Revision 9af43a69

View differences:

include/VirtualNetwork.h
478 478
    string  vlan_id;
479 479

  
480 480
    /**
481
     *  Whether or not to isolate this network with the vnm driver
482
     */
483
    int     vlan;
484

  
485
    /**
486 481
     *  Parent VNET ID if any
487 482
     */
488 483
    int     parent_vid;
......
546 541
    int from_xml(const string &xml_str);
547 542

  
548 543
    /**
549
     * Updates the BRIDGE, PHY_DEV, VLAN_ID and VLAN attributes.
544
     * Updates the BRIDGE, PHY_DEV, and VLAN_ID attributes.
550 545
     *    @param error string describing the error if any
551 546
     *    @return 0 on success
552 547
     */
share/doc/xsd/vnet.xsd
33 33
          </xs:complexType>
34 34
        </xs:element>
35 35
        <xs:element name="BRIDGE" type="xs:string"/>
36
        <xs:element name="VLAN" type="xs:integer"/>
36
        <xs:element name="VN_MAD" type="xs:integer"/>
37 37
        <xs:element name="PARENT_NETWORK_ID" type="xs:string"/>
38 38
        <xs:element name="PHYDEV" type="xs:string"/>
39 39
        <xs:element name="VLAN_ID" type="xs:string"/>
......
53 53
                    <xs:element name="SIZE" type="xs:integer"/>
54 54
                    <xs:element name="TYPE" type="xs:string"/>
55 55
                    <xs:element name="ULA_PREFIX" type="xs:string" minOccurs="0"/>
56
                    <xs:element name="VLAN" type="xs:string"  minOccurs="0"/>
56
                    <xs:element name="VN_MAD" type="xs:string"  minOccurs="0"/>
57 57
                    <xs:element name="MAC_END" type="xs:string" minOccurs="0"/>
58 58
                    <xs:element name="IP_END" type="xs:string" minOccurs="0"/>
59 59
                    <xs:element name="IP6_ULA" type="xs:string" minOccurs="0"/>
share/doc/xsd/vnet_pool.xsd
32 32
              <xs:element name="CLUSTER_ID" type="xs:integer"/>
33 33
              <xs:element name="CLUSTER" type="xs:string"/>
34 34
              <xs:element name="BRIDGE" type="xs:string"/>
35
              <xs:element name="VLAN" type="xs:integer"/>
35
              <xs:element name="VN_MAD" type="xs:integer"/>
36 36
              <xs:element name="PARENT_NETWORK_ID" type="xs:string"/>
37 37
              <xs:element name="PHYDEV" type="xs:string"/>
38 38
              <xs:element name="VLAN_ID" type="xs:string"/>
......
53 53
                          <xs:element name="SIZE" type="xs:integer"/>
54 54
                          <xs:element name="TYPE" type="xs:string"/>
55 55
                          <xs:element name="ULA_PREFIX" type="xs:string" minOccurs="0"/>
56
                          <xs:element name="VLAN" type="xs:string"  minOccurs="0"/>
56
                          <xs:element name="VN_MAD" type="xs:string"  minOccurs="0"/>
57 57
                        </xs:sequence>
58 58
                      </xs:complexType>
59 59
                    </xs:element>
share/etc/oned.conf
889 889
VNET_RESTRICTED_ATTR = "VN_MAD"
890 890
VNET_RESTRICTED_ATTR = "PHYDEV"
891 891
VNET_RESTRICTED_ATTR = "VLAN_ID"
892
VNET_RESTRICTED_ATTR = "VLAN"
893 892
VNET_RESTRICTED_ATTR = "BRIDGE"
894 893

  
895 894
VNET_RESTRICTED_ATTR = "AR/VN_MAD"
896 895
VNET_RESTRICTED_ATTR = "AR/PHYDEV"
897 896
VNET_RESTRICTED_ATTR = "AR/VLAN_ID"
898
VNET_RESTRICTED_ATTR = "AR/VLAN"
899 897
VNET_RESTRICTED_ATTR = "AR/BRIDGE"
900 898

  
901 899
#*******************************************************************************
src/cli/one_helper/onevm_helper.rb
730 730
            nic_default = {"NETWORK" => "-",
731 731
                           "IP" => "-",
732 732
                           "MAC"=> "-",
733
                           "VLAN"=>"no",
734 733
                           "BRIDGE"=>"-"}
735 734

  
736 735
            shown_ips = []
......
782 781
                    "NIC_ID"        => "-",
783 782
                    "IP"            => ip,
784 783
                    "NETWORK"       => "Additional IP",
785
                    "BRIDGE"        => "-",
786
                    "VLAN"          => "-"
784
                    "BRIDGE"        => "-"
787 785
                }
788 786
            end
789 787

  
......
804 802
                    end
805 803
                end
806 804

  
807
                column :VLAN, "", :size=>4 do |d|
808
                    if d["DOUBLE_ENTRY"]
809
                        ""
810
                    else
811
                        d["VLAN"].downcase
812
                    end
813
                end
814

  
815 805
                column :BRIDGE, "", :left, :size=>12 do |d|
