summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-11 17:21:52 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-09-11 17:21:52 +0800
commitec2050493d4ce4c3ccfe69f569476af0cb37c5c8 (patch)
treee5c5212961bea640e4ad32982b3fcd854598436e
parent74886adbcaa969e6a717c6d822b0f8bec6e1fb15 (diff)
Add svnfm-driver query vnfm_info from nslcm
Change-Id: Ife0b60b101bf25aa02568d7e00da6ee57d3a4aeb Issue-ID: VFC-326 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--zte/vmanager/driver/interfaces/tests.py50
-rw-r--r--zte/vmanager/driver/interfaces/views.py22
2 files changed, 38 insertions, 34 deletions
diff --git a/zte/vmanager/driver/interfaces/tests.py b/zte/vmanager/driver/interfaces/tests.py
index cebc8c51..daacdb6a 100644
--- a/zte/vmanager/driver/interfaces/tests.py
+++ b/zte/vmanager/driver/interfaces/tests.py
@@ -27,9 +27,9 @@ class InterfacesTest(TestCase):
def tearDown(self):
pass
- @mock.patch.object(restcall, 'call_req_aai')
+ # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
- def test_instantiate_vnf_001(self, mock_call_req, mock_call_req_aai):
+ def test_instantiate_vnf_001(self, mock_call_req):
"""
Initate_VNF
"""
@@ -109,8 +109,8 @@ class InterfacesTest(TestCase):
r3 = [0, json.JSONEncoder().encode(packageInfo), "200"]
- mock_call_req_aai.side_effect =[r1]
- mock_call_req.side_effect = [r2, r3, ret]
+ # mock_call_req_aai.side_effect =[r1]
+ mock_call_req.side_effect = [r1, r2, r3, ret]
req_data = {'vnfInstanceName': 'VFW_f88c0cb7-512a-44c4-bd09-891663f19367',
'vnfPackageId': 'd852e1be-0aac-48f1-b1a4-cd825f6cdf9a',
@@ -131,9 +131,9 @@ class InterfacesTest(TestCase):
expect_resp_data = {"jobid": "NF-CREATE-8-b384535c-9f45-11e6-8749-fa163e91c2f9", "vnfInstanceId": "8"}
self.assertEqual(expect_resp_data, response.data)
- @mock.patch.object(restcall, 'call_req_aai')
+ # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
- def test_terminate_vnf__002(self, mock_call_req, mock_call_req_aai):
+ def test_terminate_vnf__002(self, mock_call_req):
"""
Terminate_VNF
"""
@@ -152,8 +152,8 @@ class InterfacesTest(TestCase):
"createTime": "2016-07-06 15:33:18"}), "200"]
r2 = [0, json.JSONEncoder().encode({"vnfInstanceId": "1", "JobId": "1"}), "200"]
- mock_call_req_aai.side_effect = [r1]
- mock_call_req.side_effect = [r2]
+ # mock_call_req_aai.side_effect = [r1]
+ mock_call_req.side_effect = [r1, r2]
response = self.client.post("/api/ztevmanagerdriver/v1/ztevnfmid/vnfs/vbras_innstance_id/terminate")
@@ -161,9 +161,9 @@ class InterfacesTest(TestCase):
expect_resp_data = {"jobid": "1", "vnfInstanceId": "1"}
self.assertEqual(expect_resp_data, response.data)
- @mock.patch.object(restcall, 'call_req_aai')
+ # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
- def test_query_vnf_003(self, mock_call_req, mock_call_req_aai):
+ def test_query_vnf_003(self, mock_call_req):
"""
Query_VNF
"""
@@ -182,8 +182,8 @@ class InterfacesTest(TestCase):
"createTime": "2016-07-06 15:33:18"}), "200"]
r2 = [0, json.JSONEncoder().encode({"vnfinstancestatus": "1"}), "200"]
- mock_call_req_aai.side_effect = [r1]
- mock_call_req.side_effect = [r2]
+ # mock_call_req_aai.side_effect = [r1]
+ mock_call_req.side_effect = [r1, r2]
response = self.client.get("/api/ztevmanagerdriver/v1/ztevnfmid/vnfs/vbras_innstance_id")
@@ -192,9 +192,9 @@ class InterfacesTest(TestCase):
expect_resp_data = {"vnfInfo": {"vnfStatus": "1"}}
self.assertEqual(expect_resp_data, response.data)
- @mock.patch.object(restcall, 'call_req_aai')
+ # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
- def test_operation_status_004(self, mock_call_req, mock_call_req_aai):
+ def test_operation_status_004(self, mock_call_req):
"""
Operation_status
"""
@@ -224,8 +224,8 @@ class InterfacesTest(TestCase):
"jobid": "NF-CREATE-11-ec6c2f2a-9f48-11e6-9405-fa163e91c2f9"}
r1 = [0, json.JSONEncoder().encode(vnfm_info), '200']
r2 = [0, json.JSONEncoder().encode(resp_body), '200']
- mock_call_req_aai.side_effect = [r1]
- mock_call_req.side_effect = [r2]
+ # mock_call_req_aai.side_effect = [r1]
+ mock_call_req.side_effect = [r1, r2]
response = self.client.get("/api/ztevmanagerdriver/v1/{vnfmid}/jobs/{jobid}?responseId={responseId}".
format(
vnfmid=vnfm_info["vnfmId"],
@@ -338,9 +338,9 @@ class InterfacesTest(TestCase):
expect_resp_data = None
self.assertEqual(expect_resp_data, response.data)
- @mock.patch.object(restcall, 'call_req_aai')
+ # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
- def test_scale(self, mock_call_req, mock_call_req_aai):
+ def test_scale(self, mock_call_req):
job_info = {"jobid":"801","nfInstanceId":"101"}
vnfm_info = {u'userName': u'admin',
u'vendor': u'ZTE',
@@ -357,8 +357,8 @@ class InterfacesTest(TestCase):
ret = [0, json.JSONEncoder().encode(job_info), "202"]
ret_vnfm = [0,json.JSONEncoder().encode(vnfm_info), "200"]
- mock_call_req_aai.side_effect = [ret_vnfm]
- mock_call_req.side_effect = [ret]
+ # mock_call_req_aai.side_effect = [ret_vnfm]
+ mock_call_req.side_effect = [ret_vnfm, ret]
vnfd_info = {
"vnf_flavours":[
@@ -416,9 +416,9 @@ class InterfacesTest(TestCase):
self.assertEqual(str(status.HTTP_202_ACCEPTED), response.status_code)
self.assertDictEqual(job_info, response.data)
- @mock.patch.object(restcall, 'call_req_aai')
+ # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
- def test_heal(self, mock_call_req, mock_call_req_aai):
+ def test_heal(self, mock_call_req):
job_info = {"jobid": "12234455", "nfInstanceId": "10144445666"}
vnfm_info = {u'userName': u'admin',
u'vendor': u'ZTE',
@@ -435,8 +435,8 @@ class InterfacesTest(TestCase):
ret = [0, json.JSONEncoder().encode(job_info), "202"]
ret_vnfm = [0, json.JSONEncoder().encode(vnfm_info), "200"]
- mock_call_req_aai.side_effect = [ret_vnfm]
- mock_call_req.side_effect = [ret]
+ # mock_call_req_aai.side_effect = [ret_vnfm]
+ mock_call_req.side_effect = [ret_vnfm, ret]
heal_vnf_data = {
'action': 'vmReset',
@@ -458,4 +458,4 @@ class InterfacesTest(TestCase):
data=json.dumps(heal_vnf_data), content_type='application/json')
self.assertEqual(str(status.HTTP_202_ACCEPTED), response.status_code)
- self.assertDictEqual(job_info, response.data) \ No newline at end of file
+ self.assertDictEqual(job_info, response.data)
diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py
index dc94f838..3f4a4baf 100644
--- a/zte/vmanager/driver/interfaces/views.py
+++ b/zte/vmanager/driver/interfaces/views.py
@@ -55,18 +55,22 @@ query_vnfd_url = "api/nslcm/v1/vnfpackage/%s"
query_vnfm_url = "api/extsys/v1/vnfms/%s"
query_package_url = "api/nslcm/v1/vnfpackage/%s"
+#Query vnfm_info from nslcm
+def get_vnfminfo_from_nslcm(vnfmid):
+ ret = req_by_msb("api/nslcm/v1/vnfms/%s" % vnfmid, "GET")
+ return ret
-# Query VNFM by VNFMID
+# Query vnfm_info from esr
def vnfm_get(vnfmid):
ret = call_aai("api/aai-esr-server/v1/vnfms/%s" % vnfmid, "GET")
return ret
-
+# Query vnfd_info from nslcm
def vnfd_get(vnfpackageid):
ret = req_by_msb("api/nslcm/v1/vnfpackage/%s" % vnfpackageid, "GET")
return ret
-
+# Query vnfpackage_info from nslcm
def vnfpackage_get(csarid):
ret = req_by_msb("api/nslcm/v1/vnfpackage/%s" % csarid, "GET")
return ret
@@ -95,7 +99,7 @@ def instantiate_vnf(request, *args, **kwargs):
try:
logger.debug("[%s] request.data=%s", fun_name(), request.data)
vnfm_id = ignorcase_get(kwargs, "vnfmid")
- ret = vnfm_get(vnfm_id)
+ ret = get_vnfminfo_from_nslcm(vnfm_id)
if ret[0] != 0:
return Response(data={'error': ret[1]}, status=ret[2])
vnfm_info = json.JSONDecoder().decode(ret[1])
@@ -179,7 +183,7 @@ def terminate_vnf(request, *args, **kwargs):
try:
logger.debug("[%s] request.data=%s", fun_name(), request.data)
vnfm_id = ignorcase_get(kwargs, "vnfmid")
- ret = vnfm_get(vnfm_id)
+ ret = get_vnfminfo_from_nslcm(vnfm_id)
if ret[0] != 0:
return Response(data={'error': ret[1]}, status=ret[2])
vnfm_info = json.JSONDecoder().decode(ret[1])
@@ -218,7 +222,7 @@ def query_vnf(request, *args, **kwargs):
try:
logger.debug("[%s] request.data=%s", fun_name(), request.data)
vnfm_id = ignorcase_get(kwargs, "vnfmid")
- ret = vnfm_get(vnfm_id)
+ ret = get_vnfminfo_from_nslcm(vnfm_id)
if ret[0] != 0:
return Response(data={'error': ret[1]}, status=ret[2])
vnfm_info = json.JSONDecoder().decode(ret[1])
@@ -263,7 +267,7 @@ def operation_status(request, *args, **kwargs):
try:
logger.debug("[%s] request.data=%s", fun_name(), request.data)
vnfm_id = ignorcase_get(kwargs, "vnfmid")
- ret = vnfm_get(vnfm_id)
+ ret = get_vnfminfo_from_nslcm(vnfm_id)
if ret[0] != 0:
return Response(data={'error': ret[1]}, status=ret[2])
vnfm_info = json.JSONDecoder().decode(ret[1])
@@ -436,7 +440,7 @@ def scale(request, *args, **kwargs):
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)
+ ret = get_vnfminfo_from_nslcm(vnfm_id)
if ret[0] != 0:
return Response(data={'error': ret[1]}, status=ret[2])
vnfm_info = json.JSONDecoder().decode(ret[1])
@@ -491,7 +495,7 @@ def heal(request, *args, **kwargs):
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)
+ ret = get_vnfminfo_from_nslcm(vnfm_id)
if ret[0] != 0:
return Response(data={'error': ret[1]}, status=ret[2])
vnfm_info = json.JSONDecoder().decode(ret[1])