Add api adaptor for update nfvo info 73/82873/2
authorfujinhua <fu.jinhua@zte.com.cn>
Thu, 21 Mar 2019 00:52:26 +0000 (08:52 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Thu, 21 Mar 2019 02:13:25 +0000 (10:13 +0800)
Change-Id: I4fe49c57b21cfb43ea2061b35d031d01160c4f73
Issue-ID: VFC-1307
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
zte/vmanager/driver/interfaces/urls.py
zte/vmanager/driver/interfaces/views.py

index 82cc1ff..9732cac 100644 (file)
@@ -36,5 +36,6 @@ urlpatterns = [
     url(r'^api/ztevnfmdriver/v1/subscribe$', views.Subscribe.as_view(), name='subscribe'),
     url(r'^api/ztevnfmdriver/v1/vnfpkgs$', views.VnfPkgs.as_view(), name='VnfPkgs'),
     url(r'^api/ztevnfmdriver/v1/vnfpkgs/(?P<packageId>[0-9a-zA-Z\-\_]+)/(?P<fileName>[0-9a-zA-Z\.\-\_]+)$', views.VnfPkg.as_view(), name='VnfPkg'),
+    url(r'^api/ztevnfmdriver/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/nfvo/info$', views.NfvoInfo.as_view(), name='NfvoInfo'),
     url(r'^samples/$', views.SampleList.as_view(), name='samples')
 ]
index fd99a92..54325b3 100644 (file)
@@ -681,3 +681,30 @@ class VnfPkg(APIView):
         start, end = parse_file_range(local_file_path, file_range)
         file_iterator = read(local_file_path, start, end)
         return StreamingHttpResponse(file_iterator, status=status.HTTP_200_OK)
+
+
+class NfvoInfo(APIView):
+    def put(self, request, vnfmid):
+        logger.debug("====NfvoInfo put====%s", vnfmid)
+        req_data = {
+            "nfvoid": request.data.get("nfvoid", "1"),
+            "vnfmid": vnfmid,
+            "nfvourl": request.data.get("nfvourl", "http://127.0.0.1:80")
+        }
+        ret = get_vnfminfo_from_nslcm(vnfmid)
+        if ret[0] != 0:
+            raise Exception(ret[1])
+
+        vnfm_info = json.JSONDecoder().decode(ret[1])
+        logger.debug("[%s] vnfm_info=%s", fun_name(), vnfm_info)
+        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="v1/nfvo/info",
+            method='put',
+            content=json.dumps(req_data))
+        if ret[0] != 0:
+            raise Exception(ret[1])
+        logger.debug("update nfvo info successfully.")