From e40cec8af30d75e8c4c39f81a3d98e654aa2fa1f Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Thu, 2 Mar 2017 16:29:03 +0800 Subject: Modify api file of gvnfm vnflcm Change-Id: Icb86acfbb449c5363ddc5e5b9ba1fe6b1d458a78 Issue-Id: GVNFM-43 Signed-off-by: ying.yunlong --- lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py | 2 +- .../nf/vnfs/vnf_create/create_vnf_identifier.py | 2 +- lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py | 2 +- lcm/lcm/pub/msapi/gvnfmdriver.py | 44 ++++++++++++++++++++++ lcm/lcm/pub/msapi/nfvolcm.py | 44 ---------------------- 5 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 lcm/lcm/pub/msapi/gvnfmdriver.py delete mode 100644 lcm/lcm/pub/msapi/nfvolcm.py (limited to 'lcm') diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py index 7c08e90b..022b1d78 100644 --- a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py @@ -19,7 +19,7 @@ from lcm.nf.vnfs.const import VNF_STATUS from lcm.pub.database.models import NfInstModel, VmInstModel, NetworkInstModel, StorageInstModel, \ FlavourInstModel, PortInstModel, SubNetworkInstModel, VNFCInstModel from lcm.pub.exceptions import NFLCMException -from lcm.pub.msapi.nfvolcm import apply_grant_to_nfvo, notify_lcm_to_nfvo +from lcm.pub.msapi.gvnfmdriver import apply_grant_to_nfvo, notify_lcm_to_nfvo from lcm.pub.utils.jobutil import JobUtil from lcm.pub.utils.timeutil import now_time from lcm.pub.utils.values import ignore_case_get diff --git a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py index 0a901801..6d5fb00c 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py @@ -18,7 +18,7 @@ import uuid from lcm.pub.database.models import NfInstModel from lcm.pub.exceptions import NFLCMException from lcm.pub.msapi.catalog import query_rawdata_from_catalog -from lcm.pub.msapi.nfvolcm import get_packageinfo_by_vnfdid +from lcm.pub.msapi.gvnfmdriver import get_packageinfo_by_vnfdid from lcm.pub.utils import toscautil from lcm.pub.utils.timeutil import now_time from lcm.pub.utils.values import ignore_case_get diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py index 361a3011..08a3c37d 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -22,7 +22,7 @@ from lcm.pub.database.models import NfInstModel, VmInstModel, NetworkInstModel, SubNetworkInstModel, PortInstModel, StorageInstModel, FlavourInstModel, VNFCInstModel from lcm.pub.exceptions import NFLCMException from lcm.pub.msapi.catalog import query_rawdata_from_catalog -from lcm.pub.msapi.nfvolcm import apply_grant_to_nfvo, notify_lcm_to_nfvo, get_packageinfo_by_vnfdid +from lcm.pub.msapi.gvnfmdriver import apply_grant_to_nfvo, notify_lcm_to_nfvo, get_packageinfo_by_vnfdid from lcm.pub.utils import toscautil from lcm.pub.utils.jobutil import JobUtil from lcm.pub.utils.timeutil import now_time diff --git a/lcm/lcm/pub/msapi/gvnfmdriver.py b/lcm/lcm/pub/msapi/gvnfmdriver.py new file mode 100644 index 00000000..362045a7 --- /dev/null +++ b/lcm/lcm/pub/msapi/gvnfmdriver.py @@ -0,0 +1,44 @@ +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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 + +from lcm.pub.exceptions import NFLCMException +from lcm.pub.utils.restcall import req_by_msb + +logger = logging.getLogger(__name__) + + +def get_packageinfo_by_vnfdid(vnfdid): + 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) + return json.JSONDecoder().decode(ret[1]) + + +def apply_grant_to_nfvo(data): + ret = req_by_msb("openoapi/gvnfmdriver/v1/resource/grant", "PUT", data) + if ret[0] != 0: + logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) + raise NFLCMException("Nf instancing apply grant exception") + return json.JSONDecoder().decode(ret[1]) + + +def notify_lcm_to_nfvo(data): + ret = req_by_msb("openoapi/gvnfmdriver/v1/vnfs/lifecyclechangesnotification", "POST", data) + if ret[0] != 0: + logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) + raise NFLCMException("Nf lcm notify exception") + return json.JSONDecoder().decode(ret[1]) diff --git a/lcm/lcm/pub/msapi/nfvolcm.py b/lcm/lcm/pub/msapi/nfvolcm.py deleted file mode 100644 index 362045a7..00000000 --- a/lcm/lcm/pub/msapi/nfvolcm.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2017 ZTE Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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 - -from lcm.pub.exceptions import NFLCMException -from lcm.pub.utils.restcall import req_by_msb - -logger = logging.getLogger(__name__) - - -def get_packageinfo_by_vnfdid(vnfdid): - 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) - return json.JSONDecoder().decode(ret[1]) - - -def apply_grant_to_nfvo(data): - ret = req_by_msb("openoapi/gvnfmdriver/v1/resource/grant", "PUT", data) - if ret[0] != 0: - logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise NFLCMException("Nf instancing apply grant exception") - return json.JSONDecoder().decode(ret[1]) - - -def notify_lcm_to_nfvo(data): - ret = req_by_msb("openoapi/gvnfmdriver/v1/vnfs/lifecyclechangesnotification", "POST", data) - if ret[0] != 0: - logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise NFLCMException("Nf lcm notify exception") - return json.JSONDecoder().decode(ret[1]) -- cgit 1.2.3-korg