Add support to force delete routers
By default, routers are being deleted without the force option set, which will fail if there are ports on routers. Adding support to force delete routers can save us from API roundtrips when we want to clean stale resources. Change-Id: Ifff9914ead88a671ac1588269016043176f93a67
This commit is contained in:
parent
5d3a7a113a
commit
f48e0e0c4f
|
@ -458,6 +458,15 @@ class LogicalRouterTestCase(nsxlib_testcase.NsxClientTestCase):
|
||||||
'delete', router,
|
'delete', router,
|
||||||
'https://1.2.3.4/api/v1/logical-routers/%s' % uuid)
|
'https://1.2.3.4/api/v1/logical-routers/%s' % uuid)
|
||||||
|
|
||||||
|
def test_force_delete_logical_router(self):
|
||||||
|
"""Test force deleting router"""
|
||||||
|
router = self._mocked_lrouter()
|
||||||
|
uuid = test_constants.FAKE_ROUTER['id']
|
||||||
|
router.delete(uuid, True)
|
||||||
|
test_client.assert_json_call(
|
||||||
|
'delete', router,
|
||||||
|
'https://1.2.3.4/api/v1/logical-routers/%s?force=True' % uuid)
|
||||||
|
|
||||||
|
|
||||||
class LogicalRouterPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
class LogicalRouterPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
||||||
|
|
||||||
|
|
|
@ -368,8 +368,11 @@ class LogicalRouter(AbstractRESTResource):
|
||||||
body['description'] = description
|
body['description'] = description
|
||||||
return self._client.create(body=body)
|
return self._client.create(body=body)
|
||||||
|
|
||||||
def delete(self, lrouter_id):
|
def delete(self, lrouter_id, force=False):
|
||||||
return self._client.url_delete(lrouter_id)
|
url = lrouter_id
|
||||||
|
if force:
|
||||||
|
url += '?force=%s' % force
|
||||||
|
return self._client.url_delete(url)
|
||||||
|
|
||||||
def update(self, lrouter_id, *args, **kwargs):
|
def update(self, lrouter_id, *args, **kwargs):
|
||||||
# Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
|
|
Loading…
Reference in New Issue