Update docker image to fix CSIT failure
[vfc/nfvo/driver/vnfm/svnfm.git] / nokiav2 / driver / src / main / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / nokia / restapi / LcnApi.java
1 /*
2  * Copyright 2016-2017, Nokia Corporation
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
17
18 import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification;
19 import javax.servlet.http.HttpServletResponse;
20 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager;
21 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo;
22 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
23 import org.slf4j.Logger;
24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.stereotype.Controller;
26 import org.springframework.web.bind.annotation.RequestBody;
27 import org.springframework.web.bind.annotation.RequestMapping;
28 import org.springframework.web.bind.annotation.ResponseStatus;
29
30 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.BASE_URL;
31 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.LCN_URL;
32 import static org.slf4j.LoggerFactory.getLogger;
33 import static org.springframework.http.HttpStatus.NO_CONTENT;
34 import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
35 import static org.springframework.web.bind.annotation.RequestMethod.GET;
36 import static org.springframework.web.bind.annotation.RequestMethod.POST;
37
38 /**
39  * Responsible for providing the Nokia CBAM REST API for recieving LCNs from CBAM
40  */
41 @Controller
42 @RequestMapping(value = BASE_URL)
43 public class LcnApi {
44     private static Logger logger = getLogger(LcnApi.class);
45     private final LifecycleChangeNotificationManager lifecycleChangeNotificationManagerForSo;
46     private final LifecycleChangeNotificationManager lifecycleChangeNotificationManagerForVfc;
47
48     @Autowired
49     LcnApi(LifecycleChangeNotificationManagerForSo lifecycleManagerForSo, LifecycleChangeNotificationManagerForVfc lifecycleManagerForVfc) {
50         this.lifecycleChangeNotificationManagerForSo = lifecycleManagerForSo;
51         this.lifecycleChangeNotificationManagerForVfc = lifecycleManagerForVfc;
52     }
53
54     /**
55      * Provides a probe for CBAM VNFM to test LCN registration
56      *
57      * @param httpResponse the HTTP response
58      */
59     @RequestMapping(value = LCN_URL, method = GET)
60     public void testLcnConnectivity(HttpServletResponse httpResponse) {
61         //used to test connectivity from CBAM to driver
62     }
63
64     /**
65      * Handle the LCN sent by CBAM
66      *
67      * @param lcn the LCN notification
68      */
69     @RequestMapping(value = LCN_URL, method = POST, consumes = APPLICATION_JSON_VALUE)
70     @ResponseStatus(code = NO_CONTENT)
71     public void handleLcn(@RequestBody VnfLifecycleChangeNotification lcn) {
72         logger.info("REST: handle LCN");
73         //FIXME fork between where the VNF is managed
74         lifecycleChangeNotificationManagerForVfc.handleLcn(lcn);
75     }
76 }