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.openecomp.mso.adapters.vnf;
23 import java.util.Optional;
25 import org.openecomp.mso.cloud.CloudConfigFactory;
26 import org.openecomp.mso.cloud.CloudSite;
27 import org.openecomp.mso.logger.MsoLogger;
28 import org.openecomp.mso.properties.MsoPropertiesFactory;
30 public class VnfAdapterRestUtils
32 private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
33 private static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
34 private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
37 * Choose which implementation of VNF Adapter to use, based on the orchestration mode.
38 * Currently, the two supported orchestrators are HEAT and CLOUDIFY.
40 public static MsoVnfAdapter getVnfAdapterImpl (String mode, String cloudSiteId)
42 // First, determine the orchestration mode to use.
43 // If was explicitly provided as a parameter, use that. Else if specified for the
44 // cloudsite, use that. Otherwise, the default is the (original) HEAT-based impl.
46 LOGGER.debug ("Entered GetVnfAdapterImpl: mode=" + mode + ", cloudSite=" + cloudSiteId);
49 // Didn't get an explicit mode type requested.
50 // Use the CloudSite to determine which Impl to use, based on whether the target cloutSite
51 // has a CloudifyManager assigned to it
52 Optional<CloudSite> cloudSite = cloudConfigFactory.getCloudConfig().getCloudSite(cloudSiteId);
53 if (cloudSite.isPresent()) {
54 LOGGER.debug("Got CloudSite: " + cloudSite.toString());
55 if (cloudSite.get().getCloudifyManager() != null) {
63 LOGGER.debug ("GetVnfAdapterImpl: mode=" + mode);
65 MsoVnfAdapter vnfAdapter = null;
67 // TODO: Make this more dynamic (e.g. Service Loader)
68 if ("CLOUDIFY".equalsIgnoreCase(mode)) {
69 LOGGER.debug ("GetVnfAdapterImpl: Return Cloudify Adapter");
70 vnfAdapter = new MsoVnfCloudifyAdapterImpl (msoPropertiesFactory, cloudConfigFactory);;
72 else if ("HEAT".equalsIgnoreCase(mode)) {
73 LOGGER.debug ("GetVnfAdapterImpl: Return Heat Adapter");
74 vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
77 // Default is the PLUGIN adapter
78 LOGGER.debug ("GetVnfAdapterImpl: Return Default (Plugin) Adapter");
79 vnfAdapter = new MsoVnfPluginAdapterImpl (msoPropertiesFactory, cloudConfigFactory);