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.endpoint.SDNCTopology;
36 import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper;
37 import org.onap.so.logger.MsoLogger;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.stereotype.Component;
42 public class SDNCVnfResources {
43 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCVnfResources.class);
46 private VnfTopologyOperationRequestMapper sdncRM;
49 private SDNCClient sdncClient;
51 public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
52 CloudRegion cloudRegion, RequestContext requestContext, boolean homing)
53 throws MapperException, BadResponseException {
54 return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
55 SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, homing);
58 public String activateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
59 CloudRegion cloudRegion, RequestContext requestContext)
60 throws MapperException, BadResponseException {
61 GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
62 SDNCSvcAction.ACTIVATE,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false);
63 return sdncClient.post(sdncReq, SDNCTopology.VNF);
67 public String deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
68 CloudRegion cloudRegion, RequestContext requestContext)
69 throws MapperException, BadResponseException {
70 GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
71 SDNCSvcAction.DEACTIVATE,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false);
72 return sdncClient.post(sdncReq, SDNCTopology.VNF);
76 public String unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
77 CloudRegion cloudRegion, RequestContext requestContext)
78 throws MapperException, BadResponseException {
79 GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
80 SDNCSvcAction.UNASSIGN,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false);
81 return sdncClient.post(sdncReq, SDNCTopology.VNF);
84 public String deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
85 CloudRegion cloudRegion, RequestContext requestContext)
86 throws MapperException, BadResponseException {
87 GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
88 SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE,vnf, serviceInstance, customer, cloudRegion, requestContext, false);
89 return sdncClient.post(sdncReq, SDNCTopology.VNF);
92 public String changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
93 CloudRegion cloudRegion, RequestContext requestContext)
94 throws MapperException, BadResponseException {
95 GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
96 SDNCSvcAction.CHANGE_ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false);
97 return sdncClient.post(sdncReq, SDNCTopology.VNF);
100 public String queryVnf(GenericVnf vnf) throws MapperException, BadResponseException {
101 String queryPath = vnf.getSelflink();
102 return sdncClient.get(queryPath);