diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-02-20 13:46:39 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-02-20 13:46:39 +0800 |
commit | c3cedf44ee2dbe7af49515bb12932c02a90d8f5d (patch) | |
tree | 1c223400f89f76a98ee9be295177178c5bb7e930 | |
parent | 951cbddb0318c77a755eecf2b19d6f7f176c7523 (diff) |
Modify test case of create vnf identifier
Change-Id: Iea29b990c1120e87d139564e09c42ceb5ff36372
Issue-Id: GVNFM-34
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/vnfs/tests/test_vnf_create.py | 15 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py | 14 |
2 files changed, 21 insertions, 8 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index 903c6a3d..9243b3ea 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -100,6 +100,21 @@ class TestNFInstantiate(TestCase): InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run() self.assert_job_result(self.job_id, 255, "Failed to query package_info of vnfdid(111) from nslcm.") + @mock.patch.object(restcall, 'call_req') + def test_instantiate_vnf_when_get_rawdata_by_csarid_failed(self, mock_call_req): + NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='todo', + version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED', + nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time()) + r1 = [0, json.JSONEncoder().encode({'package_id':'222', 'csar_id':'2222'}), '200'] # get csar_id from nslcm by vnfd_id + r2 = [1, json.JSONEncoder().encode(''), '200'] + mock_call_req.side_effect = [r1, r2] + 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") + data = inst_req_data + InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run() + self.assert_job_result(self.job_id, 255, "Failed to query rawdata of CSAR(2222) from catalog.") + # @mock.patch.object(restcall, 'call_req') # def test_instantiate_vnf_when_input_para_not_define_in_vnfd(self, mock_call_req): # r1 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200'] diff --git a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py index 4e4656a6..88738216 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py @@ -32,6 +32,9 @@ class CreateVnf: self.vnfd_id = ignore_case_get(self.data, "vnfdId") self.vnf_instance_mame = ignore_case_get(self.data, "vnfInstanceName") self.description = ignore_case_get(self.data, "vnfInstanceDescription") + self.package_info = '' + self.package_id = '' + self.csar_id = '' def do_biz(self): logger.debug("CreateVnfIdentifier--CreateVnf::> %s" % self.data) @@ -40,17 +43,12 @@ class CreateVnf: if is_exist: raise NFLCMException('VNF is already exist.') - # ret = vnfd_rawdata_get(self.vnfd_id) - # if ret[0] != 0: - # raise NFLCMException('Get vnfd data failed.') - # vnfd_info = json.JSONDecoder().decode(ret[1]) - - # get csar_id from nslcm by vnfd_id + # get package_info from nslcm by vnfd_id self.package_info = get_packageinfo_by_vnfdid(self.vnfd_id) self.package_id = ignore_case_get(self.package_info, "package_id") self.csar_id = ignore_case_get(self.package_info, "csar_id") - #get rawdata from catalog by csar_id + # get rawdata from catalog by csar_id raw_data = query_rawdata_from_catalog(self.csar_id, self.data) # self.vnfd = toscautil.convert_vnfd_model(raw_data["rawData"]) # convert to inner json # self.vnfd = json.JSONDecoder().decode(self.vnfd) @@ -64,7 +62,7 @@ class CreateVnf: vnfd_model = vnfd_info nf_inst_id = str(uuid.uuid4()) - NfInstModel.objects.create(nfinstid=nf_inst_id, nf_name=self.vnf_instance_mame, package_id='todo', + NfInstModel.objects.create(nfinstid=nf_inst_id, nf_name=self.vnf_instance_mame, package_id=self.package_id, version=version, vendor=vendor, netype=netype, vnfd_model=vnfd_model, status='NOT_INSTANTIATED', nf_desc=self.description, vnfdid=self.vnfd_id, vnfSoftwareVersion=vnfsoftwareversion, create_time=now_time()) |