diff --git a/tackerclient/osc/v1/nfvo/ns.py b/tackerclient/osc/v1/nfvo/ns.py index 8440aa49..f58d1e33 100644 --- a/tackerclient/osc/v1/nfvo/ns.py +++ b/tackerclient/osc/v1/nfvo/ns.py @@ -156,18 +156,32 @@ class DeleteNS(command.Command): nargs="+", help=_("NS(s) to delete (name or ID)") ) + parser.add_argument( + '--force', + default=False, + action='store_true', + help=_('Force delete Network Service') + ) 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): client = self.app.client_manager.tackerclient failure = False deleted_ids = [] failed_items = {} + body = self.args2body(parsed_args) for resource_id in parsed_args.ns: try: obj = tackerV10.find_resourceid_by_name_or_id( client, _NS, resource_id) - client.delete_ns(obj) + client.delete_ns(obj, body) deleted_ids.append(resource_id) except Exception as e: failure = True diff --git a/tackerclient/tacker/v1_0/nfvo/ns.py b/tackerclient/tacker/v1_0/nfvo/ns.py index bed10331..6b167ffc 100644 --- a/tackerclient/tacker/v1_0/nfvo/ns.py +++ b/tackerclient/tacker/v1_0/nfvo/ns.py @@ -123,3 +123,17 @@ class DeleteNS(tackerV10.DeleteCommand): resource = _NS 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 diff --git a/tackerclient/v1_0/client.py b/tackerclient/v1_0/client.py index b8cc57fe..fbf13720 100644 --- a/tackerclient/v1_0/client.py +++ b/tackerclient/v1_0/client.py @@ -665,8 +665,8 @@ class Client(ClientBase): return self.post(self.nss_path, body=body) @APIParamsCall - def delete_ns(self, ns): - return self.delete(self.ns_path % ns) + def delete_ns(self, ns, body=None): + return self.delete(self.ns_path % ns, body=body) @APIParamsCall def create_cluster(self, body=None):