Revision 9af43a69 src/vnm/VirtualNetwork.cc

View differences:

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