Modify code of create vnf identifier
[vfc/gvnfm/vnflcm.git] / lcm / lcm / pub / msapi / nfvolcm.py
1 # Copyright 2017 ZTE Corporation.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14 import json
15 import logging
16
17 from lcm.pub.exceptions import NFLCMException
18 from lcm.pub.utils.restcall import req_by_msb
19
20 logger = logging.getLogger(__name__)
21
22
23 #call gvnfm driver
24 def get_packageinfo_by_vnfdid(vnfdid):
25     ret = req_by_msb("openoapi/nslcm/v1/vnfs/%s" % vnfdid, "GET")
26     if ret[0] != 0:
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])
30
31 #call gvnfm driver
32 def vnfd_rawdata_get(vnfdid, data):
33     ret = req_by_msb("openoapi/nslcm/v1/vnfs/%s" % vnfdid, "GET", data)
34     return ret
35
36 #call gvnfm driver
37 def apply_grant_to_nfvo(data):
38     ret = req_by_msb("openoapi/nslcm/v1/grantvnf" , "POST", data)
39     return ret
40
41 #call gvnfm driver
42 def notify_lcm_to_nfvo(data, nf_inst_id):
43     ret = req_by_msb("openoapi/nslcm/v1/vnfs/%s/Notify"%nf_inst_id, "POST", data)
44     return ret
45
46 #call gvnfm driver
47 def apply_res_to_nfvo(data):
48     ret = req_by_msb("openoapi/nslcm/v1/res" , "POST", data)
49     return ret