From b1e5734ef566af5d49ba17d05ca0ab7b56d6666d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 9 May 2017 03:55:30 -0700 Subject: [MSO-8] Additional fixes for the second rebase DB fixes + BPMN flows and groovy fixes + Fix issue with CloudConfig file not reloaded properly when it's wrong (JSON error or model hierarchy mistake) at MSO startup Change-Id: I2853030b78499e2a761706b643ea210955e72de3 Signed-off-by: Determe, Sebastien (sd378r) [MSO-8] Restore files removed in patch set 2 Those groovy files must be there Change-Id: I9a47ac3d9c8fc06774a1b8f518491b1b0b00af04 Signed-off-by: Determe, Sebastien (sd378r) --- .../java/org/openecomp/mso/cloud/CloudConfig.java | 421 +++++++++++---------- .../openecomp/mso/cloud/CloudConfigFactory.java | 43 ++- .../exceptions/MsoCloudIdentityNotFound.java | 56 +++ .../mso/adapter_utils/tests/CloudConfigTest.java | 41 +- .../mso/adapter_utils/tests/MsoHeatUtilsTest.java | 3 +- .../src/test/resources/cloud_config_bad.json | 31 ++ .../adapters/sdnc/impl/SDNCAdapterRestImpl.java | 6 +- .../adapters/sdnc/sdncrest/SDNCAdapterRest.java | 4 +- 8 files changed, 388 insertions(+), 217 deletions(-) create mode 100644 adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java create mode 100644 adapters/mso-adapter-utils/src/test/resources/cloud_config_bad.json (limited to 'adapters') 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 abcea2d494..929dd5aaba 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 @@ -32,19 +32,19 @@ import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.annotate.JsonRootName; - +import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; /** * 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 (in particular for the NVP/AIC cloud). - * 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 config file, so there are no explicit property setters. + * Note that this is only used to access Cloud Configurations loaded from a JSON + * config file, so there are no explicit property setters. * * This class also contains methods to query cloud sites and/or identity * services by ID. @@ -54,209 +54,246 @@ import org.openecomp.mso.logger.MsoLogger; @JsonRootName("cloud_config") public class CloudConfig { + private boolean validCloudConfig = false; @JsonProperty("identity_services") - private Map identityServices = new HashMap (); + private Map identityServices = new HashMap(); @JsonProperty("cloud_sites") - private Map cloudSites = new HashMap (); + private Map cloudSites = new HashMap(); - private static ObjectMapper mapper = new ObjectMapper (); + private static ObjectMapper mapper = new ObjectMapper(); - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); - protected String configFilePath; + protected String configFilePath; - protected int refreshTimerInMinutes; + protected int refreshTimerInMinutes; - public CloudConfig () { - mapper.enable (DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); - mapper.enable (DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + public CloudConfig() { + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); } - /** - * Get a Map of all IdentityServices that have been loaded. - * @return the Map - */ - public synchronized Map getIdentityServices () { + /** + * Get a Map of all IdentityServices that have been loaded. + * + * @return the Map + */ + public synchronized Map getIdentityServices() { return identityServices; } - /** - * Get a Map of all CloudSites that have been loaded. - * @return the Map - */ - public synchronized Map getCloudSites () { - return cloudSites; - } - - /** - * 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 individual entries - * to try and find one with a CLLI that matches the ID and an AIC version of 2.5. - * @param id the ID to match - * @return a CloudSite, or null of no match found - */ - public synchronized CloudSite getCloudSite (String id) { - if (id != null) { - if (cloudSites.containsKey (id)) { - return cloudSites.get (id); - } - // check for id == CLLI now as well - return getCloudSiteWithClli(id, "2.5"); - } - return null; - } - - /** - * Get a specific CloudSites, based on a CLLI and (optional) version, which will be matched - * against the aic_version field of the CloudSite. - * @param clli the CLLI to match - * @param version the version to match; may be null in which case any version matches - * @return a CloudSite, or null of no match found - */ - public synchronized CloudSite getCloudSiteWithClli(String clli, String version) { - if (clli != null) { - // New with 1610 - find cloud site called "DEFAULT" - return that object, - // with the name modified to match what they asked for. We're looping thru - // the cloud sites anyway - so save off the default one in case we need it. - CloudSite defaultCloudSite = null; - for (CloudSite cs : cloudSites.values()) { - if (cs.getClli() != null && clli.equals(cs.getClli())) { - if (version == null || version.equals(cs.getAic_version())) { - return cs; - } - } else if (cs.getId().equalsIgnoreCase("default")) { - // save it off in case we need it - defaultCloudSite = cs.clone(); - } - } - // If we get here - we didn't find a match - so return the default cloud site + /** + * Get a Map of all CloudSites that have been loaded. + * + * @return the Map + */ + public synchronized Map getCloudSites() { + return cloudSites; + } + + /** + * 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 + * individual entries to try and find one with a CLLI that matches the ID + * and an AIC version of 2.5. + * + * @param id + * the ID to match + * @return a CloudSite, or null of no match found + */ + public synchronized CloudSite getCloudSite(String id) { + if (id != null) { + if (cloudSites.containsKey(id)) { + return cloudSites.get(id); + } + // check for id == CLLI now as well + return getCloudSiteWithClli(id, "2.5"); + } + return null; + } + + /** + * Get a specific CloudSites, based on a CLLI and (optional) version, which + * will be matched against the aic_version field of the CloudSite. + * + * @param clli + * the CLLI to match + * @param version + * the version to match; may be null in which case any version + * matches + * @return a CloudSite, or null of no match found + */ + public synchronized CloudSite getCloudSiteWithClli(String clli, String version) { + if (clli != null) { + // New with 1610 - find cloud site called "DEFAULT" - return that + // object,with the name modified to match what they asked for. We're + // looping thru the cloud sites anyway - so save off the default one in case we + // need it. + CloudSite defaultCloudSite = null; + for (CloudSite cs : cloudSites.values()) { + if (cs.getClli() != null && clli.equals(cs.getClli())) { + if (version == null || version.equals(cs.getAic_version())) { + return cs; + } + } else if (cs.getId().equalsIgnoreCase("default")) { + // save it off in case we need it + defaultCloudSite = cs.clone(); + } + } + // If we get here - we didn't find a match - so return the default + // cloud site if (defaultCloudSite != null) { defaultCloudSite.setRegionId(clli); defaultCloudSite.setId(clli); } - return defaultCloudSite; - } + return defaultCloudSite; + } return null; - } - - /** - * Get a specific CloudIdentity, based on an ID. - * @param id the ID to match - * @return a CloudIdentity, or null of no match found - */ - public synchronized CloudIdentity getIdentityService (String id) { - if (identityServices.containsKey (id)) { - return identityServices.get (id); - } - return null; - } - - protected synchronized void reloadPropertiesFile() throws JsonParseException, JsonMappingException, IOException { - this.loadCloudConfig(this.configFilePath, this.refreshTimerInMinutes); - } - - protected synchronized void loadCloudConfig (String configFile, int refreshTimer) throws JsonParseException, JsonMappingException, IOException { - - FileReader reader=null; - configFilePath=configFile; - this.refreshTimerInMinutes = refreshTimer; - - CloudConfig cloudConfig = null; - - try { - reader = new FileReader (configFile); - // Parse the JSON input into a CloudConfig - - cloudConfig = mapper.readValue (reader, CloudConfig.class); - - this.cloudSites = cloudConfig.cloudSites; - this.identityServices = cloudConfig.identityServices; - - // Copy Cloud Identity IDs to CloudIdentity objects - for (Entry entry : cloudConfig.getIdentityServices ().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 entry : cloudConfig.getCloudSites ().entrySet ()) { - CloudSite s = entry.getValue (); - s.setId (entry.getKey ()); - s.setIdentityService (cloudConfig.getIdentityService (s.getIdentityServiceId ())); - } - } finally { - try { - if (reader != null) { - reader.close(); - } - } catch (IOException e) { - LOGGER.debug("Exception while closing reader for file:" + configFilePath, e); - } - } } - public String getConfigFilePath() { - return configFilePath; - } - - @Override - public synchronized CloudConfig clone() { - CloudConfig ccCopy = new CloudConfig(); - for (Entry e:identityServices.entrySet()) { - - ccCopy.identityServices.put(e.getKey(), e.getValue().clone()); - } - - for (Entry e:cloudSites.entrySet()) { - - ccCopy.cloudSites.put(e.getKey(), e.getValue().clone()); - } - - ccCopy.configFilePath = this.configFilePath; - - ccCopy.refreshTimerInMinutes = this.refreshTimerInMinutes; - - return ccCopy; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cloudSites == null) ? 0 : cloudSites.hashCode()); - result = prime * result + ((configFilePath == null) ? 0 : configFilePath.hashCode()); - result = prime * result + ((identityServices == null) ? 0 : identityServices.hashCode()); - result = prime * result + refreshTimerInMinutes; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CloudConfig other = (CloudConfig) obj; - if (cloudSites == null) { - if (other.cloudSites != null) - return false; - } else if (!cloudSites.equals(other.cloudSites)) - return false; - if (configFilePath == null) { - if (other.configFilePath != null) - return false; - } else if (!configFilePath.equals(other.configFilePath)) - return false; - if (identityServices == null) { - if (other.identityServices != null) - return false; - } else if (!identityServices.equals(other.identityServices)) - return false; - if (refreshTimerInMinutes != other.refreshTimerInMinutes) - return false; - return true; - } -} + /** + * Get a specific CloudIdentity, based on an ID. + * + * @param id + * the ID to match + * @return a CloudIdentity, or null of no match found + */ + public synchronized CloudIdentity getIdentityService(String id) { + if (identityServices.containsKey(id)) { + return identityServices.get(id); + } + return null; + } + + protected synchronized void reloadPropertiesFile() throws JsonParseException, JsonMappingException, IOException, MsoCloudIdentityNotFound { + this.loadCloudConfig(this.configFilePath, this.refreshTimerInMinutes); + } + + protected synchronized void loadCloudConfig(String configFile, int refreshTimer) + throws JsonParseException, JsonMappingException, IOException, MsoCloudIdentityNotFound { + + FileReader reader = null; + configFilePath = configFile; + this.refreshTimerInMinutes = refreshTimer; + + CloudConfig cloudConfig = null; + this.validCloudConfig=false; + + try { + reader = new FileReader(configFile); + // Parse the JSON input into a CloudConfig + + cloudConfig = mapper.readValue(reader, CloudConfig.class); + + this.cloudSites = cloudConfig.cloudSites; + this.identityServices = cloudConfig.identityServices; + + // Copy Cloud Identity IDs to CloudIdentity objects + for (Entry entry : cloudConfig.getIdentityServices().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 entry : cloudConfig.getCloudSites().entrySet()) { + CloudSite s = entry.getValue(); + s.setId(entry.getKey()); + CloudIdentity cloudIdentity = cloudConfig.getIdentityService(s.getIdentityServiceId()); + s.setIdentityService(cloudIdentity); + if (cloudIdentity == null) { + throw new MsoCloudIdentityNotFound(s.getId()+" Cloud site refers to a non-existing identity service: "+s.getIdentityServiceId()); + } + } + this.validCloudConfig=true; + + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (IOException e) { + LOGGER.debug("Exception while closing reader for file:" + configFilePath, e); + } + } + } + + public String getConfigFilePath() { + return configFilePath; + } + + /** + * @return the validCouldConfig + */ + public synchronized boolean isValidCloudConfig() { + return validCloudConfig; + } + + @Override + public synchronized CloudConfig clone() { + CloudConfig ccCopy = new CloudConfig(); + for (Entry e : identityServices.entrySet()) { + ccCopy.identityServices.put(e.getKey(), e.getValue().clone()); + } + + for (Entry e : cloudSites.entrySet()) { + + ccCopy.cloudSites.put(e.getKey(), e.getValue().clone()); + } + ccCopy.configFilePath = this.configFilePath; + ccCopy.refreshTimerInMinutes = this.refreshTimerInMinutes; + ccCopy.validCloudConfig = this.validCloudConfig; + return ccCopy; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((cloudSites == null) ? 0 : cloudSites.hashCode()); + result = prime * result + ((configFilePath == null) ? 0 : configFilePath.hashCode()); + result = prime * result + ((identityServices == null) ? 0 : identityServices.hashCode()); + result = prime * result + refreshTimerInMinutes; + result = prime * result + (validCloudConfig ? 1231 : 1237); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CloudConfig other = (CloudConfig) obj; + if (cloudSites == null) { + if (other.cloudSites != null) + return false; + } else if (!cloudSites.equals(other.cloudSites)) + return false; + if (configFilePath == null) { + if (other.configFilePath != null) + return false; + } else if (!configFilePath.equals(other.configFilePath)) + return false; + if (identityServices == null) { + if (other.identityServices != null) + return false; + } else if (!identityServices.equals(other.identityServices)) + return false; + if (refreshTimerInMinutes != other.refreshTimerInMinutes) + return false; + if (validCloudConfig != other.validCloudConfig) + return false; + return true; + } + + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java index 6ee6721083..688e554161 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java @@ -41,6 +41,7 @@ import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; import org.openecomp.mso.openstack.utils.MsoHeatUtils; import org.openecomp.mso.openstack.utils.MsoKeystoneUtils; import org.openecomp.mso.openstack.utils.MsoNeutronUtils; @@ -77,7 +78,7 @@ public class CloudConfigFactory implements Serializable { } } - public void initializeCloudConfig (String filePath, int refreshTimer) { + public void initializeCloudConfig (String filePath, int refreshTimer) throws MsoCloudIdentityNotFound { rwl.writeLock ().lock (); try { @@ -94,7 +95,7 @@ public class CloudConfigFactory implements Serializable { } } - public void changeMsoPropertiesFilePath (String newMsoPropPath) throws MsoPropertiesException { + public void changeMsoPropertiesFilePath (String newMsoPropPath) { rwl.writeLock ().lock (); try { CloudConfigFactory.cloudConfigCache.configFilePath = prefixMsoPropertiesPath + newMsoPropPath; @@ -109,7 +110,11 @@ public class CloudConfigFactory implements Serializable { public CloudConfig getCloudConfig () { rwl.readLock ().lock (); try { - return cloudConfigCache.clone (); + if (cloudConfigCache.isValidCloudConfig()) { + return cloudConfigCache.clone (); + } else { + return new CloudConfig(); + } } finally { rwl.readLock ().unlock (); } @@ -139,7 +144,10 @@ public class CloudConfigFactory implements Serializable { try { if (refreshTimer <= 1) { - CloudConfig oldCloudConfig = cloudConfigCache.clone(); + CloudConfig oldCloudConfig = null; + if (cloudConfigCache.isValidCloudConfig()) { + oldCloudConfig = cloudConfigCache.clone(); + } cloudConfigCache.reloadPropertiesFile (); refreshTimer = cloudConfigCache.refreshTimerInMinutes; if (!cloudConfigCache.equals(oldCloudConfig)) { @@ -173,19 +181,22 @@ public class CloudConfigFactory implements Serializable { @Produces("text/plain") public Response showCloudConfig () { CloudConfig cloudConfig = this.getCloudConfig (); - - StringBuffer response = new StringBuffer (); - response.append ("Cloud Sites:\n"); - for (CloudSite site : cloudConfig.getCloudSites ().values ()) { - response.append (site.toString () + "\n"); - } - - response.append ("\n\nCloud Identity Services:\n"); - for (CloudIdentity identity : cloudConfig.getIdentityServices ().values ()) { - response.append (identity.toString () + "\n"); + if (cloudConfig != null) { + StringBuffer response = new StringBuffer (); + response.append ("Cloud Sites:\n"); + for (CloudSite site : cloudConfig.getCloudSites ().values ()) { + response.append (site.toString () + "\n"); + } + + response.append ("\n\nCloud Identity Services:\n"); + for (CloudIdentity identity : cloudConfig.getIdentityServices ().values ()) { + response.append (identity.toString () + "\n"); + } + + return Response.status (200).entity (response).build (); + } else { + return Response.status (500).entity ("Cloud Config has not been loaded properly, this could be due to a bad JSON structure (Check the logs for additional details)").build (); } - - return Response.status (200).entity (response).build (); } @GET diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java new file mode 100644 index 0000000000..b1fb92de11 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + +/** + * Cloud site not found exception. + */ +public class MsoCloudIdentityNotFound extends MsoException { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 2583769056266415665L; + + /** + * Default constructor (needed for BPEL/JAXB) + */ + public MsoCloudIdentityNotFound () { + super("Cloud Identity not found"); + super.category=MsoExceptionCategory.USERDATA; + } + + /** + * Constructor to create a new MsoOpenstackException instance + * @param cloudSite the cloud site + */ + public MsoCloudIdentityNotFound (String cloudIdentity) { + // Set the detailed error as the Exception 'message' + super("Cloud Identity [" + cloudIdentity + "] not found"); + super.category=MsoExceptionCategory.USERDATA; + } + + @Override + public String toString () { + return getMessage(); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java index 6be668c056..03771e7667 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java @@ -24,13 +24,17 @@ package org.openecomp.mso.adapter_utils.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import org.junit.BeforeClass; + +import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import java.util.Map; import org.openecomp.mso.cloud.CloudConfig; import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudIdentity; import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; + /** @@ -50,9 +54,10 @@ public class CloudConfigTest { /** * This method is called before any test occurs. * It creates a fake tree from scratch + * @throws MsoCloudIdentityNotFound */ - @BeforeClass - public static final void prepare () { + @Before + public final void prepare () throws MsoCloudIdentityNotFound { ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); String config = classLoader.getResource("cloud_config.json").toString().substring(5); @@ -168,5 +173,35 @@ public class CloudConfigTest { CloudIdentity identity2 = con.getIdentityService("Test"); assertNull(identity2); } + + @Test (expected = MsoCloudIdentityNotFound.class) + public final void testLoadWithWrongFile () throws MsoCloudIdentityNotFound { + ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); + String config = classLoader.getResource("cloud_config_bad.json").toString().substring(5); + + cloudConfigFactory.initializeCloudConfig(config,1); + } + + @Test + public final void testReloadWithWrongFile () { + ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); + String config = classLoader.getResource("cloud_config_bad.json").toString().substring(5); + + try { + cloudConfigFactory.initializeCloudConfig(config,1); + Assert.fail("MsoCloudIdentityNotFound was expected"); + } catch (MsoCloudIdentityNotFound e) { + + } + Assert.assertTrue("Should be an empty CloudConfig", cloudConfigFactory.getCloudConfig().getCloudSites().isEmpty()); + Assert.assertTrue("Should be an empty CloudConfig", cloudConfigFactory.getCloudConfig().getIdentityServices().isEmpty()); + + // Now reload the right config + config = classLoader.getResource("cloud_config.json").toString().substring(5); + cloudConfigFactory.changeMsoPropertiesFilePath(config); + cloudConfigFactory.reloadCloudConfig(); + Assert.assertTrue("Flag valid Config should be true now that the cloud_config is correct", cloudConfigFactory.getCloudConfig().isValidCloudConfig()); + + } } diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java index 3427e42304..b620ddc192 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java @@ -27,6 +27,7 @@ import org.junit.Test; import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; import org.openecomp.mso.openstack.exceptions.MsoException; import org.openecomp.mso.openstack.exceptions.MsoIOException; @@ -49,7 +50,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { public static MsoHeatUtils msoHeatUtils; @BeforeClass - public static final void loadClasses() { + public static final void loadClasses() throws MsoCloudIdentityNotFound { ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); String config = classLoader.getResource("cloud_config.json").toString().substring(5); cloudConfigFactory.initializeCloudConfig(config, 1); diff --git a/adapters/mso-adapter-utils/src/test/resources/cloud_config_bad.json b/adapters/mso-adapter-utils/src/test/resources/cloud_config_bad.json new file mode 100644 index 0000000000..186b6c3aa0 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/resources/cloud_config_bad.json @@ -0,0 +1,31 @@ +{ "cloud_config": { + "identity_services": + { + "MT_KEYSTONE": + { + "identity_url": "http://localhost:5000/v2.0", + "mso_id": "john", + "mso_pass": "FD205490A48D48475607C36B9AD902BF", + "admin_tenant": "admin", + "member_role": "_member_", + "tenant_metadata": false, + "identity_server_type": "KEYSTONE", + "identity_authentication_type": "RACKSPACE_APIKEY" + } + }, + "cloud_sites": + { + "MT": + { + "region_id": "regionOne", + "clli": "MT", + "aic_version": "2.5", + "identity_service_id": "MT_KEYSTONE_NOT_EXISTING" + } + } +} +} + + + + diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImpl.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImpl.java index c873c9215e..55e6192ead 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImpl.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImpl.java @@ -78,9 +78,9 @@ public class SDNCAdapterRestImpl { String operation = ""; try { - reqId = headers.getRequestHeader("att-mso-request-id").get(0); - action = headers.getRequestHeader("att-mso-request-action").get(0); - operation = headers.getRequestHeader("att-mso-request-operation").get(0); + reqId = headers.getRequestHeader("mso-request-id").get(0); + action = headers.getRequestHeader("mso-request-action").get(0); + operation = headers.getRequestHeader("mso-request-operation").get(0); MsoLogger.setLogContext(reqId, ""); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterRest.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterRest.java index c4ed50a1b1..1f8e21133a 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterRest.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterRest.java @@ -82,8 +82,8 @@ public class SDNCAdapterRest { @Produces({MediaType.APPLICATION_JSON}) public Response service( SDNCServiceRequest request, - @HeaderParam(value="att-mso-request-id") String msoRequestId, - @HeaderParam(value="att-mso-service-instance-id") String msoServiceInstanceId) { + @HeaderParam(value="mso-request-id") String msoRequestId, + @HeaderParam(value="mso-service-instance-id") String msoServiceInstanceId) { MsoLogger.setLogContext(msoRequestId, msoServiceInstanceId); -- cgit 1.2.3-korg