Browse Source

Add policy DHCP related resources support

Since version 3.0.0

Change-Id: Id961fcd50c7a3b682b5378642eed9930af7e5dce
changes/46/705346/1
asarfaty 2 months ago
parent
commit
a135d7f5ee
5 changed files with 570 additions and 31 deletions
  1. +212
    -9
      vmware_nsxlib/tests/unit/v3/policy/test_resources.py
  2. +1
    -0
      vmware_nsxlib/v3/nsx_constants.py
  3. +9
    -4
      vmware_nsxlib/v3/policy/__init__.py
  4. +173
    -7
      vmware_nsxlib/v3/policy/core_defs.py
  5. +175
    -11
      vmware_nsxlib/v3/policy/core_resources.py

+ 212
- 9
vmware_nsxlib/tests/unit/v3/policy/test_resources.py View File

@@ -3613,31 +3613,48 @@ class TestPolicySegment(NsxPolicyLibTestCase):
super(TestPolicySegment, self).setUp()
self.resourceApi = self.policy_lib.segment

def test_create(self):
def _test_create(self, tier1_id=None, mdproxy=None, dhcp_server=None):
name = 'test'
description = 'desc'
tier1_id = '111'
subnets = [core_defs.Subnet(gateway_address="2.2.2.0/24")]

kwargs = {'description': description,
'subnets': subnets,
'tenant': TEST_TENANT}

if tier1_id:
kwargs['tier1_id'] = tier1_id

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, description=description,
tier1_id=tier1_id,
subnets=subnets,
tenant=TEST_TENANT)
name, **kwargs)

expected_def = core_defs.SegmentDef(
nsx_version='3.0.0',
segment_id=mock.ANY,
name=name,
description=description,
tier1_id=tier1_id,
subnets=subnets,
tenant=TEST_TENANT)
**kwargs)

self.assert_called_with_def(api_call, expected_def)
self.assertIsNotNone(result)

def test_create_with_t1(self):
self._test_create(tier1_id='111')

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:
@@ -4725,6 +4742,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):
@@ -4778,6 +4892,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):

+ 1
- 0
vmware_nsxlib/v3/nsx_constants.py View File

@@ -175,6 +175,7 @@ FEATURE_RELAX_SCALE_VALIDATION = 'Relax Scale Validation for LbService'
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

+ 9
- 4
vmware_nsxlib/v3/policy/__init__.py View File

@@ -114,9 +114,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)
@@ -153,13 +156,13 @@ class NsxPolicyLib(lib.NsxLibBase):
if (version.LooseVersion(self.get_version()) >=
version.LooseVersion(nsx_constants.NSX_VERSION_2_4_0)):
# Features available since 2.4
if (feature == nsx_constants.FEATURE_NSX_POLICY_NETWORKING):
if feature == nsx_constants.FEATURE_NSX_POLICY_NETWORKING:
return True

if (version.LooseVersion(self.get_version()) >=
version.LooseVersion(nsx_constants.NSX_VERSION_2_5_0)):
# Features available since 2.5
if (feature == nsx_constants.FEATURE_ENS_WITH_QOS):
if feature == nsx_constants.FEATURE_ENS_WITH_QOS:
return True

if (version.LooseVersion(self.get_version()) >=
@@ -169,9 +172,11 @@ class NsxPolicyLib(lib.NsxLibBase):
return True
if feature == nsx_constants.FEATURE_NSX_POLICY_MDPROXY:
return True
if (feature == nsx_constants.FEATURE_RELAX_SCALE_VALIDATION):
if feature == nsx_constants.FEATURE_RELAX_SCALE_VALIDATION:
return True
if (feature == nsx_constants.FEATURE_NSX_POLICY_GLOBAL_CONFIG):
if feature == nsx_constants.FEATURE_NSX_POLICY_DHCP:
return True
if feature == nsx_constants.FEATURE_NSX_POLICY_GLOBAL_CONFIG:
return True

return (feature == nsx_constants.FEATURE_NSX_POLICY)

+ 173
- 7
vmware_nsxlib/v3/policy/core_defs.py View File

@@ -15,12 +15,16 @@
#

import abc
from distutils import version

from oslo_log import log as logging
import six

from vmware_nsxlib.v3 import nsx_constants
from vmware_nsxlib.v3.policy import constants
from vmware_nsxlib.v3 import utils

from vmware_nsxlib.v3.policy import constants
LOG = logging.getLogger(__name__)

TENANTS_PATH_PATTERN = "%s/"
DOMAINS_PATH_PATTERN = TENANTS_PATH_PATTERN + "domains/"
@@ -56,6 +60,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 +
@@ -675,14 +680,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

@@ -703,13 +764,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)
@@ -761,6 +821,23 @@ class SegmentDef(BaseSegmentDef):
def path_defs(self):
return (TenantDef,)

def _version_dependant_attr_supported(self, attr):
if (version.LooseVersion(self.nsx_version) >=
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."
"Current NSX version: %s. Minimum supported version: %s",
attr, self.resource_type, self.attrs.get('name', ''),
self.nsx_version, nsx_constants.NSX_VERSION_3_0_0)
return False

return False

def get_obj_dict(self):
body = super(SegmentDef, self).get_obj_dict()
if self.has_attr('tier1_id'):
@@ -787,7 +864,8 @@ class SegmentDef(BaseSegmentDef):

# TODO(annak): support also tier0

if self.has_attr('metadata_proxy_id'):
if (self.has_attr('metadata_proxy_id') and
self._version_dependant_attr_supported('metadata_proxy_id')):
paths = ""
if self.get_attr('metadata_proxy_id'):
mdproxy = MetadataProxyDef(
@@ -798,6 +876,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


@@ -1776,6 +1917,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):

+ 175
- 11
vmware_nsxlib/v3/policy/core_resources.py View File

@@ -1811,6 +1811,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
vlan_ids=IGNORE,
transport_zone_id=IGNORE,
metadata_proxy_id=IGNORE,
dhcp_server_config_id=IGNORE,
tags=IGNORE,
tenant=constants.POLICY_INFRA_TENANT):

@@ -1822,17 +1823,19 @@ 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,
subnets=subnets,
dns_domain_name=dns_domain_name,
vlan_ids=vlan_ids,
transport_zone_id=transport_zone_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,
subnets=subnets,
dns_domain_name=dns_domain_name,
vlan_ids=vlan_ids,
transport_zone_id=transport_zone_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

@@ -1862,6 +1865,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
tier1_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):

if (metadata_proxy_id != IGNORE and
@@ -1878,6 +1882,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)

@@ -2450,6 +2455,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
@@ -3888,6 +3995,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

Loading…
Cancel
Save