Skip to content

Commit

Permalink
Merge "fix wrong local variable used in case of addr_from_start scheme"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Apr 4, 2017
2 parents 3c8eaa7 + 550c5a2 commit 179af0b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
37 changes: 35 additions & 2 deletions src/config/api-server/tests/test_ip_alloc.py
Expand Up @@ -1557,7 +1557,6 @@ def test_network_subnet_update(self):
vn.add_network_ipam(ipam1, vn_subnets)
self._vnc_lib.virtual_network_create(vn)
net_obj = self._vnc_lib.virtual_network_read(id = vn.uuid)

#update dns server to addr mgmt values in two subnets and keep None
# in middle subnet
ipam1_sn_v4.set_dns_server_address('11.1.1.253')
Expand Down Expand Up @@ -1622,8 +1621,42 @@ def test_network_subnet_update(self):
self._vnc_lib.virtual_network_update(vn)
net_obj = self._vnc_lib.virtual_network_read(id = vn.uuid)

#cleanup
# delete vn and create a new subnet with add from start and add
# new network
self._vnc_lib.virtual_network_delete(id=vn.uuid)

#create a subnet with allocation from start and test the subnet
# to make sure gw_ip and dns_server_address is not updateable
ipam4_sn_v4 = IpamSubnetType(subnet=SubnetType('14.1.1.0', 24),
addr_from_start=True)

ipam5_sn_v4 = IpamSubnetType(subnet=SubnetType('15.1.1.0', 24),
default_gateway='15.1.1.100',
dns_server_address='15.1.1.200',
addr_from_start=True)
vn1_subnets = VnSubnetsType([ipam4_sn_v4, ipam5_sn_v4])

vn1 = VirtualNetwork('my-v4-v6-vn', project,
virtual_network_properties=VirtualNetworkType(forwarding_mode='l3'))

vn1.add_network_ipam(ipam1, vn1_subnets)
self._vnc_lib.virtual_network_create(vn1)
net_obj = self._vnc_lib.virtual_network_read(id = vn1.uuid)

# change valid network property and and update vn1
vn1.set_address_allocation_mode('user-defined-subnet-only')
self._vnc_lib.virtual_network_update(vn1)
net_obj = self._vnc_lib.virtual_network_read(id = vn1.uuid)

# change valid subnet property and update vn1
ipam4_sn_v4.set_subnet_name('subnet4')
ipam5_sn_v4.set_subnet_name('subnet5')
vn1._pending_field_updates.add('network_ipam_refs')
self._vnc_lib.virtual_network_update(vn1)
net_obj = self._vnc_lib.virtual_network_read(id = vn1.uuid)

#cleanup
self._vnc_lib.virtual_network_delete(id=vn1.uuid)
self._vnc_lib.network_ipam_delete(id=ipam1.uuid)
self._vnc_lib.project_delete(id=project.uuid)
#end
Expand Down
2 changes: 1 addition & 1 deletion src/config/api-server/vnc_addr_mgmt.py
Expand Up @@ -1194,7 +1194,7 @@ def _validate_subnet_update(self, req_subnets, db_subnets):
network = IPNetwork('%s/%s' % (db_prefix, db_prefix_len))
if db_subnet.get('addr_from_start'):
df_gw_ip = str(IPAddress(network.first + 1))
df_dns_ser_addr = str(IPAddress(network.first + 2))
df_dns = str(IPAddress(network.first + 2))
else:
df_gw_ip = str(IPAddress(network.last - 1))
df_dns = str(IPAddress(network.last - 2))
Expand Down

0 comments on commit 179af0b

Please sign in to comment.