Add feature to update NSGroup and FirewallSection tags

update NsxLibNsGroup.update and NsxLibFirewallSection.update
to support tag update

Change-Id: I85acdd297d2c9295091890e8ef17c878ce0c7807
This commit is contained in:
lyliu
2017-09-12 07:47:04 +00:00
parent 199bf788e4
commit 597c4b8321
2 changed files with 26 additions and 2 deletions

View File

@@ -92,6 +92,17 @@ class TestNsxLibFirewallSection(nsxlib_testcase.NsxLibTestCase):
self.nsxlib.firewall_section.get_excludelist()
clist.assert_called_with('firewall/excludelist')
def test_update(self):
fws_tags = [{"scope": "name", "tag": "new_name"}]
with mock.patch.object(self.nsxlib.client, 'update') as update:
with mock.patch.object(self.nsxlib.client, 'get') as get:
get.return_value = {}
self.nsxlib.firewall_section.update('fw_section_id',
tags_update=fws_tags)
resource = 'firewall/sections/%s' % 'fw_section_id'
data = {'tags': fws_tags}
update.assert_called_with(resource, data, headers=None)
class TestNsxLibIPSet(nsxlib_testcase.NsxClientTestCase):
"""Tests for vmware_nsxlib.v3.security.NsxLibIPSet"""
@@ -174,3 +185,13 @@ class TestNsxLibNSGroup(nsxlib_testcase.NsxClientTestCase):
expected_exp = {'resource_type': const.NSGROUP_COMPLEX_EXP,
'expressions': port_exp}
self.assertEqual(expected_exp, complex_exp)
def test_update(self):
nsg_tags = [{"scope": "name", "tag": "new_name"}]
with mock.patch.object(self.nsxlib.client, 'update') as update:
with mock.patch.object(self.nsxlib.client, 'get') as get:
get.return_value = {}
self.nsxlib.ns_group.update('nsgroupid', tags_update=nsg_tags)
resource = 'ns-groups/nsgroupid'
data = {'tags': nsg_tags}
update.assert_called_with(resource, data)