2 * Copyright 2016-2017 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.rest;
19 import javax.servlet.http.HttpServletRequest;
20 import javax.ws.rs.Consumes;
21 import javax.ws.rs.PUT;
22 import javax.ws.rs.Path;
23 import javax.ws.rs.PathParam;
24 import javax.ws.rs.Produces;
25 import javax.ws.rs.core.Context;
26 import javax.ws.rs.core.MediaType;
28 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmJsonUtil;
29 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant;
30 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.VnfResourceMgr;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 import net.sf.json.JSONObject;
37 * Provide interfaces of resource for VNFM.
41 * @version VFC 1.0 Aug 24, 2016
43 @Path("/rest/vnfmmed/csm/v2/vapps")
44 @Consumes(MediaType.APPLICATION_JSON)
45 @Produces(MediaType.APPLICATION_JSON)
46 public class VnfResourceRoa {
48 private static final Logger LOG = LoggerFactory.getLogger(VnfResourceRoa.class);
50 private VnfResourceMgr vnfResourceMgr;
52 public void setVnfResourceMgr(VnfResourceMgr vnfResourceMgr) {
53 this.vnfResourceMgr = vnfResourceMgr;
57 * Provide function of grant resource.
66 @Path("/instances/{vnfId}/grant")
67 public String grantVnfRes(@Context HttpServletRequest context, @PathParam("vnfId") String vnfId) {
68 LOG.info("function=grantVnfRes, msg=enter to grant vnf resource.");
69 JSONObject restJson = new JSONObject();
70 restJson.put(Constant.RETCODE, Constant.REST_FAIL);
72 JSONObject dataObject = VnfmJsonUtil.getJsonFromContexts(context);
73 LOG.info("function=grantVnfRes, dataObject: {}", dataObject);
74 /*if(null == dataObject) {
75 LOG.error("function=grantVnfRes, msg=param error");
76 restJson.put("data", "Params error");
77 return restJson.toString();
80 JSONObject grantObj = dataObject.getJSONObject("grant");
82 if(null == grantObj) {
83 LOG.error("function=grantVnfRes, msg=param error");
84 restJson.put("data", "Grant param error");
85 return restJson.toString();
88 String vnfmId = grantObj.getString("project_id");
90 JSONObject resultObj = vnfResourceMgr.grantVnfResource(grantObj, vnfId, vnfmId);*/
91 JSONObject res = new JSONObject();
92 res.put("msg","grant success");
93 return res.toString();
97 @Path("/lifecycle_changes_notification")
98 public String notify(@Context HttpServletRequest context) {
99 LOG.info("function=notify, msg=enter to notify vnf resource");
100 JSONObject restJson = new JSONObject();
101 restJson.put(Constant.RETCODE, Constant.REST_SUCCESS);
103 return restJson.toString();