summaryrefslogtreecommitdiffstats
path: root/zte
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-05-10 17:21:49 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-05-10 17:36:52 +0800
commitb49601d123e836b65361313bd8530bb5e51ccdc6 (patch)
tree6ec51ee5a7ff71b58e8568b1cf403e7241ee7455 /zte
parentf49c18fffa543805bc2f87792c0dbc17a914edd8 (diff)
Fix bugs for ztevnfmdriver
Change-Id: Idbe4f35159a842707518132c656f049d0fa3c256 Issue-ID: VFC-1306 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'zte')
-rw-r--r--zte/vmanager/driver/interfaces/tests.py1
-rw-r--r--zte/vmanager/driver/interfaces/views.py33
2 files changed, 8 insertions, 26 deletions
diff --git a/zte/vmanager/driver/interfaces/tests.py b/zte/vmanager/driver/interfaces/tests.py
index 2455e5aa..094e0daa 100644
--- a/zte/vmanager/driver/interfaces/tests.py
+++ b/zte/vmanager/driver/interfaces/tests.py
@@ -130,6 +130,7 @@ class InterfacesTest(TestCase):
r2 = [0, json.JSONEncoder().encode(vnfd_info), "200"]
r3 = [0, json.JSONEncoder().encode(packageInfo), "200"]
mock_call_req.side_effect = [r1, r2, r3, ret]
+ mock_call_req.side_effect = [r1, ret]
req_data = {
'vnfInstanceName': 'VFW_f88c0cb7-512a-44c4-bd09-891663f19367',
diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py
index 1421f877..15d03b3a 100644
--- a/zte/vmanager/driver/interfaces/views.py
+++ b/zte/vmanager/driver/interfaces/views.py
@@ -29,7 +29,6 @@ from driver.interfaces.serializers import HealReqSerializer, InstScaleHealRespSe
NotifyReqSerializer, GrantRespSerializer, GrantReqSerializer, JobQueryRespSerializer, TerminateVnfRequestSerializer, \
InstantiateVnfRequestSerializer, QueryVnfResponseSerializer, SubscribesRespSerializer, \
SubscribeReqSerializer, SubscribeRespSerializer, VnfPkgsSerializer, NfvoInfoReqSerializer
-from driver.pub.config.config import VNF_FTP
from driver.pub.utils import restcall
from driver.pub.utils.restcall import req_by_msb
@@ -122,36 +121,16 @@ class InstantiateVnf(APIView):
vnfm_info = json.JSONDecoder().decode(ret[1])
logger.debug("[%s] vnfm_info=%s", funname, vnfm_info)
- vnf_package_id = ignorcase_get(request.data, "vnfPackageId")
- ret = vnfd_get(vnf_package_id)
- if ret[0] != 0:
- raise Exception(ret[1])
-
- vnfd_info = json.JSONDecoder().decode(ret[1])
- logger.debug("[%s] vnfd_info=%s", funname, vnfd_info)
- csar_id = ignorcase_get(vnfd_info, "csarId")
- ret = vnfpackage_get(csar_id)
- if ret[0] != 0:
- raise Exception(ret[1])
-
- vnf_package_info = json.JSONDecoder().decode(ret[1])
- packageInfo = ignorcase_get(vnf_package_info, "packageInfo")
- logger.debug("[%s] packageInfo=%s", funname, packageInfo)
- logger.debug("VNF_FTP=%s", VNF_FTP)
data = {
"vnfinstancename": "V6000_VROUTER",
"NFVOID": "1",
"VNFMID": "1",
- "vnfd_id": packageInfo.get("vnfdId"),
+ "vnfd_id": "888552dbb6d502d8dd1e68a0fad212d8",
"deployflavorid": "default",
"extension": {},
"inputs": []
}
- additionalParam = ignorcase_get(instantiateVnfRequestSerializer.data, "additionalParam")
- for name, value in ignorcase_get(additionalParam, "inputs").items():
- data["inputs"].append({"key_name": name, "value": value, "type": "TODO"})
-
inputs_json = load_json_file("inputs.json")
[data["inputs"].append(item) for item in inputs_json["inputs"]]
@@ -178,14 +157,16 @@ class InstantiateVnf(APIView):
logger.debug("[%s]resp_data=%s", funname, resp_data)
instRespSerializer = InstScaleHealRespSerializer(data=resp_data)
if not instRespSerializer.is_valid():
- raise Exception(instRespSerializer.errors)
+ logger.warn("inst resp data is invalid")
- logger.debug("[%s] instRespSerializer.data=%s", funname, instRespSerializer.data)
- return Response(data=instRespSerializer.data, status=status.HTTP_200_OK)
+ return Response(data=resp_data, status=status.HTTP_200_OK)
except Exception as e:
logger.error("Error occurred when instantiating VNF,error:%s", e.message)
logger.error(traceback.format_exc())
- return Response(data={'error': 'InstantiateVnf expection'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ return Response(
+ data={'error': 'InstantiateVnf expection'},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR
+ )
class TerminateVnf(APIView):