Add allow_partial_updates param for PrefixList API

Need to set allow_partial_updates param for PrefixList
update API to allow update prefix to [].

Change-Id: I5567fd8e4d25f69d09ec5362499bb1631c4d83ae
This commit is contained in:
lxiaopei 2023-08-30 14:00:16 +08:00
parent 9341330fdb
commit d73f0aeb76
2 changed files with 24 additions and 2 deletions

View File

@ -7189,6 +7189,26 @@ class TestPolicyTier0PrefixList(NsxPolicyLibTestCase):
self.assert_called_with_def(update_call, expected_def)
def test_non_partial_update(self):
tier0_id = 't0_test'
prefix_list_id = 'prefix_list_test'
name = 'new_name'
prefixes = []
with self.mock_get(tier0_id, name), \
self.mock_create_update() as update_call:
self.resourceApi.update(name, tier0_id, prefix_list_id, prefixes,
tenant=TEST_TENANT,
allow_partial_updates=False)
expected_def = core_defs.Tier0PrefixListDef(
tier0_id=tier0_id,
prefix_list_id=prefix_list_id,
name=name,
prefixes=prefixes,
tenant=TEST_TENANT)
update_call.assert_called_with(mock.ANY, partial_updates=False,
force=False)
self.assert_called_with_def(update_call, expected_def)
def test_build_prefix_entry(self):
network = "network_test"
le = mock.ANY

View File

@ -5170,14 +5170,16 @@ class NsxPolicyTier0PrefixListApi(NsxPolicyResourceBase):
prefixes,
description=IGNORE,
tags=IGNORE,
tenant=constants.POLICY_INFRA_TENANT):
tenant=constants.POLICY_INFRA_TENANT,
allow_partial_updates=True):
self._update(tier0_id=tier0_id,
prefix_list_id=prefix_list_id,
name=name,
prefixes=prefixes,
description=description,
tags=tags,
tenant=tenant)
tenant=tenant,
allow_partial_updates=allow_partial_updates)
def build_prefix_entry(self, network, le=None, ge=None,
action=constants.ADV_RULE_PERMIT):