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.northbound.client.model.GenericResourceApiRequestActionEnumeration;
24 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
25 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
29 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
30 import org.onap.so.client.exception.BadResponseException;
31 import org.onap.so.client.exception.MapperException;
32 import org.onap.so.client.sdnc.SDNCClient;
33 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
34 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
35 import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper;
36 import org.onap.so.logger.MsoLogger;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.stereotype.Component;
41 public class SDNCVnfResources {
42 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCVnfResources.class);
45 private VnfTopologyOperationRequestMapper sdncRM;
48 private SDNCClient sdncClient;
50 public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
51 CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
52 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
53 SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, homing);
56 public GenericResourceApiVnfOperationInformation activateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
57 CloudRegion cloudRegion, RequestContext requestContext) {
58 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
59 SDNCSvcAction.ACTIVATE,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false);
63 public GenericResourceApiVnfOperationInformation deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
64 CloudRegion cloudRegion, RequestContext requestContext) {
65 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
66 SDNCSvcAction.DEACTIVATE,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false);
70 public GenericResourceApiVnfOperationInformation unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
71 CloudRegion cloudRegion, RequestContext requestContext) {
72 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
73 SDNCSvcAction.UNASSIGN,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false);
76 public GenericResourceApiVnfOperationInformation deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
77 CloudRegion cloudRegion, RequestContext requestContext) {
78 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
79 SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE,vnf, serviceInstance, customer, cloudRegion, requestContext, false);
82 public GenericResourceApiVnfOperationInformation changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
83 CloudRegion cloudRegion, RequestContext requestContext) {
84 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
85 SDNCSvcAction.CHANGE_ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false);
88 public String queryVnf(GenericVnf vnf) throws MapperException, BadResponseException {
89 String queryPath = vnf.getSelflink();
90 return sdncClient.get(queryPath);