NSX|v3 replace dhcp profile and metadata proxy uuids with names

Support configuration of name or uuid (instead of only uuid) for
2 nsx_v3 parameters: dhcp_profile, metadata_proxy.

nsxlib part was cherry picked from: Ife6263b7cf1759a2fc309205552eb79138d512a1

Change-Id: If82e5090426cd4198c8ff4d9bd79b3ea53046112
This commit is contained in:
Adit Sarfaty 2016-10-12 07:44:56 +03:00
parent 73c80d18c5
commit 1eda9e1cdc
2 changed files with 30 additions and 1 deletions

View File

@ -60,6 +60,10 @@ class NsxLib(object):
self.client, nsxlib_config) self.client, nsxlib_config)
self.transport_zone = NsxLibTransportZone( self.transport_zone = NsxLibTransportZone(
self.client, nsxlib_config) self.client, nsxlib_config)
self.native_dhcp_profile = NsxLibDhcpProfile(
self.client, nsxlib_config)
self.native_md_proxy = NsxLibMetadataProxy(
self.client, nsxlib_config)
self.firewall_section = security.NsxLibFirewallSection( self.firewall_section = security.NsxLibFirewallSection(
self.client, nsxlib_config) self.client, nsxlib_config)
self.ns_group = security.NsxLibNsGroup( self.ns_group = security.NsxLibNsGroup(
@ -424,6 +428,32 @@ class NsxLibTransportZone(utils.NsxLibApiBase):
'transport-zones') 'transport-zones')
class NsxLibDhcpProfile(utils.NsxLibApiBase):
def get_id_by_name_or_id(self, name_or_id):
"""Get a dhcp profile by it's display name or uuid
Return the dhcp profile data, or raise an exception if not found or
not unique
"""
return self._get_resource_by_name_or_id(name_or_id,
'dhcp/server-profiles')
class NsxLibMetadataProxy(utils.NsxLibApiBase):
def get_id_by_name_or_id(self, name_or_id):
"""Get a metadata proxy by it's display name or uuid
Return the metadata proxy data, or raise an exception if not found or
not unique
"""
return self._get_resource_by_name_or_id(name_or_id,
'md-proxies')
class NsxLibBridgeCluster(utils.NsxLibApiBase): class NsxLibBridgeCluster(utils.NsxLibApiBase):
def get_id_by_name_or_id(self, name_or_id): def get_id_by_name_or_id(self, name_or_id):

View File

@ -55,7 +55,6 @@ class NsxLibNativeDhcp(utils.NsxLibApiBase):
name = utils.get_name_and_uuid(network['name'] or 'dhcpserver', name = utils.get_name_and_uuid(network['name'] or 'dhcpserver',
network['id']) network['id'])
return {'name': name, return {'name': name,
'dhcp_profile_id': self.nsxlib_config.dhcp_profile_uuid,
'server_ip': server_ip, 'server_ip': server_ip,
'dns_nameservers': dns_nameservers, 'dns_nameservers': dns_nameservers,
'domain_name': self.nsxlib_config.dns_domain, 'domain_name': self.nsxlib_config.dns_domain,