816 806
                    if d["DOUBLE_ENTRY"]
817 807
                        ""
src/cli/one_helper/onevnet_helper.rb
102 102
        :description=> "Netmask in dot notation"
103 103
    ]
104 104

  
105
    VLAN = [
106
        :name       => "vlan",
107
        :large      => "--vlan",
108
        :description=> "Use network isolation"
105
    VN_MAD = [
106
        :name       => "vn_mad",
107
        :large      => "--vn_mad",
108
        :description=> "Use this driver for the network"
109 109
    ]
110 110

  
111 111
    VLAN_ID = [
......
116 116
    ]
117 117

  
118 118
    ADDAR_OPTIONS = [
119
        SIZE, MAC, IP, IP6_GLOBAL, IP6_ULA, GATEWAY, NETMASK, VLAN, VLAN_ID ]
119
        SIZE, MAC, IP, IP6_GLOBAL, IP6_ULA, GATEWAY, NETMASK, VN_MAD, VLAN_ID ]
120 120

  
121 121
    def self.rname
122 122
        "VNET"
......
212 212
        puts str % ["CLUSTERS",
213 213
            OpenNebulaHelper.clusters_str(vn.retrieve_elements("CLUSTERS/ID"))]
214 214
        puts str % ["BRIDGE", vn["BRIDGE"]]
215
        puts str % ["VLAN", OpenNebulaHelper.boolean_to_str(vn['VLAN'])]
215
        puts str % ["VN_MAD", vn['VN_MAD']] if !vn['VN_MAD'].empty?
216 216
        puts str % ["PHYSICAL DEVICE", vn["PHYDEV"]] if !vn["PHYDEV"].empty?
217 217
        puts str % ["VLAN ID", vn["VLAN_ID"]] if !vn["VLAN_ID"].empty?
218 218
        puts str % ["USED LEASES", vn['USED_LEASES']]
src/cli/onevnet
148 148
                ar << ", ULA_PREFIX = " <<
149 149
                      options[:ip6_ula] if options[:ip6_ula]
150 150
                ar << ", GATEWAY = " << options[:gateway] if options[:gateway]
151
                ar << ", MASK = " << options[:netmask] if options[:netmask]
152
                ar << ", VLAN = YES" if options[:vlan]
153
                ar << ", VLAN_ID = " << options[:vlanid] if options[:vlanid]
151
                ar << ", MASK = "    << options[:netmask] if options[:netmask]
152
                ar << ", VN_MAD = "  << options[:vn_mad]  if options[:vn_mad]
153
                ar << ", VLAN_ID = " << options[:vlanid]  if options[:vlanid]
154 154

  
155 155
                ar << "]"
156 156
            end
src/vnm/AddressRange.cc
166 166
        return -1;
167 167
    }
168 168

  
169
    /* ------------------------- VNET Attributes ---------------------------- */
170

  
171
    bool b_vlan;
172

  
173
    if ((vattr->vector_value("VLAN", b_vlan) == 0) && b_vlan)
174
    {
175
        vattr->replace("VLAN", "YES");
176
    }
177

  
178 169
    /* ------------------------- Security Groups ---------------------------- */
179 170

  
180 171
    value = vattr->vector_value("SECURITY_GROUPS");
......
816 807

  
817 808
    string vn_mad = attr->vector_value("VN_MAD");
818 809
    string bridge = attr->vector_value("BRIDGE");
819
    string vlan   = attr->vector_value("VLAN");
820 810
    string vlanid = attr->vector_value("VLAN_ID");
821 811
    string phydev = attr->vector_value("PHYDEV");
822 812

  
......
830 820
        nic->replace("BRIDGE", bridge);
831 821
    }
832 822

  
833
    if (!vlan.empty())
834
    {
835
        nic->replace("VLAN", vlan);
836
    }
837

  
838 823
    if (!phydev.empty())
839 824
    {
840 825
        nic->replace("PHYDEV", phydev);
src/vnm/VirtualNetwork.cc
107 107

  
108 108
    string sg_str;
109 109

  
110
    bool b_vlan;
111

  
112 110
    int rc, num_ars;
113 111

  
114 112
    //--------------------------------------------------------------------------
......
142 140

  
143 141
    add_template_attribute("VLAN_ID", vlan_id);
144 142

  
145
    // ------------ VLAN ----------------------
146

  
147
    erase_template_attribute("VLAN", b_vlan);
148

  
149
    if (b_vlan || !phydev.empty())
150
    {
151
        vlan = 1;
152
        add_template_attribute("VLAN", "YES");
153
    }
154
    else
155
    {
156
        vlan = 0;
157
        add_template_attribute("VLAN", "NO");
158
    }
159

  
160 143
    // ------------ BRIDGE --------------------
161 144

  
162 145
    erase_template_attribute("BRIDGE",bridge);
......
263 246
int VirtualNetwork::post_update_template(string& error)
264 247
{
265 248
    string new_bridge;
266
    bool   b_vlan;
267 249
    string sg_str;
268 250

  
269 251
    /* ---------------------------------------------------------------------- */
......
271 253
    /*  - VN_MAD                                                              */
272 254
    /*  - PHYDEV                                                              */
273 255
    /*  - VLAN_ID                                                             */
274
    /*  - VLAN                                                                */
275 256
    /*  - BRIDGE                                                              */
276 257
    /*  - SECURITY_GROUPS                                                     */
277 258
    /* ---------------------------------------------------------------------- */
......
287 268

  
288 269
    add_template_attribute("VLAN_ID", vlan_id);
289 270

  
290
    erase_template_attribute("VLAN", b_vlan);
291

  
292
    if (b_vlan || !phydev.empty())
293
    {
294
        vlan = 1;
295
        add_template_attribute("VLAN", "YES");
296
    }
297
    else
298
    {
299
        vlan = 0;
300
        add_template_attribute("VLAN", "NO");
301
    }
302

  
303 271
    erase_template_attribute("BRIDGE",new_bridge);
304 272

  
305 273
    if (!new_bridge.empty())
......
437 405

  
438 406
    os <<
439 407
        "<VNET>" <<
440
            "<ID>"        << oid       << "</ID>"        <<
441
            "<UID>"       << uid       << "</UID>"       <<
442
            "<GID>"       << gid       << "</GID>"       <<
443
            "<UNAME>"     << uname     << "</UNAME>"     <<
444
            "<GNAME>"     << gname     << "</GNAME>"     <<
445
            "<NAME>"      << name      << "</NAME>"      <<
446
            perms_to_xml(perm_str)     <<
447
            Clusterable::to_xml(clusters_xml)            <<
448
            "<BRIDGE>"    << one_util::escape_xml(bridge)<< "</BRIDGE>" <<
449
            "<VLAN>"      << one_util::escape_xml(vlan)  << "</VLAN>";
408
            "<ID>"     << oid      << "</ID>"    <<
409
            "<UID>"    << uid      << "</UID>"   <<
410
            "<GID>"    << gid      << "</GID>"   <<
411
            "<UNAME>"  << uname    << "</UNAME>" <<
412
            "<GNAME>"  << gname    << "</GNAME>" <<
413
            "<NAME>"   << name     << "</NAME>"  <<
414
            perms_to_xml(perm_str) <<
415
            Clusterable::to_xml(clusters_xml)    <<
416
            "<BRIDGE>" << one_util::escape_xml(bridge) << "</BRIDGE>";
450 417

  
451 418
    if (parent_vid != -1)
452 419
    {
......
483 450
    {
484 451
        os << "<VLAN_ID/>";
485 452
    }
486
    os  << "<USED_LEASES>"<< ar_pool.get_used_addr() << "</USED_LEASES>";
453

  
454
    os << "<USED_LEASES>"<< ar_pool.get_used_addr() << "</USED_LEASES>";
487 455

  
488 456
    os << vrouters.to_xml(vrouters_xml);
489 457

  
490
    os  << obj_template->to_xml(template_xml);
458
    os << obj_template->to_xml(template_xml);
491 459

  
492
    os  << ar_pool.to_xml(leases_xml, extended, vms, vnets, vrs);
460
    os << ar_pool.to_xml(leases_xml, extended, vms, vnets, vrs);
493 461

  
494 462
    os << "</VNET>";
495 463

  
......
511 479
    update_from_str(xml_str);
512 480

  
513 481
    // Get class base attributes
514
    rc += xpath(oid,       "/VNET/ID", -1);
515
    rc += xpath(uid,       "/VNET/UID", -1);
516
    rc += xpath(gid,       "/VNET/GID", -1);
517
    rc += xpath(uname,     "/VNET/UNAME", "not_found");
518
    rc += xpath(gname,     "/VNET/GNAME", "not_found");
519
    rc += xpath(name,      "/VNET/NAME", "not_found");
520
    rc += xpath(bridge,    "/VNET/BRIDGE", "not_found");
521
    rc += xpath(vlan,      "/VNET/VLAN", 0);
482
    rc += xpath(oid,    "/VNET/ID",  -1);
483
    rc += xpath(uid,    "/VNET/UID", -1);
484
    rc += xpath(gid,    "/VNET/GID", -1);
485
    rc += xpath(uname,  "/VNET/UNAME", "not_found");
486
    rc += xpath(gname,  "/VNET/GNAME", "not_found");
487
    rc += xpath(name,   "/VNET/NAME",  "not_found");
488
    rc += xpath(bridge, "/VNET/BRIDGE","not_found");
522 489

  
523 490
    // Permissions
524 491
    rc += perms_from_xml();
......
601 568
    nic->replace("NETWORK_ID", oid);
602 569
    nic->replace("BRIDGE", bridge);
603 570

  
604
    if ( vlan == 1 )
605
    {
606
        nic->replace("VLAN", "YES");
607
    }
608
    else
609
    {
610
        nic->replace("VLAN", "NO");
611
    }
612

  
613 571
    if (!vn_mad.empty())
614 572
    {
615 573
        nic->replace("VN_MAD", vn_mad);

Also available in: Unified diff