From 1eda9e1cdcebe09b93b3a43ae66b60ca721eca0d Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Wed, 12 Oct 2016 07:44:56 +0300 Subject: [PATCH] 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 --- vmware_nsxlib/v3/__init__.py | 30 ++++++++++++++++++++++++++++++ vmware_nsxlib/v3/native_dhcp.py | 1 - 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/vmware_nsxlib/v3/__init__.py b/vmware_nsxlib/v3/__init__.py index f1ba264f..a26f1180 100644 --- a/vmware_nsxlib/v3/__init__.py +++ b/vmware_nsxlib/v3/__init__.py @@ -60,6 +60,10 @@ class NsxLib(object): self.client, nsxlib_config) self.transport_zone = NsxLibTransportZone( 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.client, nsxlib_config) self.ns_group = security.NsxLibNsGroup( @@ -424,6 +428,32 @@ class NsxLibTransportZone(utils.NsxLibApiBase): '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): def get_id_by_name_or_id(self, name_or_id): diff --git a/vmware_nsxlib/v3/native_dhcp.py b/vmware_nsxlib/v3/native_dhcp.py index 3942f694..cd530e78 100644 --- a/vmware_nsxlib/v3/native_dhcp.py +++ b/vmware_nsxlib/v3/native_dhcp.py @@ -55,7 +55,6 @@ class NsxLibNativeDhcp(utils.NsxLibApiBase): name = utils.get_name_and_uuid(network['name'] or 'dhcpserver', network['id']) return {'name': name, - 'dhcp_profile_id': self.nsxlib_config.dhcp_profile_uuid, 'server_ip': server_ip, 'dns_nameservers': dns_nameservers, 'domain_name': self.nsxlib_config.dns_domain,