From dfa57085148ae987f62480101318d821662c9136 Mon Sep 17 00:00:00 2001 From: asarfaty Date: Wed, 11 Dec 2019 11:15:26 +0200 Subject: [PATCH] Add policy DHCP related resources support Since version 3.0.0 Change-Id: Id961fcd50c7a3b682b5378642eed9930af7e5dce --- .../tests/unit/v3/policy/test_resources.py | 195 +++++++++++++++++- vmware_nsxlib/v3/nsx_constants.py | 1 + vmware_nsxlib/v3/policy/__init__.py | 5 + vmware_nsxlib/v3/policy/core_defs.py | 156 +++++++++++++- vmware_nsxlib/v3/policy/core_resources.py | 190 +++++++++++++++-- 5 files changed, 528 insertions(+), 19 deletions(-) diff --git a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py index e3144382..72f3f29b 100644 --- a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py @@ -3735,7 +3735,8 @@ class TestPolicySegment(NsxPolicyLibTestCase): super(TestPolicySegment, self).setUp() self.resourceApi = self.policy_lib.segment - def _test_create(self, tier1_id=None, tier0_id=None, mdproxy=None): + def _test_create(self, tier1_id=None, tier0_id=None, mdproxy=None, + dhcp_server=None): name = 'test' description = 'desc' subnets = [core_defs.Subnet(gateway_address="2.2.2.0/24")] @@ -3752,6 +3753,9 @@ class TestPolicySegment(NsxPolicyLibTestCase): if mdproxy: kwargs['metadata_proxy_id'] = mdproxy + if dhcp_server: + kwargs['dhcp_server_config_id'] = dhcp_server + with mock.patch.object(self.policy_api, "create_or_update") as api_call: result = self.resourceApi.create_or_overwrite(name, **kwargs) @@ -3779,6 +3783,9 @@ class TestPolicySegment(NsxPolicyLibTestCase): def test_create_with_mdproxy(self): self._test_create(mdproxy='md1') + def test_create_with_dhcp_server_config(self): + self._test_create(dhcp_server='dhcp1') + def test_delete(self): segment_id = '111' with mock.patch.object(self.policy_api, "delete") as api_call: @@ -5023,6 +5030,103 @@ class TestPolicyTier1SegmentPort(NsxPolicyLibTestCase): self.assertEqual(info, actual_info) +class TestPolicySegmentDhcpStaticBinding(NsxPolicyLibTestCase): + + def setUp(self, *args, **kwargs): + super(TestPolicySegmentDhcpStaticBinding, self).setUp() + self.resourceApi = self.policy_lib.segment_dhcp_static_bindings + + def test_create(self): + """Create v4 static bindings""" + name = 'test' + description = 'desc' + segment_id = "segment" + ip_address = "1.1.1.1" + mac_address = "fa:16:3e:44:56:df" + + with mock.patch.object( + self.policy_api, "create_or_update") as api_call: + result = self.resourceApi.create_or_overwrite_v4( + name, segment_id, description=description, + ip_address=ip_address, mac_address=mac_address, + tenant=TEST_TENANT) + + expected_def = core_defs.DhcpV4StaticBindingConfig( + segment_id=segment_id, + binding_id=mock.ANY, + name=name, + description=description, + ip_address=ip_address, + mac_address=mac_address, + tenant=TEST_TENANT) + + self.assert_called_with_def(api_call, expected_def) + self.assertIsNotNone(result) + + def test_create_v6(self): + """Create v6 static bindings""" + name = 'test' + description = 'desc' + segment_id = "segment" + ip_address = "2000::01ab" + mac_address = "fa:16:3e:44:56:df" + + with mock.patch.object( + self.policy_api, "create_or_update") as api_call: + result = self.resourceApi.create_or_overwrite_v6( + name, segment_id, description=description, + ip_addresses=[ip_address], + mac_address=mac_address, + tenant=TEST_TENANT) + + expected_def = core_defs.DhcpV6StaticBindingConfig( + segment_id=segment_id, + binding_id=mock.ANY, + name=name, + description=description, + ip_addresses=[ip_address], + mac_address=mac_address, + tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + self.assertIsNotNone(result) + + def test_list(self): + segment_id = '111' + with mock.patch.object(self.policy_api, "list", + return_value={'results': []}) as api_call: + result = self.resourceApi.list(segment_id, tenant=TEST_TENANT) + expected_def = core_defs.DhcpV4StaticBindingConfig( + segment_id=segment_id, + tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + self.assertEqual([], result) + + def test_delete(self): + segment_id = '111' + binding_id = '222' + with mock.patch.object(self.policy_api, "delete") as api_call: + self.resourceApi.delete(segment_id, binding_id, tenant=TEST_TENANT) + expected_def = core_defs.DhcpV4StaticBindingConfig( + segment_id=segment_id, + binding_id=binding_id, + tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + + def test_get(self): + segment_id = '111' + binding_id = '222' + with mock.patch.object(self.policy_api, "get", + return_value={'id': binding_id}) as api_call: + result = self.resourceApi.get(segment_id, binding_id, + tenant=TEST_TENANT) + expected_def = core_defs.DhcpV4StaticBindingConfig( + segment_id=segment_id, + binding_id=binding_id, + tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + self.assertEqual(binding_id, result['id']) + + class TestPolicyDhcpRelayConfig(NsxPolicyLibTestCase): def setUp(self, *args, **kwargs): @@ -5076,6 +5180,95 @@ class TestPolicyDhcpRelayConfig(NsxPolicyLibTestCase): self.assertEqual([], result) +class TestPolicyDhcpServerConfig(NsxPolicyLibTestCase): + + def setUp(self, *args, **kwargs): + super(TestPolicyDhcpServerConfig, self).setUp() + self.resourceApi = self.policy_lib.dhcp_server_config + + def test_create(self): + name = 'test' + description = 'desc' + server_addr = '1.1.1.1' + lease_time = 100 + edge_cluster_path = 'dummy/path' + tags = [{'scope': 'a', 'tag': 'b'}] + + with self.mock_create_update() as api_call: + result = self.resourceApi.create_or_overwrite( + name, description=description, + server_addresses=[server_addr], + edge_cluster_path=edge_cluster_path, + lease_time=lease_time, tags=tags, + tenant=TEST_TENANT) + + expected_def = core_defs.DhcpServerConfigDef( + config_id=mock.ANY, + name=name, + description=description, + server_addresses=[server_addr], + edge_cluster_path=edge_cluster_path, + lease_time=lease_time, + tags=tags, + tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + self.assertIsNotNone(result) + + def test_delete(self): + config_id = '111' + with mock.patch.object(self.policy_api, "delete") as api_call: + self.resourceApi.delete(config_id, tenant=TEST_TENANT) + expected_def = core_defs.DhcpServerConfigDef(config_id=config_id, + tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + + def test_get(self): + config_id = '111' + with mock.patch.object(self.policy_api, "get", + return_value={'id': config_id}) as api_call: + result = self.resourceApi.get(config_id, tenant=TEST_TENANT) + expected_def = core_defs.DhcpServerConfigDef(config_id=config_id, + tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + self.assertEqual(config_id, result['id']) + + def test_list(self): + with mock.patch.object(self.policy_api, "list", + return_value={'results': []}) as api_call: + result = self.resourceApi.list(tenant=TEST_TENANT) + expected_def = core_defs.DhcpServerConfigDef(tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + self.assertEqual([], result) + + def test_update(self): + name = 'test' + description = 'desc' + server_addr = '1.1.1.1' + lease_time = 100 + edge_cluster_path = 'dummy/path' + tags = [{'scope': 'a', 'tag': 'b'}] + config_id = 'aaa' + + with self.mock_create_update() as api_call: + self.resourceApi.update( + config_id, name=name, description=description, + server_addresses=[server_addr], + edge_cluster_path=edge_cluster_path, + lease_time=lease_time, tags=tags, + tenant=TEST_TENANT) + + expected_def = core_defs.DhcpServerConfigDef( + config_id=mock.ANY, + name=name, + description=description, + server_addresses=[server_addr], + edge_cluster_path=edge_cluster_path, + lease_time=lease_time, + tags=tags, + tenant=TEST_TENANT) + self.assert_called_with_def(api_call, expected_def) + + class TestPolicyCertificate(NsxPolicyLibTestCase): def setUp(self, *args, **kwargs): diff --git a/vmware_nsxlib/v3/nsx_constants.py b/vmware_nsxlib/v3/nsx_constants.py index 94081b9a..94403ba6 100644 --- a/vmware_nsxlib/v3/nsx_constants.py +++ b/vmware_nsxlib/v3/nsx_constants.py @@ -178,6 +178,7 @@ FEATURE_GET_TZ_FROM_SWITCH = 'Get TZ endpoints from host switch' FEATURE_NSX_POLICY = 'NSX Policy' FEATURE_NSX_POLICY_NETWORKING = 'NSX Policy Networking' FEATURE_NSX_POLICY_MDPROXY = 'NSX Policy Metadata Proxy' +FEATURE_NSX_POLICY_DHCP = 'NSX Policy DHCP' FEATURE_NSX_POLICY_GLOBAL_CONFIG = 'NSX Policy Global Config' # FEATURE available depending on Inventory service backend version diff --git a/vmware_nsxlib/v3/policy/__init__.py b/vmware_nsxlib/v3/policy/__init__.py index a05e0e1d..53e2a9b1 100644 --- a/vmware_nsxlib/v3/policy/__init__.py +++ b/vmware_nsxlib/v3/policy/__init__.py @@ -117,9 +117,12 @@ class NsxPolicyLib(lib.NsxLibBase): self.segment_port_qos_profiles = ( core_resources.SegmentPortQosProfilesBindingMapApi( *args)) + self.segment_dhcp_static_bindings = ( + core_resources.SegmentDhcpStaticBindingConfigApi(*args)) self.ipv6_ndra_profile = ( core_resources.NsxIpv6NdraProfileApi(*args)) self.dhcp_relay_config = core_resources.NsxDhcpRelayConfigApi(*args) + self.dhcp_server_config = core_resources.NsxDhcpServerConfigApi(*args) self.md_proxy = core_resources.NsxPolicyMetadataProxyApi(*args) self.certificate = core_resources.NsxPolicyCertApi(*args) self.exclude_list = core_resources.NsxPolicyExcludeListApi(*args) @@ -180,6 +183,8 @@ class NsxPolicyLib(lib.NsxLibBase): return True if feature == nsx_constants.FEATURE_NSX_POLICY_MDPROXY: return True + if feature == nsx_constants.FEATURE_NSX_POLICY_DHCP: + return True if (feature == nsx_constants.FEATURE_NSX_POLICY_GLOBAL_CONFIG): return True diff --git a/vmware_nsxlib/v3/policy/core_defs.py b/vmware_nsxlib/v3/policy/core_defs.py index 6fec6e93..b65d07bc 100644 --- a/vmware_nsxlib/v3/policy/core_defs.py +++ b/vmware_nsxlib/v3/policy/core_defs.py @@ -62,6 +62,7 @@ EXCLUDE_LIST_PATH_PATTERN = (TENANTS_PATH_PATTERN + REALIZATION_PATH = "infra/realized-state/realized-entities?intent_path=%s" DHCP_REALY_PATTERN = TENANTS_PATH_PATTERN + "dhcp-relay-configs/" +DHCP_SERVER_PATTERN = TENANTS_PATH_PATTERN + "dhcp-server-configs/" MDPROXY_PATTERN = TENANTS_PATH_PATTERN + "metadata-proxies/" TIER0_LOCALE_SERVICES_PATH_PATTERN = (TIER0S_PATH_PATTERN + @@ -719,14 +720,70 @@ class Tier0NatRule(RouterNatRule): class Subnet(object): - def __init__(self, gateway_address, dhcp_ranges=None): + def __init__(self, gateway_address, dhcp_ranges=None, dhcp_config=None): self.gateway_address = gateway_address self.dhcp_ranges = dhcp_ranges + self.dhcp_config = dhcp_config def get_obj_dict(self): body = {'gateway_address': self.gateway_address} if self.dhcp_ranges: body['dhcp_ranges'] = self.dhcp_ranges + if self.dhcp_config: + body['dhcp_config'] = ( + self.dhcp_config.get_obj_dict() + if isinstance(self.dhcp_config, SegmentDhcpConfig) + else self.dhcp_config) + + return body + + +class SegmentDhcpConfig(object): + def __init__(self, server_address=None, dns_servers=None, + lease_time=None, options=None, is_ipv6=False): + if is_ipv6: + self.resource_type = 'SegmentDhcpV6Config' + else: + self.resource_type = 'SegmentDhcpV4Config' + + self.server_address = server_address + self.dns_servers = dns_servers + self.lease_time = lease_time + self.options = options + + def get_obj_dict(self): + body = {'resource_type': self.resource_type} + if self.server_address: + body['server_address'] = self.server_address + if self.dns_servers: + body['dns_servers'] = self.dns_servers + if self.lease_time: + body['lease_time'] = self.lease_time + if self.options: + body['options'] = ( + self.options.get_obj_dict() + if isinstance(self.options, DhcpOptions) + else self.options) + + return body + + +class DhcpOptions(object): + def __init__(self, option_121=None, others=None, is_ipv6=False): + if is_ipv6: + self.resource_type = 'DhcpV6Options' + else: + self.resource_type = 'DhcpV4Options' + + self.option_121 = option_121 + self.others = others + + def get_obj_dict(self): + body = {'resource_type': self.resource_type} + if self.option_121: + body['option_121'] = self.option_121 + if self.others: + body['others'] = self.others return body @@ -747,13 +804,12 @@ class BaseSegmentDef(ResourceDef): def get_obj_dict(self): body = super(BaseSegmentDef, self).get_obj_dict() if self.has_attr('subnets'): - # Note(asarfaty): removing subnets through PATCH api is not - # supported + subnets = [] if self.get_attr('subnets'): subnets = [subnet.get_obj_dict() for subnet in self.get_attr('subnets')] - self._set_attr_if_specified(body, 'subnets', - value=subnets) + self._set_attr_if_specified(body, 'subnets', value=subnets) + if self.has_attr('ip_pool_id'): ip_pool_id = self.get_attr('ip_pool_id') adv_cfg = self._get_adv_config(ip_pool_id) @@ -810,6 +866,8 @@ class SegmentDef(BaseSegmentDef): version.LooseVersion(nsx_constants.NSX_VERSION_3_0_0)): if attr == 'metadata_proxy_id': return True + if attr == 'dhcp_server_config_id': + return True else: LOG.warning( "Ignoring %s for %s %s: this feature is not supported." @@ -866,6 +924,69 @@ class SegmentDef(BaseSegmentDef): body_attr='metadata_proxy_paths', value=paths) + # TODO(asarfaty): Also support relay config here + if (self.has_attr('dhcp_server_config_id') and + self._version_dependant_attr_supported('dhcp_server_config_id')): + path = "" + if self.get_attr('dhcp_server_config_id'): + dhcp_config = DhcpServerConfigDef( + config_id=self.get_attr('dhcp_server_config_id'), + tenant=self.get_tenant()) + path = dhcp_config.get_resource_full_path() + self._set_attr_if_specified(body, 'dhcp_server_config_id', + body_attr='dhcp_config_path', + value=path) + + return body + + +class DhcpV4StaticBindingConfig(ResourceDef): + + @property + def path_pattern(self): + return SEGMENTS_PATH_PATTERN + "%s/dhcp-static-binding-configs/" + + @property + def path_ids(self): + return ('tenant', 'segment_id', 'binding_id') + + @staticmethod + def resource_type(): + return 'DhcpV4StaticBindingConfig' + + def path_defs(self): + return (TenantDef, SegmentDef) + + def get_obj_dict(self): + body = super(DhcpV4StaticBindingConfig, self).get_obj_dict() + # TODO(asarfaty): add object or v4/6 options + self._set_attrs_if_specified(body, + ['gateway_address', + 'host_name', + 'ip_address', + 'lease_time', + 'mac_address', + 'options']) + return body + + +class DhcpV6StaticBindingConfig(DhcpV4StaticBindingConfig): + + @staticmethod + def resource_type(): + return 'DhcpV6StaticBindingConfig' + + def path_defs(self): + return (TenantDef, SegmentDef) + + def get_obj_dict(self): + body = super(DhcpV6StaticBindingConfig, self).get_obj_dict() + self._set_attrs_if_specified(body, + ['domain_names', + 'dns_nameservers', + 'ip_addresses', + 'sntp_servers', + 'preferred_time']) return body @@ -1923,6 +2044,31 @@ class DhcpRelayConfigDef(ResourceDef): return body +class DhcpServerConfigDef(ResourceDef): + + @property + def path_pattern(self): + return DHCP_SERVER_PATTERN + + @property + def path_ids(self): + return ('tenant', 'config_id') + + @staticmethod + def resource_type(): + return 'DhcpServerConfig' + + def path_defs(self): + return (TenantDef,) + + def get_obj_dict(self): + body = super(DhcpServerConfigDef, self).get_obj_dict() + self._set_attrs_if_specified(body, ['edge_cluster_path', + 'server_addresses', + 'lease_time']) + return body + + class WAFProfileDef(ResourceDef): @property def path_pattern(self): diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index c5d55c06..2cecea30 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -1868,6 +1868,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase): transport_zone_id=IGNORE, ip_pool_id=IGNORE, metadata_proxy_id=IGNORE, + dhcp_server_config_id=IGNORE, tags=IGNORE, tenant=constants.POLICY_INFRA_TENANT): @@ -1877,19 +1878,21 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase): raise exceptions.InvalidInput(details=err_msg) segment_id = self._init_obj_uuid(segment_id) - segment_def = self._init_def(segment_id=segment_id, - name=name, - description=description, - tier1_id=tier1_id, - tier0_id=tier0_id, - subnets=subnets, - dns_domain_name=dns_domain_name, - vlan_ids=vlan_ids, - transport_zone_id=transport_zone_id, - ip_pool_id=ip_pool_id, - metadata_proxy_id=metadata_proxy_id, - tags=tags, - tenant=tenant) + segment_def = self._init_def( + segment_id=segment_id, + name=name, + description=description, + tier1_id=tier1_id, + tier0_id=tier0_id, + subnets=subnets, + dns_domain_name=dns_domain_name, + vlan_ids=vlan_ids, + transport_zone_id=transport_zone_id, + ip_pool_id=ip_pool_id, + metadata_proxy_id=metadata_proxy_id, + dhcp_server_config_id=dhcp_server_config_id, + tags=tags, + tenant=tenant) self._create_or_store(segment_def) return segment_id @@ -1919,6 +1922,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase): tier1_id=IGNORE, tier0_id=IGNORE, subnets=IGNORE, dns_domain_name=IGNORE, vlan_ids=IGNORE, tags=IGNORE, metadata_proxy_id=IGNORE, + dhcp_server_config_id=IGNORE, tenant=constants.POLICY_INFRA_TENANT): self._update(segment_id=segment_id, @@ -1930,6 +1934,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase): dns_domain_name=dns_domain_name, vlan_ids=vlan_ids, metadata_proxy_id=metadata_proxy_id, + dhcp_server_config_id=dhcp_server_config_id, tags=tags, tenant=tenant) @@ -2581,6 +2586,108 @@ class NsxPolicyTier1SegmentPortApi(NsxPolicyResourceBase): max_attempts=max_attempts) +# This resource is both for DhcpV4StaticBindingConfig and +# DhcpV6StaticBindingConfig +class SegmentDhcpStaticBindingConfigApi(NsxPolicyResourceBase): + @property + def entry_def(self): + return core_defs.DhcpV4StaticBindingConfig + + def create_or_overwrite(self, name, + segment_id, + binding_id=None, + **kwargs): + err_msg = (_("This action is not supported. Please call " + "create_or_overwrite_v4 or create_or_overwrite_v6")) + raise exceptions.ManagerError(details=err_msg) + + def create_or_overwrite_v4(self, name, + segment_id, + binding_id=None, + description=IGNORE, + gateway_address=IGNORE, + host_name=IGNORE, + ip_address=IGNORE, + lease_time=IGNORE, + mac_address=IGNORE, + options=IGNORE, + tags=IGNORE, + tenant=constants.POLICY_INFRA_TENANT): + + binding_id = self._init_obj_uuid(binding_id) + binding_def = self._init_def(segment_id=segment_id, + binding_id=binding_id, + name=name, + description=description, + gateway_address=gateway_address, + host_name=host_name, + ip_address=ip_address, + lease_time=lease_time, + mac_address=mac_address, + options=options, + tags=tags, + tenant=tenant) + self._create_or_store(binding_def) + return binding_id + + def create_or_overwrite_v6(self, name, + segment_id, + binding_id=None, + description=IGNORE, + domain_names=IGNORE, + dns_nameservers=IGNORE, + ip_addresses=IGNORE, + sntp_servers=IGNORE, + preferred_time=IGNORE, + lease_time=IGNORE, + mac_address=IGNORE, + options=IGNORE, + tags=IGNORE, + tenant=constants.POLICY_INFRA_TENANT): + + binding_id = self._init_obj_uuid(binding_id) + args = self._get_user_args(segment_id=segment_id, + binding_id=binding_id, + name=name, + description=description, + domain_names=domain_names, + dns_nameservers=dns_nameservers, + ip_addresses=ip_addresses, + sntp_servers=sntp_servers, + preferred_time=preferred_time, + lease_time=lease_time, + mac_address=mac_address, + options=options, + tags=tags, + tenant=tenant) + binding_def = core_defs.DhcpV6StaticBindingConfig(**args) + self._create_or_store(binding_def) + return binding_id + + def delete(self, segment_id, binding_id, + tenant=constants.POLICY_INFRA_TENANT): + binding_def = self.entry_def(segment_id=segment_id, + binding_id=binding_id, + tenant=tenant) + self.policy_api.delete(binding_def) + + def get(self, segment_id, binding_id, + tenant=constants.POLICY_INFRA_TENANT, + silent=False): + binding_def = self.entry_def(segment_id=segment_id, + binding_id=binding_id, + tenant=tenant) + return self.policy_api.get(binding_def, silent=silent) + + def list(self, segment_id, tenant=constants.POLICY_INFRA_TENANT): + binding_def = self.entry_def(segment_id=segment_id, tenant=tenant) + return self._list(binding_def) + + def update(self, segment_id, binding_id, **kwargs): + err_msg = (_("This action is currently not supported")) + raise exceptions.ManagerError(details=err_msg) + + class NsxPolicyIpBlockApi(NsxPolicyResourceBase): """NSX Policy IP Block API""" @property @@ -4039,6 +4146,63 @@ class NsxDhcpRelayConfigApi(NsxPolicyResourceBase): tenant=tenant) +class NsxDhcpServerConfigApi(NsxPolicyResourceBase): + @property + def entry_def(self): + return core_defs.DhcpServerConfigDef + + def create_or_overwrite(self, name, + config_id=None, + description=None, + server_addresses=IGNORE, + edge_cluster_path=IGNORE, + lease_time=IGNORE, + tags=IGNORE, + tenant=constants.POLICY_INFRA_TENANT): + + config_id = self._init_obj_uuid(config_id) + config_def = self._init_def( + config_id=config_id, + name=name, + description=description, + server_addresses=server_addresses, + edge_cluster_path=edge_cluster_path, + lease_time=lease_time, + tags=tags, + tenant=tenant) + self._create_or_store(config_def) + return config_id + + def delete(self, config_id, tenant=constants.POLICY_INFRA_TENANT): + config_def = self.entry_def(config_id=config_id, tenant=tenant) + self.policy_api.delete(config_def) + + def get(self, config_id, tenant=constants.POLICY_INFRA_TENANT, + silent=False): + config_def = self.entry_def(config_id=config_id, tenant=tenant) + return self.policy_api.get(config_def, silent=silent) + + def list(self, tenant=constants.POLICY_INFRA_TENANT): + config_def = self.entry_def(tenant=tenant) + return self._list(config_def) + + def update(self, config_id, name=IGNORE, + description=IGNORE, + server_addresses=IGNORE, + edge_cluster_path=IGNORE, + lease_time=IGNORE, + tags=IGNORE, + tenant=constants.POLICY_INFRA_TENANT): + self._update(config_id=config_id, + name=name, + description=description, + server_addresses=server_addresses, + edge_cluster_path=edge_cluster_path, + lease_time=lease_time, + tags=tags, + tenant=tenant) + + class NsxPolicyCertApi(NsxPolicyResourceBase): """NSX Policy Certificate API.""" @property