Set empty values in segment subnet when not set
This will allow updating subnets witout DHCP settings Change-Id: I78e795ca9228d92a5d1eb77fa11b842c0f9f145c
This commit is contained in:
parent
2a16f624b1
commit
73ac3ef535
|
@ -26,8 +26,6 @@ from vmware_nsxlib.v3 import utils
|
|||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
TENANTS_PATH_PATTERN = "%s/"
|
||||
DOMAINS_PATH_PATTERN = TENANTS_PATH_PATTERN + "domains/"
|
||||
IP_BLOCKS_PATH_PATTERN = TENANTS_PATH_PATTERN + "ip-blocks/"
|
||||
|
@ -751,15 +749,20 @@ class Subnet(object):
|
|||
self.dhcp_ranges = dhcp_ranges
|
||||
self.dhcp_config = dhcp_config
|
||||
|
||||
def get_obj_dict(self):
|
||||
def get_obj_dict(self, nsx_version):
|
||||
body = {'gateway_address': self.gateway_address}
|
||||
|
||||
if self.dhcp_ranges:
|
||||
body['dhcp_ranges'] = self.dhcp_ranges
|
||||
if self.dhcp_config:
|
||||
|
||||
if self.dhcp_config is not None:
|
||||
body['dhcp_config'] = (
|
||||
self.dhcp_config.get_obj_dict()
|
||||
if isinstance(self.dhcp_config, SegmentDhcpConfig)
|
||||
else self.dhcp_config)
|
||||
elif (version.LooseVersion(nsx_version) >=
|
||||
version.LooseVersion(nsx_constants.NSX_VERSION_3_0_0)):
|
||||
body['dhcp_config'] = None
|
||||
|
||||
return body
|
||||
|
||||
|
@ -832,7 +835,7 @@ class BaseSegmentDef(ResourceDef):
|
|||
if self.has_attr('subnets'):
|
||||
subnets = []
|
||||
if self.get_attr('subnets'):
|
||||
subnets = [subnet.get_obj_dict()
|
||||
subnets = [subnet.get_obj_dict(self.nsx_version)
|
||||
for subnet in self.get_attr('subnets')]
|
||||
self._set_attr_if_specified(body, 'subnets', value=subnets)
|
||||
|
||||
|
|
Loading…
Reference in New Issue