summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_create.py22
-rw-r--r--lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py1
2 files changed, 23 insertions, 0 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
index 3d3e9ad1..7965072d 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
@@ -51,6 +51,28 @@ class TestNFInstantiate(TestCase):
descp=job_detail)
self.assertEqual(1, len(jobs))
+ def test_create_vnf_identifier_when_vnf_is_exist(self):
+ NfInstModel.objects.create(nfinstid='1111',
+ nf_name='vFW_01',
+ package_id='222',
+ version='',
+ vendor='',
+ netype='',
+ vnfd_model='',
+ status='NOT_INSTANTIATED',
+ nf_desc='vFW in Nanjing TIC Edge',
+ vnfdid='111',
+ create_time=now_time())
+ data = {
+ "vnfdId": "111",
+ "vnfInstanceName": "vFW_01",
+ "vnfInstanceDescription": "vFW in Nanjing TIC Edge"
+ }
+ response = self.client.post("/api/vnflcm/v1/vnf_instances", data=data, format='json')
+ self.failUnlessEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
+ context = json.loads(response.content)
+ self.assertEqual({'error': 'VNF is already exist.'}, context)
+
@mock.patch.object(restcall, 'call_req')
def test_create_vnf_identifier(self, mock_call_req):
r2_get_vnfpackage_from_catalog = [0, json.JSONEncoder().encode(vnfpackage_info), '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 9d6e2cdf..593248dd 100644
--- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py
+++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py
@@ -40,6 +40,7 @@ class CreateVnf:
self.save_db()
except NFLCMException as e:
logger.debug('Create VNF instance[%s]: %s', self.nf_inst_id, e.message)
+ raise NFLCMException(e.message)
except:
NfInstModel.objects.create(nfinstid=self.nf_inst_id,
nf_name=self.vnf_instance_mame,