Revision 0dbb3330 src/vnm/VirtualNetwork.cc

View differences:

src/vnm/VirtualNetwork.cc
29 29
/* Virtual Network :: Constructor/Destructor                                  */
30 30
/* ************************************************************************** */
31 31

  
32
VirtualNetwork::VirtualNetwork():
32
VirtualNetwork::VirtualNetwork(VirtualNetworkTemplate *_vn_template):
33 33
                PoolObjectSQL(-1),
34 34
                name(""),
35 35
                uid(-1),
36 36
                bridge(""),
37 37
                type(UNINITIALIZED),
38
                leases(0){};
38
                leases(0)
39
{
40
    if (_vn_template != 0)
41
    {
42
        vn_template = _vn_template;
43
    }
44
    else
45
    {
46
        vn_template = new VirtualNetworkTemplate;
47
    }
48
};
39 49

  
40 50
/* -------------------------------------------------------------------------- */
41 51
/* -------------------------------------------------------------------------- */
......
46 56
    {
47 57
        delete leases;
48 58
    }
59

  
60
    if (vn_template != 0)
61
    {
62
        delete vn_template;
63
    }
49 64
}
50 65

  
51 66
/* ************************************************************************** */
......
89 104
    public_vnet = atoi(values[PUBLIC]);
90 105

  
91 106
    // Virtual Network template ID is the Network ID
92
    vn_template.id = oid;
107
    vn_template->id = oid;
93 108

  
94 109
    return 0;
95 110
}
......
128 143
    }
129 144

  
130 145
    //Get the template
131
    rc = vn_template.select(db);
146
    rc = vn_template->select(db);
132 147

  
133 148
    if (rc != 0)
134 149
    {
......
315 330

  
316 331
    public_vnet = (pub == "YES");
317 332

  
318
    vn_template.erase("PUBLIC");
333
    vn_template->erase("PUBLIC");
319 334

  
320 335
    // ------------ INSERT THE TEMPLATE --------------------
321 336

  
322
    if ( vn_template.id == -1 )
337
    if ( vn_template->id == -1 )
323 338
    {
324
        vn_template.id = oid;
339
        vn_template->id = oid;
325 340
    }
326 341

  
327
    rc = vn_template.insert(db);
342
    rc = vn_template->insert(db);
328 343

  
329 344
    if ( rc != 0 )
330 345
    {
......
425 440

  
426 441
error_update:
427 442
    ose << "Can not update Virtual Network id " << oid;
428
    vn_template.drop(db);
443
    vn_template->drop(db);
429 444
    goto error_common;
430 445

  
431 446
error_addr:
......
506 521
    ostringstream   oss;
507 522
    int             rc;
508 523

  
509
    vn_template.drop(db);
524
    vn_template->drop(db);
510 525

  
511 526
    if ( leases != 0 )
512 527
    {
......
558 573
            "<TYPE>"    << type         << "</TYPE>" <<
559 574
            "<BRIDGE>"  << bridge       << "</BRIDGE>" <<
560 575
            "<PUBLIC>"  << public_vnet  << "</PUBLIC>" <<
561
            vn_template.to_xml(template_xml);
576
            vn_template->to_xml(template_xml);
562 577
    if (leases)
563 578
    {
564 579
        os << leases->to_xml(leases_xml);
......
596 611
    os << "Bridge            : " << bridge      << endl;
597 612
    os << "Public            : " << public_vnet << endl << endl;
598 613

  
599
    os << "....: Template :...." << vn_template.to_str(template_str) << endl << endl;
614
    os << "....: Template :...." << vn_template->to_str(template_str) << endl <<
615
endl;
600 616

  
601 617
    if (leases)
602 618
    {

Also available in: Unified diff