Update Policy exclude list api
The NSX api changed Change-Id: Id85cb58f0e7df87d4b2be4d0eb14290684e20301
This commit is contained in:
parent
1f652652fb
commit
de329112ae
|
@ -4238,31 +4238,21 @@ class TestPolicyExcludeList(NsxPolicyLibTestCase):
|
|||
members = ["/infra/domains/default/groups/adit1"]
|
||||
with mock.patch.object(self.policy_api,
|
||||
"create_or_update") as api_call:
|
||||
result = self.resourceApi.create_or_overwrite(
|
||||
members=members,
|
||||
tenant=TEST_TENANT)
|
||||
expected_def = (
|
||||
core_defs.ExcludeListDef(
|
||||
policy_id=self.resourceApi.DEFAULT_ENTRY_ID,
|
||||
name=self.resourceApi.DEFAULT_NAME,
|
||||
members=members,
|
||||
tenant=TEST_TENANT))
|
||||
self.resourceApi.create_or_overwrite(
|
||||
members=members, tenant=TEST_TENANT)
|
||||
expected_def = core_defs.ExcludeListDef(
|
||||
members=members, tenant=TEST_TENANT)
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertIsNotNone(result)
|
||||
|
||||
def test_delete(self):
|
||||
self.skipTest("The action is not supported by this resource")
|
||||
|
||||
def test_get(self):
|
||||
obj_id = self.resourceApi.DEFAULT_ENTRY_ID
|
||||
with mock.patch.object(self.policy_api, "get",
|
||||
return_value={'id': obj_id}) as api_call:
|
||||
result = self.resourceApi.get(obj_id, tenant=TEST_TENANT)
|
||||
with mock.patch.object(self.policy_api, "get") as api_call:
|
||||
self.resourceApi.get(tenant=TEST_TENANT)
|
||||
expected_def = core_defs.ExcludeListDef(
|
||||
policy_id=obj_id,
|
||||
tenant=TEST_TENANT)
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertEqual(obj_id, result['id'])
|
||||
|
||||
def test_list(self):
|
||||
self.skipTest("The action is not supported by this resource")
|
||||
|
|
|
@ -110,7 +110,7 @@ class NsxPolicyLib(lib.NsxLibBase):
|
|||
core_resources.NsxIpv6NdraProfileApi(*args))
|
||||
self.dhcp_relay_config = core_resources.NsxDhcpRelayConfigApi(*args)
|
||||
self.certificate = core_resources.NsxPolicyCertApi(*args)
|
||||
self.exclude_list = core_resources.NsxPolicyExcludeList(*args)
|
||||
self.exclude_list = core_resources.NsxPolicyExcludeListApi(*args)
|
||||
self.load_balancer = lb_resources.NsxPolicyLoadBalancerApi(*args)
|
||||
|
||||
@property
|
||||
|
|
|
@ -51,7 +51,7 @@ WAF_PROFILES_PATH_PATTERN = (TENANTS_PATH_PATTERN +
|
|||
"waf-profiles/")
|
||||
CERTIFICATE_PATH_PATTERN = TENANTS_PATH_PATTERN + "certificates/"
|
||||
EXCLUDE_LIST_PATH_PATTERN = (TENANTS_PATH_PATTERN +
|
||||
"firewall-configuration/exclude-list/")
|
||||
"settings/firewall/security/exclude-list")
|
||||
|
||||
REALIZATION_PATH = "infra/realized-state/realized-entities?intent_path=%s"
|
||||
DHCP_REALY_PATTERN = TENANTS_PATH_PATTERN + "dhcp-relay-configs/"
|
||||
|
@ -1701,7 +1701,9 @@ class ExcludeListDef(ResourceDef):
|
|||
|
||||
@property
|
||||
def path_ids(self):
|
||||
return ('tenant', 'policy_id')
|
||||
# Adding dummy 2nd key to satisfy get_section_path
|
||||
# This resource has no keys, since it is a single object
|
||||
return ('tenant', 'Dummy')
|
||||
|
||||
@staticmethod
|
||||
def resource_type():
|
||||
|
|
|
@ -3612,46 +3612,33 @@ class NsxPolicyCertApi(NsxPolicyResourceBase):
|
|||
tenant=tenant)
|
||||
|
||||
|
||||
class NsxPolicyExcludeList(NsxPolicyResourceBase):
|
||||
class NsxPolicyExcludeListApi(NsxPolicyResourceBase):
|
||||
"""NSX Policy Exclude list."""
|
||||
|
||||
DEFAULT_ENTRY_ID = 'security-policy'
|
||||
DEFAULT_NAME = 'security-policy'
|
||||
|
||||
@property
|
||||
def entry_def(self):
|
||||
return core_defs.ExcludeListDef
|
||||
|
||||
def create_or_overwrite(self, name=DEFAULT_NAME,
|
||||
policy_id=DEFAULT_ENTRY_ID,
|
||||
members=IGNORE,
|
||||
def create_or_overwrite(self, members=IGNORE,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
exclude_list_def = self._init_def(policy_id=policy_id,
|
||||
name=name,
|
||||
members=members,
|
||||
exclude_list_def = self._init_def(members=members,
|
||||
tenant=tenant)
|
||||
|
||||
self._create_or_store(exclude_list_def)
|
||||
return policy_id
|
||||
|
||||
def delete(self, policy_id=DEFAULT_ENTRY_ID,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
def delete(self, tenant=constants.POLICY_INFRA_TENANT):
|
||||
err_msg = (_("This action is not supported"))
|
||||
raise exceptions.ManagerError(details=err_msg)
|
||||
|
||||
def get(self, policy_id=DEFAULT_ENTRY_ID,
|
||||
tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
exclude_list_def = self.entry_def(policy_id=policy_id,
|
||||
tenant=tenant)
|
||||
def get(self, tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
exclude_list_def = self.entry_def(tenant=tenant)
|
||||
return self.policy_api.get(exclude_list_def, silent=silent)
|
||||
|
||||
def list(self, tenant=constants.POLICY_INFRA_TENANT):
|
||||
err_msg = (_("This action is not supported"))
|
||||
raise exceptions.ManagerError(details=err_msg)
|
||||
|
||||
def update(self, name=DEFAULT_NAME,
|
||||
policy_id=DEFAULT_ENTRY_ID,
|
||||
members=IGNORE,
|
||||
def update(self, members=IGNORE,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
err_msg = (_("This action is not supported"))
|
||||
raise exceptions.ManagerError(details=err_msg)
|
||||
|
|
Loading…
Reference in New Issue