From aa4624dec7f30da855060fe7068e7aa3c06ddb51 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Wed, 9 Jan 2019 10:04:31 +0200 Subject: [PATCH] Move get_dhcp_opt_code to utils so it can be consumed bt policy users as well. Change-Id: Ic11dd771fa7eee81c3054a91fb5cd029e02edf8f --- vmware_nsxlib/v3/resources.py | 44 +-------------------------------- vmware_nsxlib/v3/utils.py | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/vmware_nsxlib/v3/resources.py b/vmware_nsxlib/v3/resources.py index 2f515248..1048d1b0 100644 --- a/vmware_nsxlib/v3/resources.py +++ b/vmware_nsxlib/v3/resources.py @@ -392,49 +392,7 @@ class DhcpProfile(core_resources.NsxLibDhcpProfile): class LogicalDhcpServer(utils.NsxLibApiBase): def get_dhcp_opt_code(self, name): - _supported_options = { - 'subnet-mask': 1, - 'time-offset': 2, - 'router': 3, - 'dns-name': 6, - 'host-name': 12, - 'boot-file-size': 13, - 'domain-name': 15, - 'ip-forwarding': 19, - 'interface-mtu': 26, - 'broadcast-address': 28, - 'arp-cache-timeout': 35, - 'nis-domain': 40, - 'nis-servers': 41, - 'ntp-servers': 42, - 'netbios-name-servers': 44, - 'netbios-dd-server': 45, - 'netbios-node-type': 46, - 'netbios-scope': 47, - 'dhcp-renewal-time': 58, - 'dhcp-rebinding-time': 59, - 'class-id': 60, - 'dhcp-client-identifier': 61, - 'nisplus-domain': 64, - 'nisplus-servers': 65, - 'tftp-server': 66, - 'tftp-server-name': 66, - 'bootfile-name': 67, - 'system-architecture': 93, - 'interface-id': 94, - 'machine-id': 97, - 'name-search': 117, - 'subnet-selection': 118, - 'domain-search': 119, - 'classless-static-route': 121, - 'tftp-server-address': 150, - 'server-ip-address': 150, - 'etherboot': 175, - 'config-file': 209, - 'path-prefix': 210, - 'reboot-time': 211, - } - return _supported_options.get(name) + return utils.get_dhcp_opt_code(name) @property def uri_segment(self): diff --git a/vmware_nsxlib/v3/utils.py b/vmware_nsxlib/v3/utils.py index 75c6b6ee..d08380ee 100644 --- a/vmware_nsxlib/v3/utils.py +++ b/vmware_nsxlib/v3/utils.py @@ -598,3 +598,49 @@ def get_l4_protocol_name(protocol_number): return nsx_constants.ICMPV4 else: return protocol_number + + +def get_dhcp_opt_code(name): + _supported_options = { + 'subnet-mask': 1, + 'time-offset': 2, + 'router': 3, + 'dns-name': 6, + 'host-name': 12, + 'boot-file-size': 13, + 'domain-name': 15, + 'ip-forwarding': 19, + 'interface-mtu': 26, + 'broadcast-address': 28, + 'arp-cache-timeout': 35, + 'nis-domain': 40, + 'nis-servers': 41, + 'ntp-servers': 42, + 'netbios-name-servers': 44, + 'netbios-dd-server': 45, + 'netbios-node-type': 46, + 'netbios-scope': 47, + 'dhcp-renewal-time': 58, + 'dhcp-rebinding-time': 59, + 'class-id': 60, + 'dhcp-client-identifier': 61, + 'nisplus-domain': 64, + 'nisplus-servers': 65, + 'tftp-server': 66, + 'tftp-server-name': 66, + 'bootfile-name': 67, + 'system-architecture': 93, + 'interface-id': 94, + 'machine-id': 97, + 'name-search': 117, + 'subnet-selection': 118, + 'domain-search': 119, + 'classless-static-route': 121, + 'tftp-server-address': 150, + 'server-ip-address': 150, + 'etherboot': 175, + 'config-file': 209, + 'path-prefix': 210, + 'reboot-time': 211, + } + return _supported_options.get(name)