summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2017-02-13 14:34:34 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2017-02-13 14:34:34 +0800
commitff91a2c9b86619f2dfbceb57b8b86c0e6c9fd0db (patch)
tree6ce54fca63961f96c5d4050c6f271315cffbe915
parent4d3423b383961703116d363094d9abf51d078ac9 (diff)
Add delete resource adaptor of vimdriver
Change-Id: Iefd9416896c5de156186554c0066bee4d5732c68 Issue-Id: GVNFM-30 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/lcm/pub/vimapi/adaptor.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py
index 33358623..f7ffc1fc 100644
--- a/lcm/lcm/pub/vimapi/adaptor.py
+++ b/lcm/lcm/pub/vimapi/adaptor.py
@@ -61,6 +61,20 @@ def create_vim_res(data, do_notify, do_rollback):
logger.error(traceback.format_exc())
do_rollback(str(sys.exc_info()))
+def delete_vim_res(data, do_notify):
+ def ignore_exception_call(fun, *args):
+ try:
+ fun(*args)
+ except VimException as e:
+ logger.error(e.message)
+ res_types = ["vm", "flavor", "port", "subnet", "network", "volume"]
+ res_del_funs = [api.delete_vm, api.delete_flavor, api.delete_port,
+ api.delete_subnet, api.delete_network, api.delete_volume]
+ for res_type, res_del_fun in zip(res_types, res_del_funs):
+ for res in ignore_case_get(data, res_type):
+ ignore_exception_call(res_del_fun, res["vim_id"], res["res_id"])
+ do_notify(res_type)
+
def create_volume(vol, do_notify, progress):
param = {
"tenant": vol["properties"]["location_info"]["tenant"],