from lcm.nf.vnfs.vnf_cancel.term_vnf import TermVnf
from lcm.pub.database.models import NfInstModel, JobStatusModel, VmInstModel, NetworkInstModel, SubNetworkInstModel, \
- PortInstModel, FlavourInstModel, StorageInstModel
+ PortInstModel, FlavourInstModel, StorageInstModel, NfvoRegInfoModel
from lcm.pub.utils import restcall
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.utils.timeutil import now_time
FlavourInstModel.objects.create(flavourid="1", vimid="1", resouceid="11", instid="1111", is_predefined=1)
VmInstModel.objects.create(vmid="1", vimid="1", resouceid="11", insttype=0, instid="1111", vmname="test_01",
is_predefined=1, operationalstate=1)
+ NfvoRegInfoModel.objects.create(nfvoid='1111', vnfminstid='11111', apiurl='1')
def tearDown(self):
VmInstModel.objects.all().delete()
progress=job_progress,
descp=job_detail)
self.assertEqual(1, len(jobs))
- """
+
def test_delete_vnf_identifier(self):
NfInstModel.objects.create(nfinstid='1111', nf_name='2222', package_id='todo', version='', vendor='',
netype='', vnfd_model='', status='NOT_INSTANTIATED', nf_desc='', vnfdid='',
self.failUnlessEqual(status.HTTP_204_NO_CONTENT, response.status_code)
self.assertEqual(None, response.data)
+ """
def test_delete_vnf_identifier_when_vnf_not_exist(self):
response = self.client.delete("/openoapi/vnflcm/v1/vnf_instances/1111")
self.failUnlessEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
response = self.client.delete("/openoapi/vnflcm/v1/vnf_instances/1111")
self.failUnlessEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
self.assertEqual("Don't allow to delete vnf(status:[VNF_INSTANTIATED])", response.data["error"])
+ """
@mock.patch.object(TermVnf, 'run')
def test_terminate_vnf(self, mock_run):
response = self.client.post("/openoapi/vnflcm/v1/vnf_instances/12/terminate", data={}, format='json')
self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
+ """
def test_terminate_vnf_when_inst_id_not_exist(self):
data = {"terminationType": "GRACEFUL",
"gracefulTerminationTimeout": 120}
JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
TermVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 255, "VnfInst(%s) does not exist" % self.nf_inst_id)
+ """
@mock.patch.object(restcall, 'call_req')
@mock.patch.object(api, 'call')
JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
TermVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 100, "Terminate Vnf success.")
- """
+
def test_swagger_ok(self):
response = self.client.get("/openoapi/vnflcm/v1/swagger.json", format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
-'''
+
@mock.patch.object(restcall, 'call_req')
def test_create_vnf_identifier(self, mock_call_req):
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode({'csars':[{'package_id': '222',
'csarId': '2222',
- 'vnfdId': '111'}]), '200']
+ 'vnfdId': '111'}]}), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid, r2_get_rawdata_from_catalog]
data = {
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())
- r1_get_csarid_by_vnfdid = [1, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ r1_get_csarid_by_vnfdid = [1, json.JSONEncoder().encode({'csars':[{'package_id': '222',
+ 'csarId': '2222',
+ 'vnfdId': '111'}]}), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid]
self.nf_inst_id = '1111'
self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
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())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode({'csars':[{'package_id': '222',
+ 'csarId': '2222',
+ 'vnfdId': '111'}]}), '200']
r2_get_rawdata_from_catalog = [1, json.JSONEncoder().encode(vnfd_rawdata), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid, r2_get_rawdata_from_catalog]
self.nf_inst_id = '1111'
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())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode({'csars':[{'package_id': '222',
+ 'csarId': '2222',
+ 'vnfdId': '111'}]}), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
r3_apply_grant_result = [1, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
@mock.patch.object(restcall, 'call_req')
@mock.patch.object(api, 'call')
- def test_instantiate_vnf_when_(self, mock_call, mock_call_req):
+ def test_instantiate_vnf_when_unexpected_exception(self, mock_call, mock_call_req):
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())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode({'csars':[{'package_id': '222',
+ 'csarId': '2222',
+ 'vnfdId': '111'}]}), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
r3_apply_grant_result = [0, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
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())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode({'csars':[{'package_id': '222',
+ 'csarId': '2222',
+ 'vnfdId': '111'}]}), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
r3_apply_grant_result = [0, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
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, 100, "Instantiate Vnf success.")
-'''
\ No newline at end of file