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.GenericResourceApiRequestActionEnumeration;
26 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
31 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
32 import org.onap.so.client.exception.BadResponseException;
33 import org.onap.so.client.exception.MapperException;
34 import org.onap.so.client.sdnc.SDNCClient;
35 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
36 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
37 import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import org.springframework.beans.factory.annotation.Autowired;
41 import org.springframework.stereotype.Component;
44 public class SDNCVnfResources {
45 private static final Logger logger = LoggerFactory.getLogger(SDNCVnfResources.class);
48 private VnfTopologyOperationRequestMapper sdncRM;
51 private SDNCClient sdncClient;
53 public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
54 CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
55 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
56 SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, homing);
59 public GenericResourceApiVnfOperationInformation activateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
60 CloudRegion cloudRegion, RequestContext requestContext) {
61 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
62 SDNCSvcAction.ACTIVATE,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false);
66 public GenericResourceApiVnfOperationInformation deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
67 CloudRegion cloudRegion, RequestContext requestContext) {
68 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
69 SDNCSvcAction.DEACTIVATE,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false);
73 public GenericResourceApiVnfOperationInformation unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
74 CloudRegion cloudRegion, RequestContext requestContext) {
75 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
76 SDNCSvcAction.UNASSIGN,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false);
79 public GenericResourceApiVnfOperationInformation deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
80 CloudRegion cloudRegion, RequestContext requestContext) {
81 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
82 SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE,vnf, serviceInstance, customer, cloudRegion, requestContext, false);
85 public GenericResourceApiVnfOperationInformation changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
86 CloudRegion cloudRegion, RequestContext requestContext) {
87 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
88 SDNCSvcAction.CHANGE_ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false);
91 public String queryVnf(GenericVnf vnf) throws MapperException, BadResponseException {
92 String queryPath = vnf.getSelflink();
93 return sdncClient.get(queryPath);