1e3d655298d35e2944bba730c79206dbb63a109f
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / client / orchestration / SDNCVfModuleResources.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.client.orchestration;
24
25 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
32 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
33 import org.onap.so.client.exception.BadResponseException;
34 import org.onap.so.client.exception.MapperException;
35 import org.onap.so.client.sdnc.SDNCClient;
36 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
37 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
38 import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
41 import org.springframework.beans.factory.annotation.Autowired;
42 import org.springframework.stereotype.Component;
43
44 @Component
45 public class SDNCVfModuleResources {
46         private static final Logger logger = LoggerFactory.getLogger(SDNCVfModuleResources.class);
47
48         @Autowired
49         private VfModuleTopologyOperationRequestMapper sdncRM;
50
51         @Autowired
52         private SDNCClient sdncClient;
53
54         public GenericResourceApiVfModuleOperationInformation assignVfModule(VfModule vfModule, VolumeGroup volumeGroup,
55                         GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion,
56                         RequestContext requestContext) throws MapperException {
57                 return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
58                                 volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
59         }
60
61         public GenericResourceApiVfModuleOperationInformation unassignVfModule(VfModule vfModule, GenericVnf vnf,
62                         ServiceInstance serviceInstance) throws MapperException {
63                 return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
64                                 vnf, serviceInstance, null, null, null, null);
65         }
66
67         public GenericResourceApiVfModuleOperationInformation deactivateVfModule(VfModule vfModule, GenericVnf vnf,
68                         ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
69                         throws MapperException {
70                 return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null,
71                                 vnf, serviceInstance, customer, cloudRegion, requestContext, null);
72         }
73
74         public String queryVfModule(VfModule vfModule) throws MapperException, BadResponseException {
75                 String objectPath = vfModule.getSelflink();
76                 return sdncClient.get(objectPath);
77         }
78
79         public GenericResourceApiVfModuleOperationInformation activateVfModule(VfModule vfModule, GenericVnf vnf,
80                         ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
81                         throws MapperException {
82                 return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null,
83                                 vnf, serviceInstance, customer, cloudRegion, requestContext, null);
84         }
85
86         public GenericResourceApiVfModuleOperationInformation changeAssignVfModule(VfModule vfModule, GenericVnf vnf,
87                         ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
88                         throws MapperException {
89                 return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule,
90                                 null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
91         }
92 }