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 java.util.Optional;
25 import org.onap.so.bpmn.common.InjectionHelper;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
30 import org.onap.so.client.aai.AAIObjectType;
31 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
32 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
33 import org.onap.so.client.aai.mapper.AAIObjectMapper;
34 import org.onap.so.db.catalog.beans.OrchestrationStatus;
35 import org.onap.so.logger.MsoLogger;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.stereotype.Component;
40 public class AAIVfModuleResources {
41 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIVfModuleResources.class);
44 private InjectionHelper injectionHelper;
47 private AAIObjectMapper aaiObjectMapper;
49 public void createVfModule(VfModule vfModule, GenericVnf vnf) {
50 AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
51 vfModule.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
52 injectionHelper.getAaiClient().createIfNotExists(vfModuleURI, Optional.of(aaiObjectMapper.mapVfModule(vfModule)));
55 public void deleteVfModule(VfModule vfModule, GenericVnf vnf) {
56 AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
57 injectionHelper.getAaiClient().delete(vfModuleURI);
60 public void updateOrchestrationStatusVfModule(VfModule vfModule, GenericVnf vnf, OrchestrationStatus orchestrationStatus) {
61 AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
62 VfModule copiedVfModule = vfModule.shallowCopyId();
64 vfModule.setOrchestrationStatus(orchestrationStatus);
65 copiedVfModule.setOrchestrationStatus(orchestrationStatus);
66 org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
67 injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
70 public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) {
71 AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
72 org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
73 injectionHelper.getAaiClient().update(vfModuleURI, AAIVfModule);
76 public void connectVfModuleToVolumeGroup(GenericVnf vnf, VfModule vfModule, VolumeGroup volumeGroup, CloudRegion cloudRegion) {
77 AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
78 AAIResourceUri volumeGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
79 injectionHelper.getAaiClient().connect(vfModuleURI, volumeGroupURI);