Merge "Allow updating a single rule entry in a Security Policy"
This commit is contained in:
commit
35e030531b
|
@ -1511,6 +1511,42 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
|
|||
|
||||
self.assert_called_with_defs(update_call, [map_def, entry_def])
|
||||
|
||||
def test_update_entry(self):
|
||||
domain_id = '111'
|
||||
map_id = '222'
|
||||
entry_id = 'entry'
|
||||
name = 'new name'
|
||||
description = 'new desc'
|
||||
source_group = 'ng1'
|
||||
dest_group = 'ng2'
|
||||
service1_id = 'nc1'
|
||||
service2_id = 'nc2'
|
||||
with mock.patch.object(self.policy_api, "get",
|
||||
return_value={}),\
|
||||
mock.patch.object(self.policy_api,
|
||||
"create_or_update") as update_call:
|
||||
self.resourceApi.update_entry(
|
||||
domain_id, map_id, entry_id,
|
||||
name=name,
|
||||
description=description,
|
||||
service_ids=[service1_id, service2_id],
|
||||
source_groups=[source_group],
|
||||
dest_groups=[dest_group],
|
||||
tenant=TEST_TENANT)
|
||||
|
||||
entry_def = self.entryDef(
|
||||
domain_id=domain_id,
|
||||
map_id=map_id,
|
||||
entry_id='entry',
|
||||
name=name,
|
||||
description=description,
|
||||
service_ids=[service1_id, service2_id],
|
||||
source_groups=[source_group],
|
||||
dest_groups=[dest_group],
|
||||
tenant=TEST_TENANT)
|
||||
|
||||
self.assert_called_with_def(update_call, entry_def)
|
||||
|
||||
def test_unset(self):
|
||||
name = 'hello'
|
||||
domain_id = 'test'
|
||||
|
|
|
@ -2653,6 +2653,35 @@ class NsxPolicySecurityPolicyBaseApi(NsxPolicyResourceBase):
|
|||
else:
|
||||
self.policy_api.create_or_update(parent_def)
|
||||
|
||||
def update_entry(self, domain_id, map_id, entry_id,
|
||||
name=IGNORE, description=IGNORE,
|
||||
sequence_number=IGNORE, service_ids=IGNORE,
|
||||
action=IGNORE, source_groups=IGNORE, dest_groups=IGNORE,
|
||||
scope=IGNORE, ip_protocol=IGNORE,
|
||||
direction=IGNORE, logged=IGNORE, tags=IGNORE,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
if self._any_arg_set(name, description, sequence_number, service_ids,
|
||||
action, source_groups, dest_groups, scope,
|
||||
ip_protocol, direction, logged, tags):
|
||||
entry_def = self._get_and_update_def(
|
||||
domain_id=domain_id,
|
||||
map_id=map_id,
|
||||
entry_id=entry_id,
|
||||
name=name,
|
||||
description=description,
|
||||
sequence_number=sequence_number,
|
||||
service_ids=service_ids,
|
||||
action=action,
|
||||
source_groups=source_groups,
|
||||
dest_groups=dest_groups,
|
||||
scope=scope,
|
||||
ip_protocol=ip_protocol,
|
||||
direction=direction,
|
||||
logged=logged,
|
||||
tags=tags,
|
||||
tenant=tenant)
|
||||
self.policy_api.create_or_update(entry_def)
|
||||
|
||||
def update_entries(self, domain_id, map_id, entries,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
map_def = self.parent_entry_def(
|
||||
|
|
Loading…
Reference in New Issue