NSX|P: Fix DHCP server onfig for migrated networks

Use existing dhcp server config in case addign a new subnet on a
migrated network

Change-Id: I78a22231ad2d6c0d76689e0c986d68433abbc223
This commit is contained in:
asarfaty 2020-07-06 06:44:39 +02:00 committed by Adit Sarfaty
parent 4dc0b6f323
commit c301b45a4a
2 changed files with 7 additions and 2 deletions

View File

@ -1209,10 +1209,11 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
segment_id = self._get_network_nsx_segment_id(context, net_id)
seg_subnets = self._get_segment_subnets(context, net_id, net_az=az)
dhcp_config = self._get_segment_dhcp_server_config(segment_id, az)
# Update dhcp server config on the segment
self.nsxpolicy.segment.update(
segment_id=segment_id,
dhcp_server_config_id=az._policy_dhcp_server_config,
dhcp_server_config_id=dhcp_config,
subnets=seg_subnets)
def _get_net_dhcp_subnets(self, context, net_id):

View File

@ -1221,6 +1221,8 @@ class NsxPTestSubnets(common_v3.NsxV3TestSubnets,
def test_create_dhcpv6_subnet(self):
with mock.patch("vmware_nsxlib.v3.policy.core_resources."
"NsxPolicySegmentApi.update") as seg_update,\
mock.patch("vmware_nsxlib.v3.policy.core_resources."
"NsxPolicySegmentApi.get", return_value={}),\
self.subnet(ip_version=constants.IP_VERSION_6, cidr='fe80::/64',
enable_dhcp=True) as subnet:
self.assertEqual(True, subnet['subnet']['enable_dhcp'])
@ -1238,7 +1240,9 @@ class NsxPTestSubnets(common_v3.NsxV3TestSubnets,
enable_dhcp=False) as subnet:
data = {'subnet': {'enable_dhcp': True}}
with mock.patch("vmware_nsxlib.v3.policy.core_resources."
"NsxPolicySegmentApi.update") as seg_update:
"NsxPolicySegmentApi.update") as seg_update,\
mock.patch("vmware_nsxlib.v3.policy.core_resources."
"NsxPolicySegmentApi.get", return_value={}):
req = self.new_update_request('subnets', data,
subnet['subnet']['id'])
res = self.deserialize('json', req.get_response(self.api))