diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-03-21 14:22:35 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-03-21 14:22:35 +0800 |
commit | dea465122f931f6b060e6acc22a4a50bb407e39d (patch) | |
tree | 152746ca4bce82370d3f450a278f954a994d3ec4 | |
parent | bc0cea0b0346d4e55eb3a070842096a35a826d83 (diff) |
Fix vfc-vnflcm unit tests grant response data
Change-Id: I401644a600a5afb0769bdc6c812d7ce2b8f51c60
Issue-ID: VFC-838
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/serializers.py | 2 | ||||
-rw-r--r-- | lcm/lcm/nf/tests/test_vnf_cancel.py | 8 | ||||
-rw-r--r-- | lcm/lcm/nf/tests/test_vnf_create.py | 8 | ||||
-rw-r--r-- | lcm/lcm/nf/vnf_create/inst_vnf.py | 12 |
4 files changed, 12 insertions, 18 deletions
diff --git a/lcm/lcm/nf/serializers.py b/lcm/lcm/nf/serializers.py index 2150c93b..98f68232 100644 --- a/lcm/lcm/nf/serializers.py +++ b/lcm/lcm/nf/serializers.py @@ -283,7 +283,7 @@ class instantiatedVnfInfoSerializer(serializers.Serializer): allow_null=True) vnfState = serializers.ChoiceField( help_text="vnfState", - choices=["STARTED", "STOPPED", "NOT_INSTANTIATED", "INSTANTIATED"], + choices=["STARTED", "STOPPED", "NOT_INSTANTIATED", "INSTANTIATED", "FAILED"], required=True, allow_null=True) scaleStatus = ScaleInfoSerializer( diff --git a/lcm/lcm/nf/tests/test_vnf_cancel.py b/lcm/lcm/nf/tests/test_vnf_cancel.py index 7e6c30f3..6e431e06 100644 --- a/lcm/lcm/nf/tests/test_vnf_cancel.py +++ b/lcm/lcm/nf/tests/test_vnf_cancel.py @@ -157,12 +157,8 @@ class TestNFTerminate(TestCase): create_time=now_time()) t1_apply_grant_result = [0, json.JSONEncoder().encode( { - "vim": { - "vimid": 'vimid_1', - "accessinfo": { - "tenant": 'tenantname_1' - } - } + "vimid": 'vimid_1', + "tenant": 'tenantname_1' }), '200'] t2_lcm_notify_result = [0, json.JSONEncoder().encode(''), '200'] mock_call_req.side_effect = [t1_apply_grant_result, t2_lcm_notify_result] diff --git a/lcm/lcm/nf/tests/test_vnf_create.py b/lcm/lcm/nf/tests/test_vnf_create.py index d1f02dce..5a017499 100644 --- a/lcm/lcm/nf/tests/test_vnf_create.py +++ b/lcm/lcm/nf/tests/test_vnf_create.py @@ -35,12 +35,8 @@ class TestNFInstantiate(TestCase): def setUp(self): self.client = APIClient() self.grant_result = { - "vim": { - "vimid": 'vimid_1', - "accessinfo": { - "tenant": 'tenantname_1' - } - } + "vimid": 'vimid_1', + "tenant": 'tenantname_1' } def tearDown(self): diff --git a/lcm/lcm/nf/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnf_create/inst_vnf.py index 5eb4f01e..f9d0c06a 100644 --- a/lcm/lcm/nf/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnf_create/inst_vnf.py @@ -101,10 +101,12 @@ class InstVnf(Thread): lastuptime=now_time()) logger.info("self.vim_id = %s" % self.vim_id) - NfvoRegInfoModel.objects.create( - nfvoid=self.nf_inst_id, - vnfminstid=ignore_case_get(self.data, "vnfmId"), - apiurl=self.vim_id) + is_exist = NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id).exists() + if not is_exist: + NfvoRegInfoModel.objects.create( + nfvoid=self.nf_inst_id, + vnfminstid=ignore_case_get(self.data, "vnfmId"), + apiurl=self.vim_id) JobUtil.add_job_status(self.job_id, 15, 'Nf instancing pre-check finish') logger.info("Nf instancing pre-check finish") @@ -243,7 +245,7 @@ class InstVnf(Thread): def vnf_inst_failed_handle(self, error_msg): logger.error('VNF instantiation failed, detail message: %s' % error_msg) - NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='failed', lastuptime=now_time()) + NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='FAILED', lastuptime=now_time()) JobUtil.add_job_status(self.job_id, 255, error_msg) def do_notify(self, res_type, ret): |