2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.so.client.orchestration;
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;
45 public class SDNCVfModuleResources {
46 private static final Logger logger = LoggerFactory.getLogger(SDNCVfModuleResources.class);
49 private VfModuleTopologyOperationRequestMapper sdncRM;
52 private SDNCClient sdncClient;
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);
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);
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);
74 public String queryVfModule(VfModule vfModule) throws MapperException, BadResponseException {
75 String objectPath = vfModule.getSelflink();
76 return sdncClient.get(objectPath);
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);
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);