Adds support force delete for NS.
This patch adds '--force' parameter to NS delete command, to delete NS forcefully. blueprint force-delete-resources Change-Id: I7d8eb7ae63f9e43da37701e3e8312e650ea5bd3c
This commit is contained in:
parent
47996394b3
commit
1e280fb1fe
@ -156,18 +156,32 @@ class DeleteNS(command.Command):
|
|||||||
nargs="+",
|
nargs="+",
|
||||||
help=_("NS(s) to delete (name or ID)")
|
help=_("NS(s) to delete (name or ID)")
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--force',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help=_('Force delete Network Service')
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
def args2body(self, parsed_args):
|
||||||
|
if parsed_args.force:
|
||||||
|
body = {_NS: {'attributes': {'force': True}}}
|
||||||
|
else:
|
||||||
|
body = dict()
|
||||||
|
return body
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.tackerclient
|
client = self.app.client_manager.tackerclient
|
||||||
failure = False
|
failure = False
|
||||||
deleted_ids = []
|
deleted_ids = []
|
||||||
failed_items = {}
|
failed_items = {}
|
||||||
|
body = self.args2body(parsed_args)
|
||||||
for resource_id in parsed_args.ns:
|
for resource_id in parsed_args.ns:
|
||||||
try:
|
try:
|
||||||
obj = tackerV10.find_resourceid_by_name_or_id(
|
obj = tackerV10.find_resourceid_by_name_or_id(
|
||||||
client, _NS, resource_id)
|
client, _NS, resource_id)
|
||||||
client.delete_ns(obj)
|
client.delete_ns(obj, body)
|
||||||
deleted_ids.append(resource_id)
|
deleted_ids.append(resource_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
failure = True
|
failure = True
|
||||||
|
@ -123,3 +123,17 @@ class DeleteNS(tackerV10.DeleteCommand):
|
|||||||
|
|
||||||
resource = _NS
|
resource = _NS
|
||||||
deleted_msg = {'ns': 'delete initiated'}
|
deleted_msg = {'ns': 'delete initiated'}
|
||||||
|
|
||||||
|
def add_known_arguments(self, parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--force',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help=_('Force delete Network Service'))
|
||||||
|
|
||||||
|
def args2body(self, parsed_args):
|
||||||
|
if parsed_args.force:
|
||||||
|
body = {self.resource: {'attributes': {'force': True}}}
|
||||||
|
else:
|
||||||
|
body = dict()
|
||||||
|
return body
|
||||||
|
@ -665,8 +665,8 @@ class Client(ClientBase):
|
|||||||
return self.post(self.nss_path, body=body)
|
return self.post(self.nss_path, body=body)
|
||||||
|
|
||||||
@APIParamsCall
|
@APIParamsCall
|
||||||
def delete_ns(self, ns):
|
def delete_ns(self, ns, body=None):
|
||||||
return self.delete(self.ns_path % ns)
|
return self.delete(self.ns_path % ns, body=body)
|
||||||
|
|
||||||
@APIParamsCall
|
@APIParamsCall
|
||||||
def create_cluster(self, body=None):
|
def create_cluster(self, body=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user