from lcm.pub.utils import toscautil
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.utils.timeutil import now_time
-from lcm.pub.utils.values import ignore_case_get, get_none, get_boolean
+from lcm.pub.utils.values import ignore_case_get, get_none, get_boolean, get_integer
from lcm.pub.vimapi import adaptor
logger = logging.getLogger(__name__)
JobUtil.add_job_status(self.job_id, 5, 'Get packageinfo by vnfd_id')
self.vnfd_id = vnf_insts[0].vnfdid
package_info = get_packageinfo_by_vnfdid(self.vnfd_id)
- for val in package_info:
- if self.vnfd_id == ignore_case_get(val, "vnfd_id"):
- self.package_id = ignore_case_get(val, "csar_id")
+ for val in ignore_case_get(package_info, "csars"):
+ if self.vnfd_id == ignore_case_get(val, "vnfdId"):
+ self.package_id = ignore_case_get(val, "csarId")
break
JobUtil.add_job_status(self.job_id, 10, 'Get rawdata from catalog by csar_id')
input_parameters = []
inputs = ignore_case_get(self.data['additionalParams'], "inputs")
- for key, val in inputs.items():
- input_parameters.append({"key": key, "value": val})
+ if inputs:
+ if isinstance(inputs, (str, unicode)):
+ inputs = json.loads(inputs)
+ for key, val in inputs.items():
+ input_parameters.append({"key": key, "value": val})
raw_data = query_rawdata_from_catalog(self.package_id, input_parameters)
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()
res_index += 1
logger.info('content_args=%s' % content_args)
- apply_result = apply_grant_to_nfvo(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")
for vdu in ignore_case_get(self.vnfd_info, "vdus"):
if "location_info" in vdu["properties"]:
'affectedCp': affected_cp
}
logger.info('content_args=%s' % content_args)
- resp = notify_lcm_to_nfvo(content_args)
+ resp = notify_lcm_to_nfvo(json.dumps(content_args))
logger.info('[NF instantiation] get lcm response %s' % resp)
logger.info('[NF instantiation] send notify request to nfvo end')
vimid=ignore_case_get(ret, "vimId"),
resouceid=ignore_case_get(ret, "id"),
tenant=ignore_case_get(ret, "tenantId"),
- vcpu=ignore_case_get(ret, "vcpu"),
- memory=ignore_case_get(ret, "memory"),
- disk=ignore_case_get(ret, "disk"),
- ephemeral=ignore_case_get(ret, "ephemeral"),
- swap=ignore_case_get(ret, "swap"),
+ vcpu=get_integer(ignore_case_get(ret, "vcpu")),
+ memory=get_integer(ignore_case_get(ret, "memory")),
+ disk=get_integer(ignore_case_get(ret, "disk")),
+ ephemeral=get_integer(ignore_case_get(ret, "ephemeral")),
+ swap=get_integer(ignore_case_get(ret, "swap")),
isPublic=get_boolean(ignore_case_get(ret, "isPublic")),
extraspecs=ignore_case_get(ret, "extraSpecs"),
is_predefined=ignore_case_get(ret, "returnCode"),