summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaili <lai.li@zte.com.cn>2018-08-10 17:30:22 +0800
committerlaili <lai.li@zte.com.cn>2018-08-11 15:47:46 +0800
commit935631c6062a5a2ee168fb4968f17986864a9a03 (patch)
treee7bba164076067af7b909ff72f2110eaeb536ac3
parent6249f6864d9c5a3711d48b432810f2accf41f56a (diff)
Modify vnf instantiation related stuffs.
Remove NfvoRegInfo. Fix logic errors in instantiate_vnf.py. Change-Id: I9f2c8b28d37364be737c8b588305d41f66e2b8b9 Issue-ID: VFC-1017 Signed-off-by: laili <lai.li@zte.com.cn>
-rw-r--r--lcm/lcm/nf/biz/instantiate_vnf.py46
-rw-r--r--lcm/lcm/nf/const.py6
-rw-r--r--lcm/lcm/nf/serializers/ext_virtual_link_data.py5
-rw-r--r--lcm/lcm/pub/database/models.py1
4 files changed, 42 insertions, 16 deletions
diff --git a/lcm/lcm/nf/biz/instantiate_vnf.py b/lcm/lcm/nf/biz/instantiate_vnf.py
index 87d4f40d..3a9bd85f 100644
--- a/lcm/lcm/nf/biz/instantiate_vnf.py
+++ b/lcm/lcm/nf/biz/instantiate_vnf.py
@@ -19,7 +19,7 @@ import uuid
from threading import Thread
from lcm.pub.database.models import NfInstModel, VmInstModel, NetworkInstModel, \
- SubNetworkInstModel, PortInstModel, StorageInstModel, FlavourInstModel, VNFCInstModel, NfvoRegInfoModel
+ SubNetworkInstModel, PortInstModel, StorageInstModel, FlavourInstModel, VNFCInstModel
from lcm.pub.exceptions import NFLCMException
from lcm.pub.msapi.gvnfmdriver import apply_grant_to_nfvo, notify_lcm_to_nfvo
from lcm.pub.msapi.sdc_run_catalog import query_vnfpackage_by_id
@@ -65,7 +65,7 @@ class InstantiateVnf(Thread):
self.vnfd_id = vnf_insts[0].vnfdid
JobUtil.add_job_status(self.job_id, 10, 'Get vnf package info from catalog by csar_id')
input_parameters = []
- inputs = ignore_case_get(self.data['additionalParams'], "inputs")
+ inputs = ignore_case_get(self.data, "additionalParams")
if inputs:
if isinstance(inputs, (str, unicode)):
inputs = json.loads(inputs)
@@ -91,17 +91,19 @@ class InstantiateVnf(Thread):
status='NOT_INSTANTIATED',
vnfdid=self.vnfd_id,
localizationLanguage=ignore_case_get(self.data, 'localizationLanguage'),
- input_params=self.data,
+ input_params=input_parameters,
vnfSoftwareVersion=vnfsoftwareversion,
lastuptime=now_time())
logger.info("VimId = %s" % 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"),
+ 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")
@@ -130,11 +132,14 @@ class InstantiateVnf(Thread):
res_index += 1
logger.debug("VnfInst = %s", self.nf_inst_id)
+ '''
vnfmInfo = NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id)
if len(vnfmInfo) == 0:
raise NFLCMException('VnfInst(%s) does not exist' % self.nf_inst_id)
- content_args['additionalParam']['vnfmid'] = vnfmInfo[0].vnfminstid
- content_args['additionalParam']['vimid'] = vnfmInfo[0].apiurl
+ '''
+ nfInsts = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
+ content_args['additionalParam']['vnfmid'] = nfInsts[0].vnfminstid
+ content_args['additionalParam']['vimid'] = self.vim_id
logger.info('Grant request data = %s', content_args)
apply_result = apply_grant_to_nfvo(json.dumps(content_args))
@@ -206,10 +211,13 @@ class InstantiateVnf(Thread):
'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
+ '''
+ nfInsts = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
+ content_args['VNFMID'] = nfInsts[0].vnfminstid
logger.info('Notify request data = %s' % content_args)
resp = notify_lcm_to_nfvo(json.dumps(content_args))
logger.info('Lcm notify end, response %s' % resp)
@@ -226,12 +234,13 @@ class InstantiateVnf(Thread):
def update_cps(self):
for extlink in ignore_case_get(self.data, "extVirtualLinks"):
- for cp in ignore_case_get(self.vnfd_info, "cps"):
- cpdid = ignore_case_get(extlink, "cpdId")
- if cpdid == ignore_case_get(cp, "cp_id"):
- cp["networkId"] = ignore_case_get(extlink, "resourceId")
- cp["subnetId"] = ignore_case_get(extlink, "resourceSubnetId")
- break
+ for ext_cp in ignore_case_get(extlink, "extCps"):
+ cpdid = ignore_case_get(ext_cp, "cpdId")
+ for cp in ignore_case_get(self.vnfd_info, "cps"):
+ if cpdid == ignore_case_get(cp, "cp_id"):
+ cp["networkId"] = ignore_case_get(extlink, "resourceId")
+ cp["subnetId"] = ignore_case_get(extlink, "resourceSubnetId")
+ break
def set_location(self, apply_result):
for resource_type in ['vdus', 'vls']:
@@ -244,6 +253,17 @@ class InstantiateVnf(Thread):
"vimid": ignore_case_get(apply_result, "vimid"),
"tenant": ignore_case_get(apply_result, "tenant")}
+ '''
+ def get_subnet_ids(self, ext_cp):
+ subnet_ids = []
+ for cp_conf in ignore_case_get(ext_cp, "cpConfig"):
+ for cp_protocol in ignore_case_get(ext_cp, "cpProtocolData"):
+ ip_over_ethernet = ignore_case_get(cp_protocol, "ipOverEthernet")
+ for ip_address in ignore_case_get(ip_over_ethernet, "ipAddresses"):
+ subnet_ids.append(ignore_case_get(ip_address, "subnetId"))
+ return subnet_ids
+ '''
+
def volume_save(job_id, nf_inst_id, ret):
JobUtil.add_job_status(job_id, 25, 'Create vloumns!')
diff --git a/lcm/lcm/nf/const.py b/lcm/lcm/nf/const.py
index 33ba6548..47097d52 100644
--- a/lcm/lcm/nf/const.py
+++ b/lcm/lcm/nf/const.py
@@ -31,6 +31,7 @@ inst_req_data = {
"vimConnectionId": "vimConnection_1",
"resourceProviderId": "resourceProvider_1",
"resourceId": "resource_1",
+ "resourceSubnetId": "resourceSubnet_1",
"extCps": [
{
"cpdId": "cpd_1",
@@ -100,10 +101,9 @@ inst_req_data = {
],
"localizationLanguage": "en_US",
"additionalParams": {
- # "inputs": {
+ "vimId": "vim_1",
"key1": "test1",
- "key2": "test2"
- # }
+ "key2": "test2",
}
}
diff --git a/lcm/lcm/nf/serializers/ext_virtual_link_data.py b/lcm/lcm/nf/serializers/ext_virtual_link_data.py
index 83d5012f..612e00cb 100644
--- a/lcm/lcm/nf/serializers/ext_virtual_link_data.py
+++ b/lcm/lcm/nf/serializers/ext_virtual_link_data.py
@@ -42,6 +42,11 @@ class ExtVirtualLinkDataSerizlizer(serializers.Serializer):
max_length=255,
required=True,
allow_null=False)
+ resourceSubnetId = serializers.CharField(
+ help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
+ max_length=255,
+ required=True,
+ allow_null=False)
extCps = VnfExtCpDataSerializer(
help_text="External CPs of the VNF to be connected to this external VL.",
many=True,
diff --git a/lcm/lcm/pub/database/models.py b/lcm/lcm/pub/database/models.py
index 02993e71..e54fae2b 100644
--- a/lcm/lcm/pub/database/models.py
+++ b/lcm/lcm/pub/database/models.py
@@ -21,6 +21,7 @@ class NfInstModel(models.Model):
nfinstid = models.CharField(db_column='NFINSTID', max_length=200, primary_key=True)
nf_name = models.CharField(db_column='NFNAME', max_length=100, blank=True, null=True) # CreateVnfRequest.vnfInstanceName
+ vnfminstid = models.CharField(max_length=255, db_column='VNFMINSTID')
package_id = models.CharField(db_column='PACKAGEID', max_length=200, blank=True, null=True)
status = models.CharField(db_column='STATUS', max_length=20, blank=True, null=True)
flavour_id = models.CharField(db_column='FLAVOURID', max_length=200, blank=True, null=True) # InstantiateVnfRequest.flavourId