summaryrefslogtreecommitdiffstats
path: root/zte
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-08-23 12:05:39 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-08-23 12:05:39 +0800
commit410e015f5181b9ee40a4bc5dfc9c308da933753a (patch)
tree43eaa8891ae8038b254e78a9f2601b1c3c9f70d7 /zte
parent0523050a87a5f0a1801c9cd9dcf8b67b5818b4e1 (diff)
Implement zte-driver vnf heal function
Add new vnf heal rest api and vnf heal code in zte vmanager driver. Change-Id: Iea3ea9dadaf8e69aaddb2b388a474091ca83530a Issue-ID: VFC-147 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'zte')
-rw-r--r--zte/vmanager/driver/interfaces/urls.py4
-rw-r--r--zte/vmanager/driver/interfaces/views.py38
2 files changed, 40 insertions, 2 deletions
diff --git a/zte/vmanager/driver/interfaces/urls.py b/zte/vmanager/driver/interfaces/urls.py
index e3f55bb9..fe70e460 100644
--- a/zte/vmanager/driver/interfaces/urls.py
+++ b/zte/vmanager/driver/interfaces/urls.py
@@ -31,6 +31,8 @@ urlpatterns = [
views.operation_status, name='operation_status'),
url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/resource/grant$', views.grantvnf, name='grantvnf'),
url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/vnfs/lifecyclechangesnotification$', views.notify, name='notify'),
- url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs/(?P<nfInstanceId>[0-9a-zA-Z\-\_]+)/scale$',
+ url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/scale$',
views.scale, name='scale'),
+ url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/heal$',
+ views.heal, name='heal'),
url(r'^samples/$', views.samples, name='samples'), ]
diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py
index ce625a35..ec0342d9 100644
--- a/zte/vmanager/driver/interfaces/views.py
+++ b/zte/vmanager/driver/interfaces/views.py
@@ -432,7 +432,7 @@ def scale(request, *args, **kwargs):
logger.info("request.data = %s", request.data)
logger.info("requested_url = %s", request.get_full_path())
vnfm_id = ignorcase_get(kwargs, "vnfmid")
- nf_instance_id = ignorcase_get(kwargs, "nfInstanceId")
+ nf_instance_id = ignorcase_get(kwargs, "vnfInstanceId")
ret = vnfm_get(vnfm_id)
if ret[0] != 0:
return Response(data={'error': ret[1]}, status=ret[2])
@@ -477,6 +477,42 @@ def scale(request, *args, **kwargs):
return Response(data={'error':'scale expection'}, status='500')
return Response(data=resp_data, status=ret[2])
+@api_view(http_method_names=['POST'])
+def heal(request, *args, **kwargs):
+ logger.info("====heal_vnf===")
+ try:
+ logger.info("request.data = %s", request.data)
+ logger.info("requested_url = %s", request.get_full_path())
+ vnfm_id = ignorcase_get(kwargs, "vnfmid")
+ nf_instance_id = ignorcase_get(kwargs, "vnfInstanceId")
+ ret = vnfm_get(vnfm_id)
+ if ret[0] != 0:
+ return Response(data={'error': ret[1]}, status=ret[2])
+ vnfm_info = json.JSONDecoder().decode(ret[1])
+ data = request.data
+ data['lifecycleoperation'] = 'operate'
+ data['isgrace'] = 'force'
+
+ logger.info("data = %s", data)
+ ret = restcall.call_req(
+ base_url=ignorcase_get(vnfm_info, "url"),
+ user=ignorcase_get(vnfm_info, "userName"),
+ passwd=ignorcase_get(vnfm_info, "password"),
+ auth_type=restcall.rest_no_auth,
+ resource=nf_scaling_url.format(vnfInstanceID=nf_instance_id),
+ method='put', # POST
+ content=json.JSONEncoder().encode(data))
+ logger.info("ret=%s", ret)
+ if ret[0] != 0:
+ return Response(data={'error': 'heal error'}, status=ret[2])
+ resp_data = json.JSONDecoder().decode(ret[1])
+ # jobId = resp_data["jobid"]
+ logger.info("resp_data=%s", resp_data)
+ except Exception as e:
+ logger.error("Error occurred when healing VNF")
+ logger.error(traceback.format_exc())
+ return Response(data={'error': 'heal expection'}, status='500')
+ return Response(data=resp_data, status=ret[2])
#@staticmethod
def get_vdus(nf_model, aspect_id):