Revision 74aa41ba src/vnm/VirtualNetwork.cc

View differences:

src/vnm/VirtualNetwork.cc
547 547

  
548 548
/* -------------------------------------------------------------------------- */
549 549
/* -------------------------------------------------------------------------- */
550

  
551
int VirtualNetwork::nic_attribute(VectorAttribute *nic, int vid)
552
{
553
    int rc;
554

  
555
    string  network;
556
    string  model;
557
    string  ip;
558
    string  mac;
559

  
560
    ostringstream  vnid;
561

  
562
    map<string,string> new_nic;
563

  
564
    network = nic->vector_value("NETWORK");
565
    model   = nic->vector_value("MODEL");
566
    ip      = nic->vector_value("IP");
567
    vnid   << oid;
568

  
569
    //--------------------------------------------------------------------------
570
    //                       GET NETWORK LEASE
571
    //--------------------------------------------------------------------------
572

  
573
    if (ip.empty())
574
    {
575
        rc = leases->get(vid,ip,mac);
576
    }
577
    else
578
    {
579
        rc = leases->set(vid,ip,mac);
580
    }
581

  
582
    if ( rc != 0 )
583
    {
584
        return -1;
585
    }
586

  
587
    //--------------------------------------------------------------------------
588
    //                       NEW NIC ATTRIBUTES
589
    //--------------------------------------------------------------------------
590

  
591
    new_nic.insert(make_pair("NETWORK",network));
592
    new_nic.insert(make_pair("MAC"    ,mac));
593
    new_nic.insert(make_pair("BRIDGE" ,bridge));
594
    new_nic.insert(make_pair("VNID"   ,vnid.str()));
595
    new_nic.insert(make_pair("IP"     ,ip));
596

  
597
    if (!model.empty())
598
    {
599
        new_nic.insert(make_pair("MODEL",model));
600
    }
601

  
602
    nic->replace(new_nic);
603

  
604
    return 0;
605
}
606

  
607
/* -------------------------------------------------------------------------- */
608
/* -------------------------------------------------------------------------- */

Also available in: Unified diff