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.adapters.vnf;
23 import java.util.Optional;
25 import org.onap.so.cloud.CloudConfig;
26 import org.onap.so.cloud.CloudSite;
27 import org.onap.so.logger.MsoLogger;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Component;
32 public class VnfAdapterRestUtils
34 private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, VnfAdapterRestUtils.class);
37 private CloudConfig cloudConfig;
40 private MsoVnfCloudifyAdapterImpl cloudifyImpl;
43 private MsoVnfAdapterImpl vnfImpl;
46 * Choose which implementation of VNF Adapter to use, based on the orchestration mode.
47 * Currently, the two supported orchestrators are HEAT and CLOUDIFY.
49 public MsoVnfAdapter getVnfAdapterImpl (String mode, String cloudSiteId)
51 // First, determine the orchestration mode to use.
52 // If was explicitly provided as a parameter, use that. Else if specified for the
53 // cloudsite, use that. Otherwise, the default is the (original) HEAT-based impl.
55 LOGGER.debug ("Entered GetVnfAdapterImpl: mode=" + mode + ", cloudSite=" + cloudSiteId);
58 // Didn't get an explicit mode type requested.
59 // Use the CloudSite to determine which Impl to use, based on whether the target cloutSite
60 // has a CloudifyManager assigned to it
61 Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId);
62 if (cloudSite.isPresent()) {
63 LOGGER.debug("Got CloudSite: " + cloudSite.toString());
64 if (cloudConfig.getCloudifyManager(cloudSite.get().getCloudifyId()) != null) {
72 LOGGER.debug ("GetVnfAdapterImpl: mode=" + mode);
74 MsoVnfAdapter vnfAdapter = null;
76 // TODO: Make this more dynamic (e.g. Service Loader)
77 if ("CLOUDIFY".equalsIgnoreCase(mode)) {
78 LOGGER.debug ("GetVnfAdapterImpl: Return Cloudify Adapter");
79 vnfAdapter = cloudifyImpl;
81 else if ("HEAT".equalsIgnoreCase(mode)) {
82 LOGGER.debug ("GetVnfAdapterImpl: Return Heat Adapter");
86 // Don't expect this, but default is the HEAT adapter
87 LOGGER.debug ("GetVnfAdapterImpl: Return Default (Heat) Adapter");