diff options
Diffstat (limited to 'asdc-controller/src/main/java/org/openecomp/mso/asdc/client')
9 files changed, 1513 insertions, 0 deletions
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java new file mode 100644 index 0000000000..1d87ccbe21 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java @@ -0,0 +1,418 @@ +/*- + * ============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.asdc.client; + + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; +import java.util.Properties; + +import org.codehaus.jackson.JsonNode; + +import org.openecomp.sdc.api.consumer.IConfiguration; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.properties.MsoJsonProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +public class ASDCConfiguration implements IConfiguration { + + private MsoPropertiesFactory msoPropertiesFactory; + + // SHell command to obtain the same encryption, 128 bits key, key must be HEX + // echo -n "This is a test string" | openssl aes-128-ecb -e -K 546573746F736973546573746F736973 -nosalt | xxd + + private String configKey; + + private MsoJsonProperties msoProperties; + + private String asdcControllerName; + + public static final String MSO_PROP_ASDC = "MSO_PROP_ASDC"; + public static final String PARAMETER_PATTERN = "asdc-connections"; + + public static final String CONSUMER_GROUP_ATTRIBUTE_NAME = "consumerGroup"; + public static final String CONSUMER_ID_ATTRIBUTE_NAME = "consumerId"; + public static final String ENVIRONMENT_NAME_ATTRIBUTE_NAME = "environmentName"; + public static final String PASSWORD_ATTRIBUTE_NAME = "password"; + public static final String POLLING_INTERVAL_ATTRIBUTE_NAME = "pollingInterval"; + public static final String RELEVANT_ARTIFACT_TYPES_ATTRIBUTE_NAME = "relevantArtifactTypes"; + public static final String USER_ATTRIBUTE_NAME = "user"; + public static final String ASDC_ADDRESS_ATTRIBUTE_NAME = "asdcAddress"; + public static final String POLLING_TIMEOUT_ATTRIBUTE_NAME = "pollingTimeout"; + public static final String ACTIVATE_SERVER_TLS_AUTH = "activateServerTLSAuth"; + public static final String KEY_STORE_PASSWORD = "keyStorePassword"; + public static final String KEY_STORE_PATH = "keyStorePath"; + + public static final String HEAT="HEAT"; + public static final String HEAT_ARTIFACT="HEAT_ARTIFACT"; + public static final String HEAT_ENV="HEAT_ENV"; + public static final String HEAT_NESTED="HEAT_NESTED"; + public static final String HEAT_NET="HEAT_NET"; + public static final String HEAT_VOL="HEAT_VOL"; + public static final String OTHER="OTHER"; + public static final String VF_MODULES_METADATA="VF_MODULES_METADATA"; + + + private static final String[] SUPPORTED_ARTIFACT_TYPES = {HEAT, + HEAT_ARTIFACT, + HEAT_ENV, + HEAT_NESTED, + HEAT_NET, + HEAT_VOL, + OTHER, + VF_MODULES_METADATA}; + + public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST = Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES)); + + /** + * Default constructor, the mso.properties is searched in the classpath (for testing) + * Or in /etc/ecomp/mso/config/mso.properties + * + * @param controllerName The controllerName of the config JSON tree + * @throws ASDCParametersException in case of issues with the parameters + * @throws IOException If the key file has not been loaded properly + */ + public ASDCConfiguration (String controllerName) throws ASDCParametersException, IOException { + + Properties keyProp = new Properties (); + this.asdcControllerName = controllerName; + + keyProp.load (Thread.currentThread ().getContextClassLoader ().getResourceAsStream ("config-key.properties")); + configKey = (String) keyProp.get ("asdc.config.key"); + + // This structure contains static values initialized by servlet initializer + this.msoPropertiesFactory = new MsoPropertiesFactory (); + + refreshASDCConfig (); + + } + + public String getAsdcControllerName () { + return asdcControllerName; + } + + private JsonNode getASDCControllerConfigJsonNode () { + if (this.msoProperties.getJsonRootNode ().get (PARAMETER_PATTERN) != null) { + return this.msoProperties.getJsonRootNode ().get (PARAMETER_PATTERN).get (this.asdcControllerName); + } else { + return null; + } + + } + + /** + * This method reload the config if needed. + * + * @return true if config has been reloaded, false otherwise + * @throws ASDCParametersException In case the parameters validation fails + * @throws MsoPropertiesException + */ + public boolean refreshASDCConfig () throws ASDCParametersException { + + try { + if (msoPropertiesFactory.propertiesHaveChanged (MSO_PROP_ASDC, msoProperties)) { + msoProperties = msoPropertiesFactory.getMsoJsonProperties (MSO_PROP_ASDC); + + this.testAllParameters (); + return true; + } else { + return false; + } + } catch (MsoPropertiesException e) { + throw new ASDCParametersException ("mso.asdc.json not initialized properly, ASDC config cannot be reloaded", + e); + } + } + + /** + * This method is useful to check whether a mso properties config has been changed. + * + * @return true is a new config is availabe, false otherwise + * @throws ASDCParametersException + * @throws MsoPropertiesException + */ + public boolean hasASDCConfigChanged () throws ASDCParametersException { + try { + return msoPropertiesFactory.propertiesHaveChanged (MSO_PROP_ASDC, msoProperties); + } catch (MsoPropertiesException e) { + throw new ASDCParametersException ("mso.asdc.json not initialized properly, ASDC config cannot be read", e); + } + } + + @Override + public String getConsumerGroup () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (CONSUMER_GROUP_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (CONSUMER_GROUP_ATTRIBUTE_NAME).asText (); + + if ("NULL".equals (config) || config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getConsumerID () { + + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (CONSUMER_ID_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (CONSUMER_ID_ATTRIBUTE_NAME).asText (); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getEnvironmentName () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (ENVIRONMENT_NAME_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (ENVIRONMENT_NAME_ATTRIBUTE_NAME).asText (); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getPassword () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (PASSWORD_ATTRIBUTE_NAME) != null) { + String config = this.msoProperties.getEncryptedProperty (masterConfigNode.get (PASSWORD_ATTRIBUTE_NAME), + null, + this.configKey); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public int getPollingInterval () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (POLLING_INTERVAL_ATTRIBUTE_NAME) != null) { + return masterConfigNode.get (POLLING_INTERVAL_ATTRIBUTE_NAME).asInt (); + } else { + return 0; + } + } + + @Override + public List <String> getRelevantArtifactTypes () { + // DO not return the Static List SUPPORTED_ARTIFACT_TYPES_LIST because the ASDC Client will try to modify it !!! + return Arrays.asList(SUPPORTED_ARTIFACT_TYPES); + } + + @Override + public String getUser () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (USER_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (USER_ATTRIBUTE_NAME).asText (); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getAsdcAddress () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (ASDC_ADDRESS_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (ASDC_ADDRESS_ATTRIBUTE_NAME).asText (); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public int getPollingTimeout () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (POLLING_TIMEOUT_ATTRIBUTE_NAME) != null) { + return masterConfigNode.get (POLLING_TIMEOUT_ATTRIBUTE_NAME).asInt (); + } else { + return 0; + } + } + + @Override + public boolean activateServerTLSAuth() { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode(); + if (masterConfigNode != null && masterConfigNode.get(ACTIVATE_SERVER_TLS_AUTH) != null) { + return masterConfigNode.get(ACTIVATE_SERVER_TLS_AUTH).asBoolean(false); + } else { + return false; + } + } + + @Override + public String getKeyStorePassword() { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode(); + if (masterConfigNode != null && masterConfigNode.get(KEY_STORE_PASSWORD) != null) { + String config = this.msoProperties.getEncryptedProperty(masterConfigNode.get(KEY_STORE_PASSWORD), null, + this.configKey); + + if (config.isEmpty()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getKeyStorePath() { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode(); + if (masterConfigNode != null && masterConfigNode.get(KEY_STORE_PATH) != null) { + String config = masterConfigNode.get(KEY_STORE_PATH).asText(); + + if (config.isEmpty()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + public void testAllParameters () throws ASDCParametersException { + + // Special case for this attribute that can be null from getConsumerGroup + if (this.getConsumerGroup () == null + && (getASDCControllerConfigJsonNode () == null + || !"NULL".equals (getASDCControllerConfigJsonNode ().get (CONSUMER_GROUP_ATTRIBUTE_NAME).asText ()))) { + throw new ASDCParametersException (CONSUMER_GROUP_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getConsumerID () == null || this.getConsumerID ().isEmpty ()) { + throw new ASDCParametersException (CONSUMER_ID_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getEnvironmentName () == null || this.getEnvironmentName ().isEmpty ()) { + throw new ASDCParametersException (ENVIRONMENT_NAME_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getAsdcAddress () == null || this.getAsdcAddress ().isEmpty ()) { + throw new ASDCParametersException (ASDC_ADDRESS_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getPassword () == null || this.getPassword ().isEmpty ()) { + throw new ASDCParametersException (PASSWORD_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getPollingInterval () == 0) { + throw new ASDCParametersException (POLLING_INTERVAL_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getPollingTimeout () == 0) { + throw new ASDCParametersException (POLLING_TIMEOUT_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getRelevantArtifactTypes () == null || this.getRelevantArtifactTypes ().isEmpty ()) { + throw new ASDCParametersException (RELEVANT_ARTIFACT_TYPES_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getUser () == null || this.getUser ().isEmpty ()) { + throw new ASDCParametersException (USER_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + } + + /** + * This method triggers the MsoPropertiesFactory to get the ASDC config from the cache and extracts all controllers + * defined. + * + * @return A list of controller Names defined in the cache config + * @throws ASDCParametersException In cas of issues with the cache + */ + public static List <String> getAllDefinedControllers () throws ASDCParametersException { + + MsoJsonProperties msoProp; + try { + List <String> result = new ArrayList <String> (); + msoProp = new MsoPropertiesFactory ().getMsoJsonProperties (MSO_PROP_ASDC); + + if (msoProp.getJsonRootNode ().get (PARAMETER_PATTERN) != null) { + Iterator <Entry <String, JsonNode>> it = msoProp.getJsonRootNode () + .get (PARAMETER_PATTERN) + .getFields (); + + Entry <String, JsonNode> entry; + while (it.hasNext ()) { + entry = it.next (); + result.add (entry.getKey ()); + + } + } + return result; + } catch (MsoPropertiesException e) { + throw new ASDCParametersException ("Unable to get the JSON Properties in cache:" + MSO_PROP_ASDC, e); + } + + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java new file mode 100644 index 0000000000..b553100816 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java @@ -0,0 +1,570 @@ +/*- + * ============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.asdc.client; + + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.impl.DistributionClientFactory; +import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.openecomp.sdc.utils.DistributionStatusEnum; +import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException; +import org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.asdc.installer.IVfResourceInstaller; +import org.openecomp.mso.asdc.installer.VfResourceStructure; +import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller; +import org.openecomp.mso.asdc.util.ASDCNotificationLogging; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.utils.UUIDChecker; + +public class ASDCController { + + protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); + + protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + protected boolean isAsdcClientAutoManaged = false; + + protected String controllerName; + + /** + * Inner class for Notification callback + * + * + */ + private final class ASDCNotificationCallBack implements INotificationCallback { + + private ASDCController asdcController; + + ASDCNotificationCallBack (ASDCController controller) { + asdcController = controller; + } + + /** + * This method can be called multiple times at the same moment. + * The controller must be thread safe ! + */ + @Override + public void activateCallback (INotificationData iNotif) { + long startTime = System.currentTimeMillis (); + UUIDChecker.generateUUID (LOGGER); + MsoLogger.setServiceName ("NotificationHandler"); + MsoLogger.setLogContext (iNotif.getDistributionID (), iNotif.getServiceUUID ()); + String event = "Receive a callback notification in ASDC, nb of resources: " + iNotif.getResources ().size (); + LOGGER.debug(event); + asdcController.treatNotification (iNotif); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Completed the treatment of the notification"); + } + } + + // ***** Controller STATUS code + + protected int nbOfNotificationsOngoing = 0; + + public int getNbOfNotificationsOngoing () { + return nbOfNotificationsOngoing; + } + + private ASDCControllerStatus controllerStatus = ASDCControllerStatus.STOPPED; + + protected synchronized final void changeControllerStatus (ASDCControllerStatus newControllerStatus) { + switch (newControllerStatus) { + + case BUSY: + ++this.nbOfNotificationsOngoing; + this.controllerStatus = newControllerStatus; + break; + + case IDLE: + if (this.nbOfNotificationsOngoing > 1) { + --this.nbOfNotificationsOngoing; + } else { + this.nbOfNotificationsOngoing = 0; + this.controllerStatus = newControllerStatus; + } + + break; + default: + this.controllerStatus = newControllerStatus; + break; + + } + } + + public synchronized final ASDCControllerStatus getControllerStatus () { + return this.controllerStatus; + } + + // ***** END of Controller STATUS code + + protected ASDCConfiguration asdcConfig; + private IDistributionClient distributionClient; + private IVfResourceInstaller resourceInstaller; + + public ASDCController (String controllerConfigName) { + isAsdcClientAutoManaged = true; + this.controllerName = controllerConfigName; + this.resourceInstaller = new VfResourceInstaller(); + } + + public ASDCController (String controllerConfigName, IDistributionClient asdcClient, IVfResourceInstaller resourceinstaller) { + + distributionClient = asdcClient; + this.resourceInstaller = resourceinstaller; + this.controllerName = controllerConfigName; + } + + public ASDCController (String controllerConfigName,IDistributionClient asdcClient) { + distributionClient = asdcClient; + this.controllerName = controllerConfigName; + this.resourceInstaller = new VfResourceInstaller(); + } + + /** + * This method refresh the ASDC Controller config and restart the client. + * + * @return true if config has been reloaded, false otherwise + * @throws ASDCControllerException If case of issue with the init or close called during the config reload + * @throws ASDCParametersException If there is an issue with the parameters + * @throws IOException In case of the key file could not be loaded properly + */ + public boolean updateConfigIfNeeded () throws ASDCParametersException, ASDCControllerException, IOException { + LOGGER.debug ("Checking whether ASDC config must be reloaded"); + + try { + if (this.asdcConfig != null && this.asdcConfig.hasASDCConfigChanged ()) { + LOGGER.debug ("ASDC Config must be reloaded"); + this.closeASDC (); + this.asdcConfig.refreshASDCConfig (); + this.initASDC (); + return true; + } else { + LOGGER.debug ("ASDC Config must NOT be reloaded"); + return false; + } + } catch (ASDCParametersException ep) { + // Try to close it at least to make it consistent with the file specified + // We cannot let it run with a different config file, even if it's bad. + // This call could potentially throw a ASDCController exception if the controller is currently BUSY. + this.closeASDC (); + + throw ep; + } + } + + /** + * This method initializes the ASDC Controller and the ASDC Client. + * + * @throws ASDCControllerException It throws an exception if the ASDC Client cannot be instantiated or if an init + * attempt is done when already initialized + * @throws ASDCParametersException If there is an issue with the parameters provided + * @throws IOException In case of issues when trying to load the key file + */ + public void initASDC () throws ASDCControllerException, ASDCParametersException, IOException { + String event = "Initialize the ASDC Controller"; + MsoLogger.setServiceName ("InitASDC"); + LOGGER.debug (event); + if (this.getControllerStatus () != ASDCControllerStatus.STOPPED) { + String endEvent = "The controller is already initialized, call the closeASDC method first"; + throw new ASDCControllerException (endEvent); + } + + if (asdcConfig == null) { + asdcConfig = new ASDCConfiguration (this.controllerName); + + } + // attempt to refresh during init as MsoProperties is may be pointing to an old file + // Be careful this is static in MsoProperties + asdcConfig.refreshASDCConfig (); + + if (this.distributionClient == null) { + distributionClient = DistributionClientFactory.createDistributionClient (); + } + long initStartTime = System.currentTimeMillis (); + IDistributionClientResult result = this.distributionClient.init (asdcConfig, + new ASDCNotificationCallBack (this)); + if (!result.getDistributionActionResult ().equals (DistributionActionResultEnum.SUCCESS)) { + String endEvent = "ASDC distribution client init failed with reason:" + + result.getDistributionMessageResult (); + LOGGER.recordMetricEvent (initStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, "Initialization of the ASDC Controller failed with reason:" + result.getDistributionMessageResult (), "ASDC", "init", null); + LOGGER.debug (endEvent); + asdcConfig = null; + + this.changeControllerStatus (ASDCControllerStatus.STOPPED); + throw new ASDCControllerException ("Initialization of the ASDC Controller failed with reason: " + + result.getDistributionMessageResult ()); + } + LOGGER.recordMetricEvent (initStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully initialize ASDC Controller", "ASDC", "init", null); + + long clientstartStartTime = System.currentTimeMillis (); + result = this.distributionClient.start (); + if (!result.getDistributionActionResult ().equals (DistributionActionResultEnum.SUCCESS)) { + String endEvent = "ASDC distribution client start failed with reason:" + + result.getDistributionMessageResult (); + LOGGER.recordMetricEvent (clientstartStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, endEvent, "ASDC", "start", null); + LOGGER.debug (endEvent); + asdcConfig = null; + this.changeControllerStatus (ASDCControllerStatus.STOPPED); + throw new ASDCControllerException ("Startup of the ASDC Controller failed with reason: " + + result.getDistributionMessageResult ()); + } + LOGGER.recordMetricEvent (clientstartStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully start ASDC distribution client", "ASDC", "start", null); + + + this.changeControllerStatus (ASDCControllerStatus.IDLE); + LOGGER.info (MessageEnum.ASDC_INIT_ASDC_CLIENT_SUC, "ASDC", "changeControllerStatus"); + } + + /** + * This method closes the ASDC Controller and the ASDC Client. + * + * @throws ASDCControllerException It throws an exception if the ASDC Client cannot be closed because + * it's currently BUSY in processing notifications. + */ + public void closeASDC () throws ASDCControllerException { + + MsoLogger.setServiceName ("CloseController"); + if (this.getControllerStatus () == ASDCControllerStatus.BUSY) { + throw new ASDCControllerException ("Cannot close the ASDC controller as it's currently in BUSY state"); + } + if (this.distributionClient != null) { + this.distributionClient.stop (); + // If auto managed we can set it to Null, ASDCController controls it. + // In the other case the client of this class has specified it, so we can't reset it + if (isAsdcClientAutoManaged) { + // Next init will initialize it with a new ASDC Client + this.distributionClient = null; + } + + } + this.changeControllerStatus (ASDCControllerStatus.STOPPED); + } + + private boolean checkResourceAlreadyDeployed (VfResourceStructure vfResource) throws ArtifactInstallerException { + + if (this.resourceInstaller.isResourceAlreadyDeployed (vfResource)) { + LOGGER.info (MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST, + vfResource.getResourceInstance().getResourceInstanceName(), + vfResource.getResourceInstance().getResourceUUID(), + vfResource.getResourceInstance().getResourceName(), "", ""); + + this.sendDeployNotificationsForResource(vfResource,DistributionStatusEnum.ALREADY_DOWNLOADED,null); + this.sendDeployNotificationsForResource(vfResource,DistributionStatusEnum.ALREADY_DEPLOYED,null); + + return true; + } else { + return false; + } + + } + + private final static String UUID_PARAM = "(UUID:"; + + private IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact, + String distributionId) throws ASDCDownloadException { + + LOGGER.debug ("Trying to download the artifact : " + artifact.getArtifactURL () + + UUID_PARAM + + artifact.getArtifactUUID () + + ")"); + IDistributionClientDownloadResult downloadResult; + + + try { + downloadResult = distributionClient.download (artifact); + if (null == downloadResult) { + LOGGER.info (MessageEnum.ASDC_ARTIFACT_NULL, artifact.getArtifactUUID (), "", ""); + return downloadResult; + } + } catch (RuntimeException e) { + LOGGER.debug ("Not able to download the artifact due to an exception: " + artifact.getArtifactURL ()); + this.sendASDCNotification (NotificationType.DOWNLOAD, + artifact.getArtifactURL (), + asdcConfig.getConsumerID (), + distributionId, + DistributionStatusEnum.DOWNLOAD_ERROR, + e.getMessage (), + System.currentTimeMillis ()); + + throw new ASDCDownloadException ("Exception caught when downloading the artifact", e); + } + + if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult ())) { + + LOGGER.info (MessageEnum.ASDC_ARTIFACT_DOWNLOAD_SUC, + artifact.getArtifactURL (), + artifact.getArtifactUUID (), + String.valueOf (downloadResult.getArtifactPayload ().length), "", ""); + + } else { + + LOGGER.error (MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL, + artifact.getArtifactName (), + artifact.getArtifactURL (), + artifact.getArtifactUUID (), + downloadResult.getDistributionMessageResult (), "", "", MsoLogger.ErrorCode.DataError, "ASDC artifact download fail"); + + this.sendASDCNotification (NotificationType.DOWNLOAD, + artifact.getArtifactURL (), + asdcConfig.getConsumerID (), + distributionId, + DistributionStatusEnum.DOWNLOAD_ERROR, + downloadResult.getDistributionMessageResult (), + System.currentTimeMillis ()); + + throw new ASDCDownloadException ("Artifact " + artifact.getArtifactName () + + " could not be downloaded from ASDC URL " + + artifact.getArtifactURL () + + UUID_PARAM + + artifact.getArtifactUUID () + + ")" + + System.lineSeparator () + + "Error message is " + + downloadResult.getDistributionMessageResult () + + System.lineSeparator ()); + + } + + this.sendASDCNotification (NotificationType.DOWNLOAD, + artifact.getArtifactURL (), + asdcConfig.getConsumerID (), + distributionId, + DistributionStatusEnum.DOWNLOAD_OK, + null, + System.currentTimeMillis ()); + return downloadResult; + + } + + + private void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) { + + for (IArtifactInfo artifactInfo : vfResourceStructure.getResourceInstance().getArtifacts()) { + + if (DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) + // This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP + && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null + && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()).getDeployedInDb() == 0) { + this.sendASDCNotification (NotificationType.DEPLOY, + artifactInfo.getArtifactURL (), + asdcConfig.getConsumerID (), + vfResourceStructure.getNotification().getDistributionID(), + DistributionStatusEnum.DEPLOY_ERROR, + "The artifact has not been used by the modules defined in the resource", + System.currentTimeMillis ()); + } else { + this.sendASDCNotification (NotificationType.DEPLOY, + artifactInfo.getArtifactURL (), + asdcConfig.getConsumerID (), + vfResourceStructure.getNotification().getDistributionID(), + distribStatus, + errorReason, + System.currentTimeMillis ()); + } + } + } + + private void deployResourceStructure (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException { + + LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, vfResourceStructure.getResourceInstance().getResourceInstanceName(), vfResourceStructure.getResourceInstance().getResourceUUID(), "ASDC", "deployResourceStructure"); + try { + vfResourceStructure.createVfModuleStructures(); + resourceInstaller.installTheResource (vfResourceStructure); + + } catch (ArtifactInstallerException e) { + + sendDeployNotificationsForResource(vfResourceStructure,DistributionStatusEnum.DEPLOY_ERROR,e.getMessage()); + throw e; + } + + if (vfResourceStructure.isDeployedSuccessfully()) { + LOGGER.info (MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC, + vfResourceStructure.getResourceInstance().getResourceName(), + vfResourceStructure.getResourceInstance().getResourceUUID(), + String.valueOf (vfResourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure"); + sendDeployNotificationsForResource(vfResourceStructure,DistributionStatusEnum.DEPLOY_OK ,null); + } + + } + + private enum NotificationType { + DOWNLOAD, DEPLOY + } + + private void sendASDCNotification (NotificationType notificationType, + String artifactURL, + String consumerID, + String distributionID, + DistributionStatusEnum status, + String errorReason, + long timestamp) { + + String event = "Sending " + notificationType.name () + + "(" + + status.name () + + ")" + + " notification to ASDC for artifact:" + + artifactURL; + + if (errorReason != null) { + event=event+"("+errorReason+")"; + } + LOGGER.info (MessageEnum.ASDC_SEND_NOTIF_ASDC, notificationType.name (), status.name (), artifactURL, "ASDC", "sendASDCNotification"); + LOGGER.debug (event); + + long subStarttime = System.currentTimeMillis (); + String action = ""; + try { + IDistributionStatusMessage message = new DistributionStatusMessage (artifactURL, + consumerID, + distributionID, + status, + timestamp); + + switch (notificationType) { + case DOWNLOAD: + if (errorReason != null) { + this.distributionClient.sendDownloadStatus (message, errorReason); + } else { + this.distributionClient.sendDownloadStatus (message); + } + action = "sendDownloadStatus"; + break; + case DEPLOY: + if (errorReason != null) { + this.distributionClient.sendDeploymentStatus (message, errorReason); + } else { + this.distributionClient.sendDeploymentStatus (message); + } + action = "sendDeploymentdStatus"; + break; + default: + break; + } + } catch (RuntimeException e) { + // TODO: May be a list containing the unsent notification should be + // kept + LOGGER.warn (MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC, "ASDC", "sendASDCNotification", MsoLogger.ErrorCode.SchemaError, "RuntimeException - sendASDCNotification", e); + } + LOGGER.recordMetricEvent (subStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully sent notification to ASDC", "ASDC", action, null); + } + + public void treatNotification (INotificationData iNotif) { + + int noOfArtifacts = 0; + for (IResourceInstance resource : iNotif.getResources ()) { + noOfArtifacts += resource.getArtifacts ().size (); + } + LOGGER.info (MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF, + String.valueOf (noOfArtifacts), + iNotif.getServiceUUID (), "ASDC", "treatNotification"); + + try { + LOGGER.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); + LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, iNotif.getServiceUUID(), "ASDC", "treatNotification"); + this.changeControllerStatus(ASDCControllerStatus.BUSY); + // Process only the Resource artifacts in MSO + for (IResourceInstance resource : iNotif.getResources()) { + + // We process only VNF resource on MSO Side + if ("VF".equals(resource.getResourceType())) { + this.processResourceNotification(iNotif,resource); + } + } + + + + } catch (RuntimeException e) { + LOGGER.error (MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, + "Unexpected exception caught during the notification processing", "ASDC", "treatNotification", MsoLogger.ErrorCode.SchemaError, "RuntimeException in treatNotification", + e); + } finally { + this.changeControllerStatus (ASDCControllerStatus.IDLE); + } + } + + + private void processResourceNotification (INotificationData iNotif,IResourceInstance resource) { + // For each artifact, create a structure describing the VFModule in a ordered flat level + VfResourceStructure vfResourceStructure = new VfResourceStructure(iNotif,resource); + try { + + if (!this.checkResourceAlreadyDeployed(vfResourceStructure)) { + for (IArtifactInfo artifact : resource.getArtifacts()) { + + IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, + iNotif.getDistributionID()); + + if (resultArtifact != null) { + if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) { + LOGGER.debug("VF_MODULE_ARTIFACT: "+new String(resultArtifact.getArtifactPayload(),"UTF-8")); + LOGGER.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(distributionClient.decodeVfModuleArtifact(resultArtifact.getArtifactPayload()))); + } + vfResourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact); + + } + + } + + this.deployResourceStructure(vfResourceStructure); + + } + } catch (ArtifactInstallerException | ASDCDownloadException | UnsupportedEncodingException e) { + LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, + "Exception caught during Installation of artifact", "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e); + } + } + + private static final String UNKNOWN="Unknown"; + + /** + * @return the address of the ASDC we are connected to. + */ + public String getAddress () { + if (asdcConfig != null) { + return asdcConfig.getAsdcAddress (); + } + return UNKNOWN; + } + + /** + * @return the environment name of the ASDC we are connected to. + */ + public String getEnvironment () { + if (asdcConfig != null) { + return asdcConfig.getEnvironmentName (); + } + return UNKNOWN; + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCControllerStatus.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCControllerStatus.java new file mode 100644 index 0000000000..53de5fc5ab --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCControllerStatus.java @@ -0,0 +1,27 @@ +/*- + * ============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.asdc.client; + + + +public enum ASDCControllerStatus { + STOPPED, IDLE, BUSY +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java new file mode 100644 index 0000000000..4e10953efb --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java @@ -0,0 +1,217 @@ +/*- + * ============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.asdc.client; + + + +import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJsonProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + + + +public class ASDCGlobalController { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); + private Map <String,ASDCController> controllers = new HashMap <String,ASDCController> (); + + private MsoJsonProperties msoProp= null; + + private void loadControllers () throws ASDCParametersException { + + List<String> controllerNames = ASDCConfiguration.getAllDefinedControllers(); + + StringBuffer controllerListLog = new StringBuffer("List of controllers loaded:"); + for (String controllerName : controllerNames) { + controllers.put(controllerName, new ASDCController(controllerName)); + controllerListLog.append(controllerName); + controllerListLog.append(";"); + } + LOGGER.debug(controllerListLog.toString()); + } + + private boolean sameControllersDefined() throws ASDCParametersException { + List<String> controllerNames = ASDCConfiguration.getAllDefinedControllers(); + if (controllerNames.size() == controllers.size()) { + boolean areIdentical = true; + + for (String name:controllerNames) { + if (!controllers.containsKey(name)) { + areIdentical = false; + break; + } + } + return areIdentical; + + } else { + return false; + } + } + + /** + * Check that controllers list needs to be updated or not. + * @param return true if the list has been updated + */ + private boolean updateControllersListIfNeeded () { + boolean updateNeeded=false; + try { + + MsoPropertiesFactory msoPropFactory = new MsoPropertiesFactory(); + MsoJsonProperties newMsoProp; + + newMsoProp = msoPropFactory.getMsoJsonProperties(ASDCConfiguration.MSO_PROP_ASDC); + + if (msoPropFactory.propertiesHaveChanged(ASDCConfiguration.MSO_PROP_ASDC, msoProp) && !sameControllersDefined()) { + updateNeeded = true; + LOGGER.debug("List of ASDC controllers has been changed, trying to kill them"); + this.closeASDC(); + + // Wait that all controllers are down before restarting, next pass will kill them all + if (this.controllers.size() == 0) { + msoProp = newMsoProp; + this.loadControllers(); + } + } + + } catch (ASDCParametersException e) { + LOGGER.warn (MessageEnum.ASDC_LOAD_ASDC_CLIENT_EXC, + "All ASDC Hosts", + "All ASDC Envs", "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCParametersException in updateControllersListIfNeeded", + e); + } catch (MsoPropertiesException e) { + LOGGER.warn (MessageEnum.ASDC_LOAD_ASDC_CLIENT_EXC, + "All ASDC Hosts", + "All ASDC Envs", "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "MsoPropertiesException in updateControllersListIfNeeded", + e); + } + return updateNeeded; + + + } + + /** + * Checks for each controller if it is STOPPED and restart if it is the case. + */ + public void checkInStoppedState () { + + for (ASDCController controller : controllers.values()) { + if (ASDCControllerStatus.STOPPED.equals (controller.getControllerStatus ())) { + + // Try to restart just in case of issues + try { + controller.initASDC (); + } catch (ASDCControllerException ec) { + LOGGER.warn (MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCControllerException in checkInStoppedState", + ec); + } catch (ASDCParametersException ep) { + LOGGER.warn (MessageEnum.ASDC_LOAD_ASDC_CLIENT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCParametersException in checkInStoppedState", + ep); + } catch (RuntimeException | IOException e) { + LOGGER.error (MessageEnum.ASDC_SINGLETON_CHECKT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "RuntimeException in checkInStoppedState", + e); + } + } + } + } + + public void closeASDC () { + List<String> controllerToRemove = new LinkedList<String>(); + + for (ASDCController controller : controllers.values()) { + try { + controller.closeASDC (); + controllerToRemove.add(controller.controllerName); + + } catch (RuntimeException e) { + LOGGER.warn (MessageEnum.ASDC_SHUTDOWN_ASDC_CLIENT_EXC, + "RuntimeException", + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "RuntimeException in closeASDC", + e); + } catch (ASDCControllerException e) { + LOGGER.warn (MessageEnum.ASDC_SHUTDOWN_ASDC_CLIENT_EXC, + "ASDCControllerException", + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCControllerException in closeASDC", + e); + } + } + + // Now remove the ones properly closed + for (String toRemove:controllerToRemove) { + controllers.remove(toRemove); + } + + } + + /** + * Check whether the config has been changed + */ + public boolean updateControllersConfigIfNeeded () { + boolean listUpdated=updateControllersListIfNeeded(); + if (!listUpdated) { + + for (ASDCController controller : controllers.values()) { + try { + controller.updateConfigIfNeeded (); + } catch (ASDCControllerException ec) { + LOGGER.warn (MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCControllerException in updateControllersConfigIfNeeded", + ec); + } catch (ASDCParametersException ep) { + LOGGER.warn (MessageEnum.ASDC_LOAD_ASDC_CLIENT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCParametersException in updateControllersConfigIfNeeded", + ep); + } catch (RuntimeException | IOException e) { + LOGGER.error (MessageEnum.ASDC_SINGLETON_CHECKT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "RuntimeException in updateControllersConfigIfNeeded", + e); + } + } + } + return listUpdated; + } + + public Map<String, ASDCController> getControllers() { + return controllers; + } + + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/DistributionStatusMessage.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/DistributionStatusMessage.java new file mode 100644 index 0000000000..dddcaff243 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/DistributionStatusMessage.java @@ -0,0 +1,77 @@ +/*- + * ============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.asdc.client; + + +import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; +import org.openecomp.sdc.utils.DistributionStatusEnum; + +public class DistributionStatusMessage implements IDistributionStatusMessage { + + private String artifactURL; + + private String consumerID; + + private String distributionID; + + private DistributionStatusEnum distributionStatus; + + private long timestamp; + + public DistributionStatusMessage (final String artifactUrl, final String consumerId,final String distributionId, final DistributionStatusEnum distributionStatusEnum, final long timestampL) { + artifactURL = artifactUrl; + consumerID = consumerId; + distributionID = distributionId; + distributionStatus = distributionStatusEnum; + timestamp = timestampL; + } + + @Override + public String getArtifactURL() { + + return artifactURL; + } + + @Override + public String getConsumerID() { + + return consumerID; + } + + @Override + public String getDistributionID() { + + return distributionID; + } + + @Override + public DistributionStatusEnum getStatus() { + + return distributionStatus; + } + + @Override + public long getTimestamp() { + + return timestamp; + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerException.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerException.java new file mode 100644 index 0000000000..72c5a5a4fb --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerException.java @@ -0,0 +1,51 @@ +/*- + * ============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.asdc.client.exceptions; + + +/** + * Exception of the ASDC controller. + */ +public class ASDCControllerException extends Exception { + + /** + * serialization id. + */ + private static final long serialVersionUID = -4236006447255525130L; + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCControllerException (final String message) { + super (message); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCControllerException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadException.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadException.java new file mode 100644 index 0000000000..59d32236ed --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadException.java @@ -0,0 +1,51 @@ +/*- + * ============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.asdc.client.exceptions; + + +/** + * Exception during download from ASDC. + */ +public class ASDCDownloadException extends Exception { + + /** + * serialization id. + */ + private static final long serialVersionUID = -5276848693231134901L; + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCDownloadException (final String message) { + super (message); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCDownloadException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersException.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersException.java new file mode 100644 index 0000000000..fdedd40c04 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersException.java @@ -0,0 +1,51 @@ +/*- + * ============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.asdc.client.exceptions; + + +/** + * Exception of the ASDC controller. + */ +public class ASDCParametersException extends Exception { + + /** + * serialization id. + */ + private static final long serialVersionUID = 8425657297510362736L; + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCParametersException (final String message) { + super (message); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCParametersException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerException.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerException.java new file mode 100644 index 0000000000..af698ad809 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerException.java @@ -0,0 +1,51 @@ +/*- + * ============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.asdc.client.exceptions; + + +/** + * Exception during artifact installation. + */ +public class ArtifactInstallerException extends Exception { + + /** + * serialization id. + */ + private static final long serialVersionUID = 4095937499475915021L; + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ArtifactInstallerException (final String message) { + super (message); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ArtifactInstallerException (final String message, final Throwable cause) { + super (message, cause); + + } +} |