New API for deleting IP pool forcefully

Change-Id: If54a5161ee94c0bbcc629380466857b11a2d6b84
This commit is contained in:
Qian Sun 2018-08-27 01:19:34 -07:00
parent abc0bec54e
commit c2e149af3e
2 changed files with 26 additions and 0 deletions

View File

@ -1207,6 +1207,26 @@ class IpPoolTestCase(BaseTestResource):
else:
self.fail("shouldn't happen")
def test_delete_ip_pool(self):
fake_ip_pool = test_constants.FAKE_IP_POOL.copy()
pool = self.get_mocked_resource(response=fake_ip_pool)
uuid = fake_ip_pool['id']
pool.delete(uuid)
test_client.assert_json_call(
'delete', pool,
'https://1.2.3.4/api/v1/pools/ip-pools/%s' % uuid,
headers=self.default_headers())
def test_force_delete_ip_pool(self):
fake_ip_pool = test_constants.FAKE_IP_POOL.copy()
pool = self.get_mocked_resource(response=fake_ip_pool)
uuid = fake_ip_pool['id']
pool.delete(uuid, force=True)
test_client.assert_json_call(
'delete', pool,
'https://1.2.3.4/api/v1/pools/ip-pools/%s?force=True' % uuid,
headers=self.default_headers())
def test_update_ip_pool_name(self):
fake_ip_pool = test_constants.FAKE_IP_POOL.copy()
pool = self.get_mocked_resource(response=fake_ip_pool)

View File

@ -569,6 +569,12 @@ class IpPool(utils.NsxLibApiBase):
return self.client.create(self.get_path(), body=body)
def delete(self, pool_id, force=False):
url = pool_id
if force:
url += '?force=%s' % force
return self.client.delete(self.get_path(url))
def _update_param_in_pool(self, args_dict, key, pool_data):
# update the arg only if it exists in the args dictionary
if key in args_dict: