From 0194671a341317b41162ce8f48f8112337c88b0c Mon Sep 17 00:00:00 2001 From: fujinhua Date: Thu, 21 Mar 2019 08:52:26 +0800 Subject: Add api adaptor for update nfvo info Change-Id: I4fe49c57b21cfb43ea2061b35d031d01160c4f73 Issue-ID: VFC-1307 Signed-off-by: fujinhua --- zte/vmanager/driver/interfaces/urls.py | 1 + zte/vmanager/driver/interfaces/views.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'zte/vmanager') diff --git a/zte/vmanager/driver/interfaces/urls.py b/zte/vmanager/driver/interfaces/urls.py index 82cc1ffd..9732cacd 100644 --- a/zte/vmanager/driver/interfaces/urls.py +++ b/zte/vmanager/driver/interfaces/urls.py @@ -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[0-9a-zA-Z\-\_]+)/(?P[0-9a-zA-Z\.\-\_]+)$', views.VnfPkg.as_view(), name='VnfPkg'), + url(r'^api/ztevnfmdriver/v1/(?P[0-9a-zA-Z\-\_]+)/nfvo/info$', views.NfvoInfo.as_view(), name='NfvoInfo'), url(r'^samples/$', views.SampleList.as_view(), name='samples') ] diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py index fd99a92d..54325b39 100644 --- a/zte/vmanager/driver/interfaces/views.py +++ b/zte/vmanager/driver/interfaces/views.py @@ -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.") -- cgit 1.2.3-korg