X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=lcm%2Flcm%2Fnf%2Fvnfs%2Fvnf_create%2Finst_vnf.py;h=9b6babb248ec944a77c1a0d38a24aee94fbe69f9;hb=6e9aade702be97ec1ff2fa5328feb18cddd0427a;hp=a34ad8f37956ac293b1901638277dbc37044332f;hpb=583f46a5118119384c23a0104b21698f80691a4a;p=vfc%2Fgvnfm%2Fvnflcm.git diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py index a34ad8f3..9b6babb2 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -11,13 +11,13 @@ # 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 json import logging import traceback import uuid from threading import Thread -from lcm.nf.vnfs.const import vnfd_model_dict from lcm.pub.database.models import NfInstModel, VmInstModel, NetworkInstModel, \ SubNetworkInstModel, PortInstModel, StorageInstModel, FlavourInstModel, VNFCInstModel, NfvoRegInfoModel from lcm.pub.exceptions import NFLCMException @@ -87,7 +87,7 @@ class InstVnf(Thread): self.vnfd_info = toscautil.convert_vnfd_model(raw_data["rawData"]) # convert to inner json self.vnfd_info = json.JSONDecoder().decode(self.vnfd_info) - #self.vnfd_info = vnfd_model_dict # just for test + # self.vnfd_info = vnfd_model_dict # just for test self.update_cps() self.check_parameter_exist() @@ -98,14 +98,24 @@ class InstVnf(Thread): vnfsoftwareversion = ignore_case_get(metadata, "version") vnfd_model = self.vnfd_info NfInstModel.objects.filter(nfinstid=self.nf_inst_id).\ - update(package_id=self.package_id, flavour_id=ignore_case_get(self.data, "flavourId"), version=version, - vendor=vendor, netype=netype, vnfd_model=vnfd_model, status='NOT_INSTANTIATED', vnfdid=self.vnfd_id, - localizationLanguage=ignore_case_get(self.data, 'localizationLanguage'), input_params=self.data, - vnfSoftwareVersion=vnfsoftwareversion, lastuptime=now_time()) + update(package_id=self.package_id, + flavour_id=ignore_case_get(self.data, "flavourId"), + version=version, + vendor=vendor, + netype=netype, + vnfd_model=vnfd_model, + status='NOT_INSTANTIATED', + vnfdid=self.vnfd_id, + localizationLanguage=ignore_case_get(self.data, 'localizationLanguage'), + input_params=self.data, + vnfSoftwareVersion=vnfsoftwareversion, + 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) + 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") @@ -133,8 +143,8 @@ class InstVnf(Thread): content_args['additionalParam']['vimid'] = vnfmInfo[0].apiurl logger.info('content_args=%s' % content_args) apply_result = apply_grant_to_nfvo(json.dumps(content_args)) - #vim_info = ignore_case_get(apply_result, "vim") - #vim_info = ignore_case_get(json.JSONDecoder().decode(apply_result), "vim") + # vim_info = ignore_case_get(apply_result, "vim") + # vim_info = ignore_case_get(json.JSONDecoder().decode(apply_result), "vim") for vdu in ignore_case_get(self.vnfd_info, "vdus"): if "location_info" in vdu["properties"]: @@ -201,8 +211,8 @@ class InstVnf(Thread): {'vsInstanceId': port.portid, 'cpdid': port.nodeId, 'changeType': 'added', - 'storageResource': {'vimId': port.vimid, 'resourceId': port.resouceid, - 'resourceName': port.name, 'resourceType': 'port'}}) + 'portResource': {'vimId': port.vimid, 'resourceId': port.resouceid, + 'resourceName': port.name, 'resourceType': 'port'}}) affected_vs = [] vss = StorageInstModel.objects.filter(instid=self.nf_inst_id) for vs in vss: @@ -214,14 +224,18 @@ class InstVnf(Thread): 'resourceName': vs.name, 'resourceType': 'volume'}}) content_args = { "status": 'result', - "nfInstanceId": self.nf_inst_id, + "vnfInstanceId": self.nf_inst_id, "operation": 'instantiate', "jobId": self.job_id, 'affectedVnfc': affected_vnfc, 'affectedVirtualLink': affected_vl, 'affectedVirtualStorage': affected_vs, - 'affectedCp': affected_cp - } + 'affectedCp': affected_cp} + + vnfmInfo = NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id) + if len(vnfmInfo) == 0: + raise NFLCMException('nf_inst_id(%s) does not exist in NfvoRegInfoModel' % self.nf_inst_id) + content_args['VNFMID'] = vnfmInfo[0].vnfminstid logger.info('content_args=%s' % content_args) resp = notify_lcm_to_nfvo(json.dumps(content_args)) logger.info('[NF instantiation] get lcm response %s' % resp)