2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.client.orchestration;
23 import org.onap.sdnc.apps.client.model.GenericResourceApiVfModuleOperationInformation;
24 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
25 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
30 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
31 import org.onap.so.client.exception.BadResponseException;
32 import org.onap.so.client.exception.MapperException;
33 import org.onap.so.client.sdnc.SDNCClient;
34 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
35 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
36 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
37 import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;
38 import org.onap.so.logger.MsoLogger;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.stereotype.Component;
43 public class SDNCVfModuleResources {
44 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCVfModuleResources.class);
47 private VfModuleTopologyOperationRequestMapper sdncRM;
50 private SDNCClient sdncClient;
52 public String assignVfModule(VfModule vfModule, VolumeGroup volumeGroup,GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
53 CloudRegion cloudRegion, RequestContext requestContext)
54 throws MapperException, BadResponseException {
56 GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
57 SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
58 return sdncClient.post(sdncReq, SDNCTopology.VFMODULE);
61 public String unassignVfModule(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance)
62 throws MapperException, BadResponseException {
64 GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
65 SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null);
66 return sdncClient.post(sdncReq, SDNCTopology.VFMODULE);
69 public String deactivateVfModule(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance,
70 Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
71 throws MapperException, BadResponseException {
73 GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(
74 SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null, vnf, serviceInstance,
75 customer, cloudRegion, requestContext, null);
76 return sdncClient.post(sdncReq, SDNCTopology.VFMODULE);
79 public String queryVfModule(VfModule vfModule)
80 throws MapperException, BadResponseException {
82 String objectPath = vfModule.getSelflink();
83 return sdncClient.get(objectPath);
86 public String activateVfModule(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
87 CloudRegion cloudRegion, RequestContext requestContext)
88 throws MapperException, BadResponseException {
90 GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
91 SDNCSvcAction.ACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
92 return sdncClient.post(sdncReq, SDNCTopology.VFMODULE);
95 public String changeAssignVfModule(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext) throws MapperException, BadResponseException {
96 GenericResourceApiVfModuleOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
97 return sdncClient.post(sdncReq, SDNCTopology.VFMODULE);