From 1e427ba318b443075e9b87fc72e0deb1a3e27cf0 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Sun, 19 Feb 2017 04:10:47 -0800 Subject: [PATCH] Add get_code to LogicalDhcpServer This will enable the plugin to validate the supported DHCP extra options. This is done via the method get_dhcp_opt_code. If a name is not supported then None is returned. Change-Id: Ia28c2da080d79e7e1e87db0f137963a4560862bb --- vmware_nsxlib/v3/resources.py | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/vmware_nsxlib/v3/resources.py b/vmware_nsxlib/v3/resources.py index 07d71b14..b6d48521 100644 --- a/vmware_nsxlib/v3/resources.py +++ b/vmware_nsxlib/v3/resources.py @@ -520,6 +520,49 @@ class DhcpProfile(AbstractRESTResource): class LogicalDhcpServer(AbstractRESTResource): + 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-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, + 'etherboot': 175, + 'config-file': 209, + 'path-prefix': 210, + 'reboot-time': 211, + } + return _supported_options.get(name) + @property def uri_segment(self): return 'dhcp/servers'