From 6712696f6d2a27ac97398f581dc8fe1962111f68 Mon Sep 17 00:00:00 2001 From: Anna Khmelnitsky Date: Tue, 25 Jul 2017 17:49:26 -0700 Subject: [PATCH] Nsx policy: adjust to latest backend changes 1. dashes between words convention in uris 2. rename DENY action to DROP 3. Remove LogicalSwitch membership criteria Change-Id: Ida3028a89f17aa11979eb800e7e3a5b14f344edd --- vmware_nsxlib/tests/unit/v3/test_policy_api.py | 2 +- vmware_nsxlib/tests/unit/v3/test_policy_resources.py | 6 +++--- vmware_nsxlib/v3/policy_constants.py | 3 +-- vmware_nsxlib/v3/policy_defs.py | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/vmware_nsxlib/tests/unit/v3/test_policy_api.py b/vmware_nsxlib/tests/unit/v3/test_policy_api.py index 0288d4fc..a9b8f518 100644 --- a/vmware_nsxlib/tests/unit/v3/test_policy_api.py +++ b/vmware_nsxlib/tests/unit/v3/test_policy_api.py @@ -317,5 +317,5 @@ class TestPolicyDeploymentMap(TestPolicyApi): 'enforcement_point_path': ep_path} self.assert_json_call('POST', self.client, - 'infra/domains/d1/domaindeploymentmaps/dm1', + 'infra/domains/d1/domain-deployment-maps/dm1', data=expected_data) diff --git a/vmware_nsxlib/tests/unit/v3/test_policy_resources.py b/vmware_nsxlib/tests/unit/v3/test_policy_resources.py index e8cfc9b5..752154f5 100644 --- a/vmware_nsxlib/tests/unit/v3/test_policy_resources.py +++ b/vmware_nsxlib/tests/unit/v3/test_policy_resources.py @@ -205,7 +205,7 @@ class TestPolicyGroup(NsxPolicyLibTestCase): description = 'desc' cond_val = '123' cond_op = policy_constants.CONDITION_OP_EQUALS - cond_member_type = policy_constants.CONDITION_MEMBER_NET + cond_member_type = policy_constants.CONDITION_MEMBER_VM cond_key = policy_constants.CONDITION_KEY_TAG with mock.patch.object(self.policy_api, "create_or_update") as api_call: @@ -1054,8 +1054,8 @@ class TestPolicyDeploymentMap(NsxPolicyLibTestCase): expected_def = policy_defs.DeploymentMapDef(map_id=id, tenant=TEST_TENANT) domain_path = "/%s/domains/%s" % (TEST_TENANT, domain_id) - ep_path = ("/%s/deploymentzones/default/" - "enforcementpoints/%s" % (TEST_TENANT, ep_id)) + ep_path = ("/%s/deployment-zones/default/" + "enforcement-points/%s" % (TEST_TENANT, ep_id)) expected_dict = {'display_name': name, 'enforcement_point_paths': [ep_path], 'domain_path': domain_path} diff --git a/vmware_nsxlib/v3/policy_constants.py b/vmware_nsxlib/v3/policy_constants.py index 187f9394..9c3081bd 100644 --- a/vmware_nsxlib/v3/policy_constants.py +++ b/vmware_nsxlib/v3/policy_constants.py @@ -19,14 +19,13 @@ UDP = 'UDP' POLICY_INFRA_TENANT = 'infra' ACTION_ALLOW = 'ALLOW' -ACTION_DENY = 'DENY' +ACTION_DENY = 'DROP' ANY_GROUP = 'ANY' CONDITION_KEY_TAG = 'Tag' CONDITION_MEMBER_VM = 'VirtualMachine' CONDITION_MEMBER_PORT = 'LogicalPort' -CONDITION_MEMBER_NET = 'LogicalSwitch' CONDITION_OP_EQUALS = 'EQUALS' CONDITION_OP_CONTAINS = 'CONTAINS' CONDITION_OP_STARTS_WITH = 'STARTSWITH' diff --git a/vmware_nsxlib/v3/policy_defs.py b/vmware_nsxlib/v3/policy_defs.py index 050eb129..38a70e0f 100644 --- a/vmware_nsxlib/v3/policy_defs.py +++ b/vmware_nsxlib/v3/policy_defs.py @@ -470,7 +470,7 @@ class EnforcementPointDef(ResourceDef): @property def path_pattern(self): return (TENANTS_PATH_PATTERN + - 'deploymentzones/default/enforcementpoints/') + 'deployment-zones/default/enforcement-points/') def get_obj_dict(self): body = super(EnforcementPointDef, self).get_obj_dict() @@ -526,7 +526,7 @@ class DeploymentMapDef(ResourceDef): @property def path_pattern(self): - return (DOMAINS_PATH_PATTERN + '%s/domaindeploymentmaps/') + return (DOMAINS_PATH_PATTERN + '%s/domain-deployment-maps/') def get_obj_dict(self): body = super(DeploymentMapDef, self).get_obj_dict()