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.
18 from lcm.pub.exceptions import NFLCMException
19 from lcm.pub.utils.restcall import req_by_msb
21 logger = logging.getLogger(__name__)
24 def get_packageinfo_by_vnfdid(vnfdid):
25 ret = req_by_msb("api/gvnfmdriver/v1/vnfpackages", "GET")
27 logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
28 raise NFLCMException("Failed to query package_info of vnfdid(%s) from nslcm." % vnfdid)
29 return json.JSONDecoder().decode(ret[1])
32 def apply_grant_to_nfvo(data):
33 ret = req_by_msb("api/gvnfmdriver/v1/resource/grant", "PUT", data)
35 logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
36 raise NFLCMException("Nf instancing apply grant exception")
37 return json.JSONDecoder().decode(ret[1])
40 def notify_lcm_to_nfvo(data):
41 ret = req_by_msb("api/gvnfmdriver/v1/vnfs/lifecyclechangesnotification", "POST", data)
43 logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
44 raise NFLCMException("Nf lcm notify exception")