diff options
-rw-r--r-- | lcm/lcm/nf/vnfs/const.py | 2 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/tests/test_vnf_create.py | 46 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/views.py | 14 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py | 15 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_query/query_vnf.py | 13 |
5 files changed, 35 insertions, 55 deletions
diff --git a/lcm/lcm/nf/vnfs/const.py b/lcm/lcm/nf/vnfs/const.py index 1a0cb672..02edce7e 100644 --- a/lcm/lcm/nf/vnfs/const.py +++ b/lcm/lcm/nf/vnfs/const.py @@ -18,7 +18,6 @@ VNF_STATUS = enum(NULL='null', INSTANTIATING="instantiating", INACTIVE='inactive FAILED="failed", TERMINATING="terminating", SCALING="scaling", OPERATING="operating", UPDATING="updating", HEALING="healing") -# inst_req_data inst_req_data = { "flavourId": "flavour_1", "instantiationLevelId": "instantiationLevel_1", @@ -91,7 +90,6 @@ inst_req_data = { } } -# vnfd_model_dict vnfd_model_dict = { 'metadata': { 'vendor': u'zte', diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index 6613706b..3d3e9ad1 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -33,6 +33,14 @@ from lcm.pub.vimapi import api class TestNFInstantiate(TestCase): def setUp(self): self.client = Client() + self.grant_result = { + "vim": { + "vimid": 'vimid_1', + "accessinfo": { + "tenant": 'tenantname_1' + } + } + } def tearDown(self): pass @@ -111,16 +119,8 @@ class TestNFInstantiate(TestCase): vnfdid='111', create_time=now_time()) r1_get_vnfpackage_by_vnfdid = [0, json.JSONEncoder().encode(vnfpackage_info), '200'] - r3_apply_grant_result = [1, json.JSONEncoder().encode( - { - "vim": { - "vimid": 'vimid_1', - "accessinfo": { - "tenant": 'tenantname_1' - } - } - }), '200'] - mock_call_req.side_effect = [r1_get_vnfpackage_by_vnfdid, r3_apply_grant_result] + r2_apply_grant_result = [1, json.JSONEncoder().encode(self.grant_result), '200'] + mock_call_req.side_effect = [r1_get_vnfpackage_by_vnfdid, r2_apply_grant_result] self.nf_inst_id = '1111' self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id) JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY") @@ -143,16 +143,8 @@ class TestNFInstantiate(TestCase): vnfdid='111', create_time=now_time()) r1_get_vnfpackage_by_vnfdid = [0, json.JSONEncoder().encode(vnfpackage_info), '200'] - r3_apply_grant_result = [0, json.JSONEncoder().encode( - { - "vim": { - "vimid": 'vimid_1', - "accessinfo": { - "tenant": 'tenantname_1' - } - } - }), '200'] - mock_call_req.side_effect = [r1_get_vnfpackage_by_vnfdid, r3_apply_grant_result] + r2_apply_grant_result = [0, json.JSONEncoder().encode(self.grant_result), '200'] + mock_call_req.side_effect = [r1_get_vnfpackage_by_vnfdid, r2_apply_grant_result] mock_call.side_effect = [c1_data_get_tenant_id, c2_data_create_volume, c3_data_get_volume] self.nf_inst_id = '1111' self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id) @@ -176,17 +168,9 @@ class TestNFInstantiate(TestCase): vnfdid='111', create_time=now_time()) r1_get_vnfpackage_by_vnfdid = [0, json.JSONEncoder().encode(vnfpackage_info), '200'] - r3_apply_grant_result = [0, json.JSONEncoder().encode( - { - "vim": { - "vimid": 'vimid_1', - "accessinfo": { - "tenant": 'tenantname_1' - } - } - }), '200'] - r4_lcm_notify_result = [0, json.JSONEncoder().encode(''), '200'] - mock_call_req.side_effect = [r1_get_vnfpackage_by_vnfdid, r3_apply_grant_result, r4_lcm_notify_result] + r2_apply_grant_result = [0, json.JSONEncoder().encode(self.grant_result), '200'] + r3_lcm_notify_result = [0, json.JSONEncoder().encode(''), '200'] + mock_call_req.side_effect = [r1_get_vnfpackage_by_vnfdid, r2_apply_grant_result, r3_lcm_notify_result] mock_call.side_effect = [c1_data_get_tenant_id, c2_data_create_volume, c3_data_get_volume, c4_data_create_network, c5_data_create_subnet, c6_data_create_port, c7_data_create_flavor, c8_data_list_image, c9_data_create_vm, c10_data_get_vm] diff --git a/lcm/lcm/nf/vnfs/views.py b/lcm/lcm/nf/vnfs/views.py index 2330fa2c..495e782a 100644 --- a/lcm/lcm/nf/vnfs/views.py +++ b/lcm/lcm/nf/vnfs/views.py @@ -32,7 +32,7 @@ logger = logging.getLogger(__name__) class CreateVnfAndQueryVnfs(APIView): def get(self, request): - logger.debug("QuerySingleVnf--get::> %s" % request.data) + logger.debug("QueryMultiVnf--get::> %s" % request.data) try: resp_data = QueryVnf(request.data).query_multi_vnf() except NFLCMException as e: @@ -54,7 +54,9 @@ class CreateVnfAndQueryVnfs(APIView): except Exception: logger.error(traceback.format_exc()) return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - rsp = {"vnfInstanceId": nf_inst_id} + rsp = { + "vnfInstanceId": nf_inst_id + } return Response(data=rsp, status=status.HTTP_201_CREATED) @@ -71,7 +73,9 @@ class InstantiateVnf(APIView): except Exception: logger.error(traceback.format_exc()) return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - rsp = {"jobId": job_id} + rsp = { + "jobId": job_id + } return Response(data=rsp, status=status.HTTP_202_ACCEPTED) @@ -115,5 +119,7 @@ class TerminateVnf(APIView): except Exception: logger.error(traceback.format_exc()) return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - rsp = {"jobId": job_id} + rsp = { + "jobId": job_id + } return Response(data=rsp, status=status.HTTP_202_ACCEPTED) diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py index c8c85d2b..12df170b 100644 --- a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py @@ -40,13 +40,14 @@ class TermVnf(Thread): self.gracefulTerminationTimeout = ignore_case_get(self.data, "gracefulTerminationTimeout") self.apply_result = None self.notify_data = None - self.inst_resource = {'volumn': [], - 'network': [], - 'subnet': [], - 'port': [], - 'flavor': [], - 'vm': [], - } + self.inst_resource = { + 'volumn': [], + 'network': [], + 'subnet': [], + 'port': [], + 'flavor': [], + 'vm': [], + } def run(self): try: diff --git a/lcm/lcm/nf/vnfs/vnf_query/query_vnf.py b/lcm/lcm/nf/vnfs/vnf_query/query_vnf.py index 80e0d9b5..70727b10 100644 --- a/lcm/lcm/nf/vnfs/vnf_query/query_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_query/query_vnf.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import logging from lcm.pub.database.models import NfInstModel, StorageInstModel, VLInstModel, NetworkInstModel, VNFCInstModel, \ @@ -24,7 +25,6 @@ class QueryVnf: def __init__(self, data, instanceid=''): self.vnf_inst_id = instanceid self.data = data - pass def query_single_vnf(self): vnf_inst = NfInstModel.objects.filter(nfinstid=self.vnf_inst_id) @@ -120,15 +120,9 @@ class QueryVnf: resp_data = { "vnfInstanceId": vnf.nfinstid, "vnfInstanceName": vnf.nf_name, - # "vnfInstanceDescription": vnf.nf_desc, "onboardedVnfPkgInfoId": vnf.package_id, - # "vnfdId": vnf.vnfdid, "vnfdVersion": vnf.version, - # "vnfSoftwareVersion": vnf.vnfSoftwareVersion, "vnfProvider": vnf.vendor, - # "vnfProductName": vnf.producttype, - # "vnfConfigurableProperties": {vnf.vnfConfigurableProperties}, - # "instantiationState": vnf.status, "instantiatedVnfInfo": { "flavourId": vnf.flavour_id, "vnfState": vnf.status, @@ -136,13 +130,10 @@ class QueryVnf: "extCpInfo": [], "extVirtualLink": [], "monitoringParameters": {}, - # "localizationLanguage": vnf.localizationLanguage, "vimInfo": vm_arr, "vnfcResourceInfo": vnfc_arr, "virtualLinkResourceInfo": vl_arr, "virtualStorageResourceInfo": arr - }, - # "metadata": vnf.input_params, - # "extensions": vnf.extension + } } return resp_data |