diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-12-11 11:14:40 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-12-11 11:14:40 +0800 |
commit | 74146bf9a2786ac9a9ca65c99e0589ceca42392d (patch) | |
tree | c1ac82b08b703886b341adddab1e073be8c472f2 | |
parent | 8b2347597891b82499e9ba9a12388df09d97c26d (diff) |
Optimize vfc-ztevnfmdriver notify Code
Change-Id: Ic2d22e4d88f65344e9fdd50b6ccff8e5c07ac892
Issue-ID: VFC-613
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | zte/vmanager/driver/interfaces/views.py | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py index ddc6c0d6..d4a98240 100644 --- a/zte/vmanager/driver/interfaces/views.py +++ b/zte/vmanager/driver/interfaces/views.py @@ -256,7 +256,6 @@ def operation_status(request, *args, **kwargs): def grantvnf(request, *args, **kwargs): logger.info("=====grantvnf=====") try: - resp_data = {} logger.info("req_data = %s", request.data) grant_vnf_param_map = { "VNFMID": "", @@ -296,8 +295,10 @@ def grantvnf(request, *args, **kwargs): if ret[0] != 0: return Response(data={'error': ret[1]}, status=ret[2]) resp = json.JSONDecoder().decode(ret[1]) - resp_data['vimid'] = ignorcase_get(resp['vim'], 'vimid') - resp_data['tenant'] = ignorcase_get(ignorcase_get(resp['vim'], 'accessinfo'), 'tenant') + resp_data = { + 'vimid': ignorcase_get(resp['vim'], 'vimid'), + 'tenant': ignorcase_get(ignorcase_get(resp['vim'], 'accessinfo'), 'tenant') + } logger.info("[%s]resp_data=%s", fun_name(), resp_data) except Exception as e: logger.error("Error occurred in Grant VNF.") @@ -305,27 +306,23 @@ def grantvnf(request, *args, **kwargs): return Response(data=resp_data, status=ret[2]) -# Notify LCM Events -notify_url = 'api/nslcm/v1/ns/{vnfmid}/vnfs/{vnfInstanceId}/Notify' -notify_param_map = { - "NFVOID": "", - "VNFMID": "VNFMID", - "VIMID": "vimid", - "VNFInstanceID": "vnfInstanceId", - "TimeStamp": "", - "EventType": "operation", - "VMList": "", - "VMFlavor": "", - "VMNumber": "", - "VMIDlist": "", - "VMUUID": "" -} - - @api_view(http_method_names=['POST']) def notify(request, *args, **kwargs): try: logger.info("[%s]req_data = %s", fun_name(), request.data) + notify_param_map = { + "NFVOID": "", + "VNFMID": "VNFMID", + "VIMID": "vimid", + "VNFInstanceID": "vnfInstanceId", + "TimeStamp": "", + "EventType": "operation", + "VMList": "", + "VMFlavor": "", + "VMNumber": "", + "VMIDlist": "", + "VMUUID": "" + } data = mapping_conv(notify_param_map, request.data) logger.info("[%s]data = %s", fun_name(), data) @@ -373,6 +370,7 @@ def notify(request, *args, **kwargs): for affectedcp in affectedcps: data["affectedCp"].append(affectedcp) + notify_url = 'api/nslcm/v1/ns/{vnfmid}/vnfs/{vnfInstanceId}/Notify' ret = req_by_msb(notify_url.format(vnfmid=ignorcase_get(data, 'VNFMID'), vnfInstanceId=ignorcase_get(data, 'vnfinstanceid')), "POST", content=json.JSONEncoder().encode(data)) |