1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 from lcm.pub.exceptions import NFLCMException
18 from lcm.pub.utils.restcall import req_by_msb
20 logger = logging.getLogger(__name__)
23 def get_packageinfo_by_vnfdid(vnfdid):
24 ret = req_by_msb("openoapi/gvnfmdriver/v1/vnfpackages", "GET") # TODO
26 logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
27 raise NFLCMException("Failed to query package_info of vnfdid(%s) from nslcm." % vnfdid)
28 return json.JSONDecoder().decode(ret[1])
31 def apply_grant_to_nfvo(data):
32 ret = req_by_msb("openoapi/gvnfmdriver/v1/resource/grant", "PUT", data)
34 logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
35 raise NFLCMException("Nf instancing apply grant exception")
36 return json.JSONDecoder().decode(ret[1])
39 def notify_lcm_to_nfvo(data):
40 ret = req_by_msb("openoapi/gvnfmdriver/v1/vnfs/lifecyclechangesnotification", "POST", data)
42 logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
43 raise NFLCMException("Nf lcm notify exception")
44 return json.JSONDecoder().decode(ret[1])