Comment 2 for bug 1381082

Revision history for this message
Jacek Świderski (jacek-swiderski) wrote :

Here's the example:

>>> 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.