2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Nokia 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;
24 import org.onap.so.bpmn.common.InjectionHelper;
25 import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
27 import org.onap.aaiclient.client.aai.AAIObjectType;
28 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
29 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
30 import org.onap.so.client.aai.mapper.AAIObjectMapper;
31 import org.onap.so.db.catalog.beans.OrchestrationStatus;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.stereotype.Component;
36 public class AAIPnfResources {
39 private InjectionHelper injectionHelper;
42 private AAIObjectMapper aaiObjectMapper;
44 public void createPnfAndConnectServiceInstance(Pnf pnf, ServiceInstance serviceInstance) {
45 AAIResourceUri pnfURI = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName());
46 pnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
47 AAIResourceUri serviceInstanceURI =
48 AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
49 injectionHelper.getAaiClient().createIfNotExists(pnfURI, Optional.of(aaiObjectMapper.mapPnf(pnf)))
50 .connect(pnfURI, serviceInstanceURI);
53 public void updateOrchestrationStatusPnf(Pnf pnf, OrchestrationStatus orchestrationStatus) {
54 AAIResourceUri pnfURI = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName());
56 Pnf pnfCopy = pnf.shallowCopyId();
58 pnf.setOrchestrationStatus(orchestrationStatus);
59 pnfCopy.setOrchestrationStatus(orchestrationStatus);
60 injectionHelper.getAaiClient().update(pnfURI, aaiObjectMapper.mapPnf(pnfCopy));