summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-03-02 14:53:37 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-03-02 14:53:37 +0800
commitb51f79348b419a755dd08f758c45ed56c2ea0a10 (patch)
tree28e892099e9b830bed1c9e6b40b8cbf8cd4d21be /lcm
parent062226977de3e506f31d2473f28f6409d5c81125 (diff)
Update vnf instaniation code of gvnfm vnflcm
Change-Id: I79e55ea322a95e3fbfcf793b64e06279e37cf27d Issue-Id: GVNFM-42 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/vnfs/const.py79
-rw-r--r--lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py11
-rw-r--r--lcm/lcm/pub/msapi/nfvolcm.py2
-rw-r--r--lcm/lcm/pub/vimapi/adaptor.py9
4 files changed, 62 insertions, 39 deletions
diff --git a/lcm/lcm/nf/vnfs/const.py b/lcm/lcm/nf/vnfs/const.py
index a3a2f5f8..f368271e 100644
--- a/lcm/lcm/nf/vnfs/const.py
+++ b/lcm/lcm/nf/vnfs/const.py
@@ -22,43 +22,52 @@ inst_req_data = {
"flavourId": "flavour_1",
"instantiationLevelId": "instantiationLevel_1",
"extVirtualLinks": [
+ # {
+ # "vlInstanceId": "1",
+ # "vim": {
+ # "vimInfoId": "1",
+ # "vimId": "1",
+ # "interfaceInfo": {
+ # "vimType": "vim",
+ # "apiVersion": "v2",
+ # "protocolType": "http"
+ # },
+ # "accessInfo": {
+ # "tenant": "tenant_vCPE",
+ # "username": "vCPE",
+ # "password": "vCPE_321"
+ # },
+ # "interfaceEndpoint": "http://10.43.21.105:80/"
+ # },
+ # "resourceId": "1246",
+ # "extCps": [
+ # {
+ # "cpdId": "11",
+ # "addresses": [
+ # {
+ # "addressType": "MAC",
+ # "l2AddressData": "00:f3:43:20:a2:a3"
+ # },
+ # {
+ # "addressType": "IP",
+ # "l3AddressData": {
+ # "iPAddressType": "IPv4",
+ # "iPAddress": "192.168.104.2"
+ # }
+ # }
+ # ],
+ # "numDynamicAddresses": 0
+ # }
+ # ]
+ # },
{
- "vlInstanceId": "1",
+ "vlInstanceId": '55',
+ "resourceId": '55_network',
+ "resourceSubnetId": '55_subnet',
+ "cpdId": 'cpId1',
"vim": {
- "vimInfoId": "1",
- "vimId": "1",
- "interfaceInfo": {
- "vimType": "vim",
- "apiVersion": "v2",
- "protocolType": "http"
- },
- "accessInfo": {
- "tenant": "tenant_vCPE",
- "username": "vCPE",
- "password": "vCPE_321"
- },
- "interfaceEndpoint": "http://10.43.21.105:80/"
- },
- "resourceId": "1246",
- "extCps": [
- {
- "cpdId": "11",
- "addresses": [
- {
- "addressType": "MAC",
- "l2AddressData": "00:f3:43:20:a2:a3"
- },
- {
- "addressType": "IP",
- "l3AddressData": {
- "iPAddressType": "IPv4",
- "iPAddress": "192.168.104.2"
- }
- }
- ],
- "numDynamicAddresses": 0
- }
- ]
+ "vimid": '55_vimid'
+ }
}
],
"localizationLanguage": "en_US",
diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
index e94001e6..c950e153 100644
--- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
+++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
@@ -91,6 +91,7 @@ class InstVnf(Thread):
self.vnfd_info = json.JSONDecoder().decode(self.vnfd_info)
self.vnfd_info = vnfd_model_dict # just for test
+ self.update_cps()
self.checkParameterExist()
# update NfInstModel
@@ -392,6 +393,16 @@ class InstVnf(Thread):
# def do_notify_delete(self, ret):
# logger.error('Deleting [%s] resource' % ret)
+ def update_cps(self):
+ for extlink in ignore_case_get(self.data, "extVirtualLinks"):
+ for cp in 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
+ pass
+
def checkParameterExist(self):
# if ignore_case_get(self.data, "flavourId") not in self.vnfd_info:
# raise NFLCMException('Input parameter is not defined in vnfd_info.')
diff --git a/lcm/lcm/pub/msapi/nfvolcm.py b/lcm/lcm/pub/msapi/nfvolcm.py
index f6849da0..362045a7 100644
--- a/lcm/lcm/pub/msapi/nfvolcm.py
+++ b/lcm/lcm/pub/msapi/nfvolcm.py
@@ -21,7 +21,7 @@ logger = logging.getLogger(__name__)
def get_packageinfo_by_vnfdid(vnfdid):
- ret = req_by_msb("openoapi/gvnfmdriver/v1/%s" % vnfdid, "GET") # TODO
+ ret = req_by_msb("openoapi/gvnfmdriver/v1/vnfpackages", "GET") # TODO
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NFLCMException("Failed to query package_info of vnfdid(%s) from nslcm." % vnfdid)
diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py
index fed69b1d..a09943f5 100644
--- a/lcm/lcm/pub/vimapi/adaptor.py
+++ b/lcm/lcm/pub/vimapi/adaptor.py
@@ -167,13 +167,16 @@ def create_port(vim_cache, res_cache, data, port, do_notify, res_type):
if not location_info:
err_msg = "vdu_id(%s) for cp(%s) is not defined"
raise VimException(err_msg % (port_ref_vdu_id, port["cp_id"]), ERR_CODE)
- network_id = get_res_id(res_cache, RES_NETWORK, port["vl_id"])
- subnet_id = get_res_id(res_cache, RES_SUBNET, port["vl_id"])
+ network_id = ignore_case_get(port, "networkId")
+ subnet_id = ignore_case_get(port, "subnetId")
+ if not network_id:
+ network_id = get_res_id(res_cache, RES_NETWORK, port["vl_id"])
+ subnet_id = get_res_id(res_cache, RES_SUBNET, port["vl_id"])
param = {
"networkId": network_id,
- "subnetId": subnet_id,
"name": port["properties"]["name"]
}
+ set_opt_val(param, "subnetId", subnet_id)
set_opt_val(param, "macAddress", ignore_case_get(port["properties"], "mac_address"))
set_opt_val(param, "ip", ignore_case_get(port["properties"], "ip_address"))
set_opt_val(param, "vnicType", ignore_case_get(port["properties"], "vnic_type"))