>>> from vnc_api.vnc_api import *
>>> vnc = VncApi("admin",'contrail123',"admin","127.0.0.1","8082","/")
>>> vnc.network_ipams_list()
{u'network-ipams': [{u'href': u'http://127.0.0.1:8082/network-ipam/f9b58449-f9bc-4134-a2b1-a1a00582f404', u'fq_name': [u'default-domain', u'default-project', u'default-network-ipam'], u'uuid': u'f9b58449-f9bc-4134-a2b1-a1a00582f404'}]}
>>> ipam = vnc.network_ipam_read(id="f9b58449-f9bc-4134-a2b1-a1a00582f404")
>>> vn_blue_obj = VirtualNetwork('vn')
>>> vn_obj = VirtualNetwork('vn')
>>> vn_obj.add_network_ipam(ipam,VnSubnetsType([IpamSubnetType(subnet = SubnetType('10.1.1.0', 24)),IpamSubnetType(subnet = SubnetType('190.1.1.0', 24))]))
>>> vnc.virtual_network_create(vn_obj)
// now network has 2 subnets attached - 10.1.1.0/24 and 190.1.1.0/24 - http://pastebin.com/zRUWUzVu
>>> vn_obj = vnc.virtual_network_read(id='6317af36-c9f6-4ff0-b82f-5ab3b7045563')
>>> vn_obj.add_network_ipam(ipam,VnSubnetsType([IpamSubnetType(subnet = SubnetType('30.1.1.0', 12)),IpamSubnetType(subnet = SubnetType('19.1.1.0', 18))]))
>>> vnc.virtual_network_update(vn_obj)
u'{"virtual-network": {"href": "http://127.0.0.1:8082/virtual-network/6317af36-c9f6-4ff0-b82f-5ab3b7045563", "uuid": "6317af36-c9f6-4ff0-b82f-5ab3b7045563"}}'
// after update network has the same subnets as before update - only modification date changed - http://pastebin.com/A5eKv8nm
note - there is no explicit documentation about it being expected behavior but comment in method suggests that if we add already existing IPAM with new attr (VnSubnetsType) it should be updated to newly passed value - if that's not the case I would be thankful for clarification.
Here's the example:
>>> from vnc_api.vnc_api import * "admin" ,'contrail123' ,"admin" ,"127.0. 0.1","8082" ,"/") ipams_list( ) 127.0.0. 1:8082/ network- ipam/f9b58449- f9bc-4134- a2b1-a1a00582f4 04', u'fq_name': [u'default-domain', u'default-project', u'default- network- ipam'], u'uuid': u'f9b58449- f9bc-4134- a2b1-a1a00582f4 04'}]} ipam_read( id="f9b58449- f9bc-4134- a2b1-a1a00582f4 04") 'vn') 'vn') add_network_ ipam(ipam, VnSubnetsType( [IpamSubnetType (subnet = SubnetType( '10.1.1. 0', 24)),IpamSubnet Type(subnet = SubnetType( '190.1. 1.0', 24))])) network_ create( vn_obj) pastebin. com/zRUWUzVu network_ read(id= '6317af36- c9f6-4ff0- b82f-5ab3b70455 63') add_network_ ipam(ipam, VnSubnetsType( [IpamSubnetType (subnet = SubnetType( '30.1.1. 0', 12)),IpamSubnet Type(subnet = SubnetType( '19.1.1. 0', 18))])) network_ update( vn_obj) network" : {"href": "http:// 127.0.0. 1:8082/ virtual- network/ 6317af36- c9f6-4ff0- b82f-5ab3b70455 63", "uuid": "6317af36- c9f6-4ff0- b82f-5ab3b70455 63"}}' pastebin. com/A5eKv8nm
>>> vnc = VncApi(
>>> vnc.network_
{u'network-ipams': [{u'href': u'http://
>>> ipam = vnc.network_
>>> vn_blue_obj = VirtualNetwork(
>>> vn_obj = VirtualNetwork(
>>> vn_obj.
>>> vnc.virtual_
// now network has 2 subnets attached - 10.1.1.0/24 and 190.1.1.0/24 - http://
>>> vn_obj = vnc.virtual_
>>> vn_obj.
>>> vnc.virtual_
u'{"virtual-
// after update network has the same subnets as before update - only modification date changed - http://
note - there is no explicit documentation about it being expected behavior but comment in method suggests that if we add already existing IPAM with new attr (VnSubnetsType) it should be updated to newly passed value - if that's not the case I would be thankful for clarification.