diff options
author | Rob Daugherty <rd472p@att.com> | 2018-03-14 02:07:32 -0400 |
---|---|---|
committer | Rob Daugherty <rd472p@att.com> | 2018-03-14 04:08:41 -0400 |
commit | 38f720752af4d4aad8c4e467a288d9048659f688 (patch) | |
tree | e81066a8b5c77272e30fb57a64999573c4db4d86 /adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java | |
parent | aee3d223f92a6f250f43e17558a2dfd576ff7294 (diff) |
AT&T 1712 and 1802 release code
This is code from AT&T's 1712 and 1802 releases.
Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04
Issue-ID: SO-425
Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java')
-rw-r--r-- | adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java | 77 |
1 files changed, 60 insertions, 17 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java index 275241f768..2c15391c81 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,18 +27,22 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.annotate.JsonRootName; + import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + /** * JavaBean JSON class for a CloudConfig. This bean maps a JSON-format cloud * configuration file to Java. The CloudConfig contains information about - * Openstack cloud configurations. It includes: - * - CloudIdentity objects,representing DCP nodes (Openstack Identity Service) + * Openstack cloud configurations. It includes: + * - CloudIdentity objects,representing DCP nodes (Openstack Identity Service) * - CloudSite objects, representing LCP nodes (Openstack Compute & other services) * * Note that this is only used to access Cloud Configurations loaded from a JSON @@ -46,6 +50,7 @@ import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; * * This class also contains methods to query cloud sites and/or identity * services by ID. + * */ @JsonRootName("cloud_config") @@ -61,11 +66,13 @@ public class CloudConfig { @JsonProperty("identity_services") private Map<String, CloudIdentity> identityServices = new HashMap<>(); @JsonProperty("cloud_sites") - private Map<String, CloudSite> cloudSites = new HashMap<>(); + private Map <String, CloudSite> cloudSites = new HashMap <String, CloudSite> (); + @JsonProperty("cloudify_managers") + private Map <String, CloudifyManager> cloudifyManagers = new HashMap <String, CloudifyManager> (); public CloudConfig() { - mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); - mapper.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE); + mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); } /** @@ -82,6 +89,14 @@ public class CloudConfig { return Collections.unmodifiableMap(cloudSites); } + /** + * Get a Map of all CloudifyManagers that have been loaded. + * @return the Map + */ + public synchronized Map <String, CloudifyManager> getCloudifyManagers () { + return cloudifyManagers; + } + /** * Get a specific CloudSites, based on an ID. The ID is first checked * against the regions, and if no match is found there, then against @@ -98,11 +113,10 @@ public class CloudConfig { if (cloudSites.containsKey(id)) { return Optional.ofNullable(cloudSites.get(id)); } - return Optional.ofNullable(getCloudSiteWithClli(id)); + return null; } - - private CloudSite getCloudSiteWithClli(String clli) { + private CloudSite getCloudSiteWithClli(String clli) { Optional <CloudSite> cloudSiteOptional = cloudSites.values().stream().filter(cs -> cs.getClli() != null && clli.equals(cs.getClli()) && (CLOUD_SITE_VERSION.equals(cs.getAic_version()))) .findAny(); @@ -124,7 +138,7 @@ public class CloudConfig { /** * Get a specific CloudIdentity, based on an ID. - * + * * @param id * the ID to match * @return a CloudIdentity, or null of no match found @@ -136,6 +150,18 @@ public class CloudConfig { return null; } + /** + * Get a specific CloudifyManager, based on an ID. + * @param id the ID to match + * @return a CloudifyManager, or null of no match found + */ + public synchronized CloudifyManager getCloudifyManager (String id) { + if (cloudifyManagers.containsKey (id)) { + return cloudifyManagers.get (id); + } + return null; + } + protected synchronized void reloadPropertiesFile() throws IOException, MsoCloudIdentityNotFound { this.loadCloudConfig(this.configFilePath, this.refreshTimerInMinutes); } @@ -156,12 +182,18 @@ public class CloudConfig { this.cloudSites = cloudConfig.cloudSites; this.identityServices = cloudConfig.identityServices; + this.cloudifyManagers = cloudConfig.cloudifyManagers; // Copy Cloud Identity IDs to CloudIdentity objects for (Entry<String, CloudIdentity> entry : cloudConfig.getIdentityServices().entrySet()) { entry.getValue().setId(entry.getKey()); } + // Copy Cloduify IDs to CloudifyManager objects + for (Entry <String, CloudifyManager> entry : cloudConfig.getCloudifyManagers ().entrySet ()) { + entry.getValue ().setId (entry.getKey ()); + } + // Copy Cloud Site IDs to CloudSite objects, and set up internal // pointers to their corresponding identity service. for (Entry<String, CloudSite> entry : cloudConfig.getCloudSites().entrySet()) { @@ -172,9 +204,11 @@ public class CloudConfig { if (cloudIdentity == null) { throw new MsoCloudIdentityNotFound(s.getId()+" Cloud site refers to a non-existing identity service: "+s.getIdentityServiceId()); } + CloudifyManager cloudifyManager = cloudConfig.getCloudifyManager(s.getCloudifyId()); + s.setCloudifyManager(cloudifyManager); } this.validCloudConfig=true; - + } finally { try { if (reader != null) { @@ -201,11 +235,20 @@ public class CloudConfig { public synchronized CloudConfig clone() { CloudConfig ccCopy = new CloudConfig(); for (Entry<String, CloudIdentity> e : identityServices.entrySet()) { + ccCopy.identityServices.put(e.getKey(), e.getValue().clone()); } + for (Entry<String, CloudSite> e : cloudSites.entrySet()) { + ccCopy.cloudSites.put(e.getKey(), e.getValue().clone()); } + + for (Entry<String,CloudifyManager> e:cloudifyManagers.entrySet()) { + + ccCopy.cloudifyManagers.put(e.getKey(), e.getValue().clone()); + } + ccCopy.configFilePath = this.configFilePath; ccCopy.refreshTimerInMinutes = this.refreshTimerInMinutes; ccCopy.validCloudConfig = this.validCloudConfig; @@ -261,5 +304,5 @@ public class CloudConfig { return true; } - + } |