diff options
author | 2018-07-30 15:56:09 -0400 | |
---|---|---|
committer | 2018-07-31 11:09:25 -0400 | |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /asdc-controller/src/main/java/org/openecomp/mso/asdc/client | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'asdc-controller/src/main/java/org/openecomp/mso/asdc/client')
19 files changed, 0 insertions, 3042 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 deleted file mode 100644 index 7cc6ab8a89..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java +++ /dev/null @@ -1,508 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.asdc.client.exceptions.ASDCParametersException; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJsonProperties; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.onap.sdc.api.consumer.IConfiguration; - -import com.fasterxml.jackson.databind.JsonNode; - -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; - private String PASSWORD_ATTRIBUTE_NAME; - private String KEY_STORE_PASSWORD; - - public static final String MSO_PROP_ASDC = "MSO_PROP_ASDC"; - public static final String PARAMETER_PATTERN = "asdc-connections"; - public static final String MSG_BUS_ADDRESS_ATTRIBUTE_NAME = "messageBusAddress"; - public static final String COMPONENT_NAMES_ADDRESS_ATTRIBUTE_NAME = "componentNames"; - public static final String WATCHDOG_TIMEOUT_NAME = "watchDogTimeout"; - - 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 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_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 TOSCA_CSAR="TOSCA_CSAR"; - public static final String VF_MODULES_METADATA="VF_MODULES_METADATA"; - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - - private static final String[] SUPPORTED_ARTIFACT_TYPES = {HEAT, - HEAT_ARTIFACT, - HEAT_ENV, - HEAT_NESTED, - HEAT_NET, - HEAT_VOL, - OTHER, - TOSCA_CSAR, - 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 (); - - } - - @Override - public java.lang.Boolean isUseHttpsWithDmaap() { - return false; - } - - @Override - public boolean isConsumeProduceStatusTopic(){ - return true; - } - - @Override - public List<String> getMsgBusAddress(){ - - JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); - if (masterConfigNode != null && masterConfigNode.get (MSG_BUS_ADDRESS_ATTRIBUTE_NAME) != null) { - List<String> msgAddressList = new ArrayList<>(); - - Iterator<JsonNode> config = masterConfigNode.get(MSG_BUS_ADDRESS_ATTRIBUTE_NAME).elements(); - - while( config.hasNext() ) { - String key = (String)config.next().asText(); - msgAddressList.add(key); - } - - if ("NULL".equals (msgAddressList) || msgAddressList.isEmpty ()) { - return null; - } else { - return msgAddressList; - } - } else { - return null; - } - - - } - - 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; - } - } - - public int getWatchDogTimeout () { - JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); - if (masterConfigNode != null && masterConfigNode.get (WATCHDOG_TIMEOUT_NAME) != null) { - - return masterConfigNode.get (WATCHDOG_TIMEOUT_NAME).asInt (); - } else { - return 0; - } - } - - @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 () { - Properties keyProp = new Properties (); - try { - keyProp.load (Thread.currentThread ().getContextClassLoader ().getResourceAsStream ("config-key.properties")); - PASSWORD_ATTRIBUTE_NAME=(String) keyProp.get ("password.attribute.name"); - 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; - } - } catch (IOException e) { - msoLogger.debug("IOException occured", e); - 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() { - Properties keyProp = new Properties (); - try { - keyProp.load (Thread.currentThread ().getContextClassLoader ().getResourceAsStream ("config-key.properties")); - KEY_STORE_PASSWORD=(String) keyProp.get ("key.store.password"); - 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; - } - } catch (IOException e) { - msoLogger.debug("IOException occured", e); - 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.getWatchDogTimeout() == 0) { - throw new ASDCParametersException (WATCHDOG_TIMEOUT_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"); - } - - if (this.getMsgBusAddress() == null || this.getMsgBusAddress().isEmpty ()) { - throw new ASDCParametersException (MSG_BUS_ADDRESS_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<>(); - msoProp = new MsoPropertiesFactory ().getMsoJsonProperties (MSO_PROP_ASDC); - - if (msoProp.getJsonRootNode ().get (PARAMETER_PATTERN) != null) { - Iterator <Entry <String, JsonNode>> it = msoProp.getJsonRootNode () - .get (PARAMETER_PATTERN) - .fields(); - - 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); - } - - } - - /** - * The flag allows the client to receive metadata for all resources of the service regardless of the artifacts associated to them. - * Setting the flag to false will preserve legacy behavior. - */ - public boolean isFilterInEmptyResources() { - return true; - } - -} 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 deleted file mode 100644 index 867efd5840..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java +++ /dev/null @@ -1,915 +0,0 @@ -/*-
-d * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.sdc.api.IDistributionClient;
-import org.onap.sdc.api.consumer.IDistributionStatusMessage;
-import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
-import org.onap.sdc.api.consumer.INotificationCallback;
-import org.onap.sdc.api.consumer.IStatusCallback;
-import org.onap.sdc.api.notification.IArtifactInfo;
-import org.onap.sdc.api.notification.INotificationData;
-import org.onap.sdc.api.notification.IResourceInstance;
-import org.onap.sdc.api.notification.IStatusData;
-import org.onap.sdc.api.results.IDistributionClientDownloadResult;
-import org.onap.sdc.api.results.IDistributionClientResult;
-import org.onap.sdc.impl.DistributionClientFactory;
-import org.onap.sdc.utils.DistributionActionResultEnum;
-import org.onap.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.ToscaResourceStructure;
-import org.openecomp.mso.asdc.installer.VfResourceStructure;
-import org.openecomp.mso.asdc.installer.heat.ToscaResourceInstaller;
-import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller;
-import org.openecomp.mso.asdc.tenantIsolation.DistributionStatus;
-import org.openecomp.mso.asdc.tenantIsolation.WatchdogDistribution;
-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.properties.MsoPropertiesFactory;
-import org.openecomp.mso.requestsdb.WatchdogDistributionStatusDb;
-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;
-
- protected ToscaResourceInstaller toscaInstaller;
-
- private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
-
-
- private final class ResourceInstance implements IResourceInstance {
-
- @Override
- public String getResourceInstanceName(){
- return new String();
- }
-
- @Override
- public String getResourceName(){
- return new String();
- }
-
- @Override
- public String getResourceVersion(){
- return new String();
- }
-
- @Override
- public String getResourceType(){
- return new String();
- }
-
- @Override
- public String getResourceUUID(){
- return new String();
- }
-
- // Method descriptor #10 ()Ljava/util/List;
- @Override
- public java.util.List getArtifacts(){
- return new ArrayList();
- }
-
- @Override
- public String getResourceInvariantUUID(){
- return new String();
- }
-
- @Override
- public String getResourceCustomizationUUID(){
- return new String();
- }
-
- @Override
- public String getCategory(){
- return new String();
- }
-
- @Override
- public String getSubcategory(){
- return new String();
- }
-
- }
-
- private final class ASDCStatusCallBack implements IStatusCallback {
-
- @Override
- public void activateCallback (IStatusData iStatus) {
-
- long startTime = System.currentTimeMillis ();
- UUIDChecker.generateUUID (LOGGER);
- MsoLogger.setServiceName ("ASDCStatusCallBack");
- MsoLogger.setLogContext (iStatus.getDistributionID (), iStatus.getComponentName());
- String event = "Receive a callback componentStatus in ASDC, for componentName: " + iStatus.getComponentName() + " and status of " + iStatus.getStatus() + " distributionID of " + iStatus.getDistributionID() +
- " consumerID of " + iStatus.getConsumerID() + " errorReason of " + iStatus.getErrorReason();
-
- try{
-
- if (iStatus.getStatus() == DistributionStatusEnum.COMPONENT_DONE_OK ||
- iStatus.getStatus() == DistributionStatusEnum.COMPONENT_DONE_ERROR) {
-
- LOGGER.debug(event);
-
- toscaInstaller.installTheComponentStatus(iStatus);
-
- }
-
- }catch(ArtifactInstallerException e){
- System.out.println("Error in ASDCStatusCallback " + e.getMessage());
- LOGGER.debug("Error in ASDCStatusCallback " + e.getMessage());
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Completed the Status Call Back");
- }
-
- }
-
-
- /**
- * 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();
- toscaInstaller = new ToscaResourceInstaller();
- }
-
- 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();
- toscaInstaller = new ToscaResourceInstaller();
- }
-
- /**
- * 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), new ASDCStatusCallBack());
- 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 resource) throws ArtifactInstallerException {
-
-
- if (toscaInstaller.isResourceAlreadyDeployed (resource)) {
- LOGGER.info (MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST,
- resource.getResourceInstance().getResourceInstanceName(),
- resource.getResourceInstance().getResourceUUID(),
- resource.getResourceInstance().getResourceName(), "", "");
-
- this.sendDeployNotificationsForResource(resource,DistributionStatusEnum.ALREADY_DOWNLOADED,null);
- this.sendDeployNotificationsForResource(resource,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 writeArtifactToFile (IArtifactInfo artifact,
- IDistributionClientDownloadResult resultArtifact) throws ASDCDownloadException {
-
- LOGGER.debug ("Trying to download the artifact : " + artifact.getArtifactURL ()
- + UUID_PARAM
- + artifact.getArtifactUUID ()
- + ")");
-
- File spoolFile = new File(System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactName());
-
-
- byte[] payloadBytes = resultArtifact.getArtifactPayload();
-
- try {
- LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***WRITE FILE ARTIFACT NAME", "ASDC", artifact.getArtifactName());
-
- try (FileOutputStream outFile = new FileOutputStream(System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactName())) {
- outFile.write(payloadBytes, 0, payloadBytes.length);
- }
- } catch (Exception e) {
- LOGGER.debug("Exception :",e);
- LOGGER.error(MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL,
- artifact.getArtifactName (),
- artifact.getArtifactURL (),
- artifact.getArtifactUUID (),
- resultArtifact.getDistributionMessageResult (), "", "", MsoLogger.ErrorCode.DataError, "ASDC write to file failed");
- }
-
- }
-
-
- private void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) {
-
- for (IArtifactInfo artifactInfo : vfResourceStructure.getResourceInstance().getArtifacts()) {
-
- if ((DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) && !artifactInfo.getArtifactType().equalsIgnoreCase("OTHER"))
- // 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 sendCsarDeployNotification(INotificationData iNotif, VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
-
- IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact();
-
- if(deploySuccessful){
-
- this.sendASDCNotification (NotificationType.DEPLOY,
- csarArtifact.getArtifactURL (),
- asdcConfig.getConsumerID (),
- resourceStructure.getNotification().getDistributionID(),
- DistributionStatusEnum.DEPLOY_OK,
- errorReason,
- System.currentTimeMillis ());
-
- } else {
-
- this.sendASDCNotification (NotificationType.DEPLOY,
- csarArtifact.getArtifactURL (),
- asdcConfig.getConsumerID (),
- resourceStructure.getNotification().getDistributionID(),
- DistributionStatusEnum.DEPLOY_ERROR,
- errorReason,
- System.currentTimeMillis ());
-
- }
- }
-
- private void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
-
- LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, resourceStructure.getResourceInstance().getResourceInstanceName(), resourceStructure.getResourceInstance().getResourceUUID(), "ASDC", "deployResourceStructure");
- try {
- String resourceType = resourceStructure.getResourceInstance().getResourceType();
- String category = resourceStructure.getResourceInstance().getCategory();
- if("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)){
- resourceStructure.createVfModuleStructures();
- }
-
-
- toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure);
-
-
- } catch (ArtifactInstallerException e) {
- LOGGER.info (MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL,
- resourceStructure.getResourceInstance().getResourceName(),
- resourceStructure.getResourceInstance().getResourceUUID(),
- String.valueOf (resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure");
- sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.DEPLOY_ERROR,e.getMessage());
- throw e;
- }
-
- if (resourceStructure.isDeployedSuccessfully() || toscaResourceStructure.isDeployedSuccessfully()) {
- LOGGER.info (MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC,
- resourceStructure.getResourceInstance().getResourceName(),
- resourceStructure.getResourceInstance().getResourceUUID(),
- String.valueOf (resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure");
- sendDeployNotificationsForResource(resourceStructure,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);
- }
-
- private void sendFinalDistributionStatus (
- String distributionID,
- DistributionStatusEnum status,
- String errorReason) {
-
-
- LOGGER.debug ("Enter sendFinalDistributionStatus with DistributionID " + distributionID + " and Status of " + status.name() + " and ErrorReason " + errorReason);
-
- long subStarttime = System.currentTimeMillis ();
- try {
-
-
- IFinalDistrStatusMessage finalDistribution = new FinalDistributionStatusMessage(distributionID,status,subStarttime, asdcConfig.getConsumerID());
-
- if(errorReason == null){
- this.distributionClient.sendFinalDistrStatus(finalDistribution);
- }else{
- this.distributionClient.sendFinalDistrStatus(finalDistribution, errorReason);
- }
-
-
- } catch (RuntimeException e) {
- // TODO: May be a list containing the unsent notification should be
- // kept
- LOGGER.debug ("Exception caught in sendFinalDistributionStatus " + e.getMessage());
- 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 Final notification to ASDC", "ASDC", null, null);
- }
-
- public void treatNotification (INotificationData iNotif) {
-
- int noOfArtifacts = 0;
- WatchdogDistribution wd = new WatchdogDistribution();
-
- 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(VF), Network(VL) and PNF resources on MSO Side
- //if ("VF".equals(resource.getResourceType()) || "VL".equals(resource.getResourceType()) || "PNF".equals(resource.getResourceType())){
- this.processResourceNotification(iNotif,resource);
- //}
-
- }
-
- //Handle services without any resources
- if (iNotif.getResources() == null || iNotif.getResources().size() < 1){
-
- this.processResourceNotification(iNotif, new ResourceInstance());
- }
-
- //********************************************************************************************************
- //Start Watchdog loop and wait for all components to complete before reporting final status back.
- // **If timer expires first then we will report a Distribution Error back to ASDC
- //********************************************************************************************************
- long initialStartTime = System.currentTimeMillis();
- boolean componentsComplete = false;
- String distributionStatus = null;
- String watchdogError = null;
- String overallStatus = null;
- int watchDogTimeout = asdcConfig.getWatchDogTimeout() * 1000;
- boolean isDeploySuccess = false;
- WatchdogDistributionStatusDb wdDistributionStatus = WatchdogDistributionStatusDb.getInstance();
-
-
- while(componentsComplete == false && (System.currentTimeMillis() - initialStartTime) < watchDogTimeout)
- {
-
- try{
-
- distributionStatus = wd.getOverallDistributionStatus(iNotif.getDistributionID());
- Thread.sleep(watchDogTimeout / 10);
-
- }catch(Exception e){
- LOGGER.debug ("Exception in Watchdog Loop " + e.getMessage());
- Thread.sleep(watchDogTimeout / 10);
- }
-
- if(distributionStatus != null && !distributionStatus.equalsIgnoreCase(DistributionStatus.INCOMPLETE.name())){
-
- if(distributionStatus.equalsIgnoreCase(DistributionStatus.SUCCESS.name())){
- isDeploySuccess = true;
- overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.name();
- }else{
- overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
- }
-
- componentsComplete = true;
- }
- }
-
- if(componentsComplete == false){
- LOGGER.debug("Timeout of " + watchDogTimeout + " seconds was reached before all components reported status");
- watchdogError = "Timeout occurred while waiting for all components to report status";
- overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
- }
-
- if(distributionStatus == null){
- overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
- LOGGER.debug("DistributionStatus is null for DistributionId: " + iNotif.getDistributionID());
-
- }
-
- try {
- wd.executePatchAAI(iNotif.getDistributionID(), iNotif.getServiceInvariantUUID(), overallStatus);
- LOGGER.debug ("A&AI Updated succefully with Distribution Status!");
- }
- catch(Exception e) {
- LOGGER.debug ("Exception in Watchdog executePatchAAI(): " + e.getMessage());
- watchdogError = "Error calling A&AI " + e.getMessage();
- if(e.getCause() != null) {
- LOGGER.debug ("Exception caused by: " + e.getCause().getMessage());
- }
- }
-
-
- if(isDeploySuccess && watchdogError == null){
- sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK, null);
- wdDistributionStatus.updateWatchdogDistributionIdStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.name());
- } else {
- sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, watchdogError);
- wdDistributionStatus.updateWatchdogDistributionIdStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name());
- }
-
-
-
- } catch (Exception e) {
- LOGGER.error (MessageEnum.ASDC_GENERAL_EXCEPTION_ARG,
- "Unexpected exception caught during the notification processing", "ASDC", "treatNotification", MsoLogger.ErrorCode.SchemaError, "RuntimeException in treatNotification",
- e);
-
- sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, e.getMessage());
-
- } 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 resourceStructure = new VfResourceStructure(iNotif,resource);
- ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
- boolean deploySuccessful = true;
- String errorMessage = null;
-
- try {
-
- if (!this.checkResourceAlreadyDeployed(resourceStructure)) {
- 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(resourceStructure.decodeVfModuleArtifact(resultArtifact.getArtifactPayload())));
- }
- resourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact);
-
- }
-
- }
- this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
-
- try{
-
- this.deployResourceStructure(resourceStructure, toscaResourceStructure);
-
- } catch(ArtifactInstallerException e){
- deploySuccessful = false;
- errorMessage = e.getMessage();
- }
-
- this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful, errorMessage);
-
-
-
- }
- } 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 void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
-
- List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
-
- for(IArtifactInfo artifact : serviceArtifacts){
-
- if(artifact.getArtifactType().equals(ASDCConfiguration.TOSCA_CSAR)){
-
- try{
-
- toscaResourceStructure.setToscaArtifact(artifact);
-
- IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,iNotif.getDistributionID());
-
- writeArtifactToFile(artifact, resultArtifact);
-
- toscaResourceStructure.updateResourceStructure(artifact);
-
- toscaResourceStructure.setServiceVersion(iNotif.getServiceVersion());
-
- LOGGER.debug(ASDCNotificationLogging.dumpCSARNotification(iNotif, toscaResourceStructure));
-
-
- } catch(Exception e){
- System.out.println("Whats the error " + e.getMessage());
- LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG,
- "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processCsarServiceArtifacts", 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 deleted file mode 100644 index db83a91b72..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCControllerStatus.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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 deleted file mode 100644 index 430bd10892..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java +++ /dev/null @@ -1,217 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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<>(); - - private MsoJsonProperties msoProp= null; - - private void loadControllers () throws ASDCParametersException { - - List<String> controllerNames = ASDCConfiguration.getAllDefinedControllers(); - - StringBuilder controllerListLog = new StringBuilder("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. - * 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<>(); - - 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 deleted file mode 100644 index 60fa4a9f98..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/DistributionStatusMessage.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.onap.sdc.api.consumer.IDistributionStatusMessage; -import org.onap.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/FinalDistributionStatusMessage.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/FinalDistributionStatusMessage.java deleted file mode 100644 index bf22d7e323..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/FinalDistributionStatusMessage.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.onap.sdc.api.consumer.IFinalDistrStatusMessage; -import org.onap.sdc.utils.DistributionStatusEnum; - -public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage{ - - private String componentName; - - private String consumerID; - - private String distributionID; - - private DistributionStatusEnum status; - - private long timestamp; - - public FinalDistributionStatusMessage (String distributionId, final DistributionStatusEnum distributionStatusEnum, final long timestampL, String consumerId) { - //componentName = componentname; - consumerID = consumerId; - distributionID = distributionId; - status = distributionStatusEnum; - timestamp = timestampL; - } - - public DistributionStatusEnum getStatus() { - return status; - } - - public void setStatus(DistributionStatusEnum status) { - this.status = status; - } - - public String getDistributionID() { - return distributionID; - } - - public void setDistributionID(String distributionID) { - this.distributionID = distributionID; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getComponentName() { - return componentName; - } - - public void setComponentName(String componentName) { - this.componentName = componentName; - } - - public String getConsumerID() { - return consumerID; - } - - public void setConsumerID(String consumerID) { - this.consumerID = consumerID; - } - -} 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 deleted file mode 100644 index e8cb308073..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerException.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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 deleted file mode 100644 index a8a0f150eb..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadException.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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 deleted file mode 100644 index b4bce4ed85..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersException.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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 deleted file mode 100644 index e8a5e81abe..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerException.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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); - - } -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/DistributionClientEmulator.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/DistributionClientEmulator.java deleted file mode 100644 index 426e2353d8..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/DistributionClientEmulator.java +++ /dev/null @@ -1,204 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.emulators; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedList; -import java.util.List; - -import org.apache.commons.io.IOUtils; -import org.openecomp.mso.asdc.installer.IVfModuleData; -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.consumer.IComponentDoneStatusMessage; -import org.onap.sdc.api.consumer.IConfiguration; -import org.onap.sdc.api.consumer.IDistributionStatusMessage; -import org.onap.sdc.api.consumer.IFinalDistrStatusMessage; -import org.onap.sdc.api.consumer.INotificationCallback; -import org.onap.sdc.api.consumer.IStatusCallback; -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.IVfModuleMetadata; -import org.onap.sdc.api.results.IDistributionClientDownloadResult; -import org.onap.sdc.api.results.IDistributionClientResult; -import org.onap.sdc.impl.DistributionClientDownloadResultImpl; -import org.onap.sdc.impl.DistributionClientResultImpl; -import org.onap.sdc.utils.DistributionActionResultEnum; - -public class DistributionClientEmulator implements IDistributionClient { - - private String resourcePath; - - private List<IVfModuleData> listVFModuleMetaData; - - private List<IDistributionStatusMessage> distributionMessageReceived = new LinkedList<>(); - - public DistributionClientEmulator(String notifFolderInResource) { - - resourcePath = notifFolderInResource; - } - - public List<IDistributionStatusMessage> getDistributionMessageReceived() { - return distributionMessageReceived; - } - - @Override - public List<IVfModuleMetadata> decodeVfModuleArtifact(byte[] arg0) { - return null; - } - - /* @Override - public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) { - try { - listVFModuleMetaData = new ObjectMapper().readValue(arg0, new TypeReference<List<JsonVfModuleMetaData>>(){}); - return listVFModuleMetaData; - - } catch (JsonParseException e) { - e.printStackTrace(); - } catch (JsonMappingException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } */ - - public List<IVfModuleData> getListVFModuleMetaData() { - return listVFModuleMetaData; - } - - @Override - public IDistributionClientDownloadResult download (IArtifactInfo arg0) { - - - //String filename = resourcePath+"/artifacts/"+arg0.getArtifactURL(); - String filename = arg0.getArtifactURL(); - System.out.println("Emulating the download from resources files:"+filename); - - InputStream inputStream = null; - - if(arg0.getArtifactName().equals("service_PortMirroringContainer_csar.csar")){ - try{ - inputStream = new FileInputStream("C://Users//JM5423//git//mso//asdc-tosca-1712-test3//openecomp-mso//asdc-controller//src//main//resources//resource-examples//service_PortMirroringContainer_csar.csar"); - }catch(Exception e){ - System.out.println("Error " + e.getMessage()); - } - }else{ - - inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourcePath + filename); - } - - if (inputStream == null) { - System.out.println("InputStream is NULL for:"+filename); - } - try { - return new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name(),arg0.getArtifactName(),IOUtils.toByteArray(inputStream)); - } catch (IOException e) { - - e.printStackTrace(); - } - return null; - } - - @Override - public IConfiguration getConfiguration() { - return null; - } - - @Override - public IDistributionClientResult init(IConfiguration arg0, INotificationCallback arg1) { - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - } - - @Override - public IDistributionClientResult init(IConfiguration arg0, INotificationCallback arg1, IStatusCallback arg2) { - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - } - - @Override - public IDistributionClientResult sendDeploymentStatus(IDistributionStatusMessage arg0) { - this.distributionMessageReceived.add(arg0); - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - } - - @Override - public IDistributionClientResult sendDeploymentStatus(IDistributionStatusMessage arg0, String arg1) { - this.distributionMessageReceived.add(arg0); - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - } - - @Override - public IDistributionClientResult sendDownloadStatus(IDistributionStatusMessage arg0) { - this.distributionMessageReceived.add(arg0); - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - } - - @Override - public IDistributionClientResult sendDownloadStatus(IDistributionStatusMessage arg0, String arg1) { - this.distributionMessageReceived.add(arg0); - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - } - - @Override - public IDistributionClientResult start() { - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - } - - @Override - public IDistributionClientResult stop() { - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - - } - - @Override - public IDistributionClientResult updateConfiguration(IConfiguration arg0) { - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name()); - } - - @Override - public IDistributionClientResult sendComponentDoneStatus( - IComponentDoneStatusMessage arg0) { - // TODO Auto-generated method stub - return null; - } - - @Override - public IDistributionClientResult sendFinalDistrStatus( - IFinalDistrStatusMessage arg0) { - // TODO Auto-generated method stub - return null; - } - - @Override - public IDistributionClientResult sendComponentDoneStatus( - IComponentDoneStatusMessage arg0, String arg1) { - // TODO Auto-generated method stub - return null; - } - - @Override - public IDistributionClientResult sendFinalDistrStatus( - IFinalDistrStatusMessage arg0, String arg1) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonArtifactInfo.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonArtifactInfo.java deleted file mode 100644 index b57792e6d5..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonArtifactInfo.java +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.emulators; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.onap.sdc.api.notification.IArtifactInfo; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; - -public class JsonArtifactInfo implements IArtifactInfo { - - @JsonIgnore - private Map<String,IArtifactInfo> artifactsMapByUUID = new HashMap<>(); - - @JsonIgnore - private Map<String,Object> attributesMap = new HashMap<>(); - - public JsonArtifactInfo() { - - } - - public synchronized void addArtifactToUUIDMap (List<JsonArtifactInfo> artifactList) { - for (JsonArtifactInfo artifact:artifactList) { - artifactsMapByUUID.put(artifact.getArtifactUUID(), artifact); - } - - } - - @SuppressWarnings("unused") - @JsonAnySetter - public final void setAttribute(String attrName, Object attrValue) { - if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) { - this.attributesMap.put(attrName,attrValue); - } - } - - - - public Map<String, IArtifactInfo> getArtifactsMapByUUID() { - return artifactsMapByUUID; - } - - @Override - public String getArtifactChecksum() { - return (String)attributesMap.get("artifactCheckSum"); - } - - @Override - public String getArtifactDescription() { - return (String)attributesMap.get("artifactDescription"); - } - - @Override - public String getArtifactName() { - return (String)attributesMap.get("artifactName"); - } - - @Override - public Integer getArtifactTimeout() { - return (Integer)attributesMap.get("artifactTimeout"); - } - - @Override - public String getArtifactType() { - return (String)attributesMap.get("artifactType"); - } - - @Override - public String getArtifactURL() { - return (String)attributesMap.get("artifactURL"); - } - - @Override - public String getArtifactUUID() { - return (String)attributesMap.get("artifactUUID"); - } - - @Override - public String getArtifactVersion() { - return (String)attributesMap.get("artifactVersion"); - } - - @Override - public IArtifactInfo getGeneratedArtifact () { - return artifactsMapByUUID.get(attributesMap.get("generatedArtifact")); - } - - @Override - public List<IArtifactInfo> getRelatedArtifacts() { - List<IArtifactInfo> listArtifacts = new LinkedList<>(); - List<String> uuidList = (List<String>)attributesMap.get("relatedArtifact"); - if (uuidList != null) { - for(String uuid:uuidList) { - listArtifacts.add(artifactsMapByUUID.get(uuid)); - } - } - return listArtifacts; - } - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonArtifactInfoDeserializer.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonArtifactInfoDeserializer.java deleted file mode 100644 index 66863b562e..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonArtifactInfoDeserializer.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.emulators; - -import java.io.IOException; -import java.util.List; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class JsonArtifactInfoDeserializer extends JsonDeserializer<List<JsonArtifactInfo>>{ - - @Override - public List<JsonArtifactInfo> deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - List<JsonArtifactInfo> jsonArtifactInfoList = new ObjectMapper().readValue(jp, new TypeReference<List<JsonArtifactInfo>>(){}); - - // For each artifact add the list of artifact retrieved - // This could be used later to index by UUID - for (JsonArtifactInfo artifactInfo:jsonArtifactInfoList) { - artifactInfo.addArtifactToUUIDMap(jsonArtifactInfoList); - } - return jsonArtifactInfoList; - } - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonNotificationData.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonNotificationData.java deleted file mode 100644 index 3eddb4a7c5..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonNotificationData.java +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.emulators; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.INotificationData; -import org.onap.sdc.api.notification.IResourceInstance; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - - -public class JsonNotificationData implements INotificationData { - - @JsonIgnore - private static ObjectMapper mapper = new ObjectMapper(); - - @JsonIgnore - private Map<String,Object> attributesMap = new HashMap<>(); - - @JsonProperty("serviceArtifacts") - @JsonDeserialize(using=JsonArtifactInfoDeserializer.class) - private List<IArtifactInfo> serviceArtifacts; - - @JsonProperty("resources") - @JsonDeserialize(using=JsonResourceInfoDeserializer.class) - private List<IResourceInstance> resourcesList; - - public JsonNotificationData() { - - } - - /** - * Method instantiate a INotificationData implementation from a JSON file. - * - * @param notifFilePath The file path in String - * @return A JsonNotificationData instance - * @throws IOException in case of the file is not readable or not accessible - */ - public static JsonNotificationData instantiateNotifFromJsonFile(String notifFilePath) throws IOException { - - InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(notifFilePath + "notif-structure.json"); - - //String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json"; - - //String source = fileLocation; - //InputStream is = IOUtils.toInputStream(source, "UTF-8"); - - //String myString = IOUtils.toString(is, "UTF-8"); - - - //System.out.println(myString); - - if (is == null) { - //throw new FileExistsException("Resource Path does not exist: "+notifFilePath); - } - return mapper.readValue(is, JsonNotificationData.class); - } - - @SuppressWarnings("unused") - @JsonAnySetter - public final void setAttribute(String attrName, Object attrValue) { - if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) { - this.attributesMap.put(attrName,attrValue); - } - } - - @Override - public String getWorkloadContext(){ - return (String)this.attributesMap.get("workloadContext"); - } - - @Override - public void setWorkloadContext(java.lang.String arg0){ - - } - - @Override - public IArtifactInfo getArtifactMetadataByUUID(String arg0) { - return null; - } - - @Override - public String getDistributionID() { - return (String)this.attributesMap.get("distributionID"); - } - - @Override - public List<IResourceInstance> getResources() { - return resourcesList; - } - - @Override - public List<IArtifactInfo> getServiceArtifacts() { - return this.serviceArtifacts; - } - - @Override - public String getServiceDescription() { - return (String)this.attributesMap.get("serviceDescription"); - } - - @Override - public String getServiceInvariantUUID() { - return (String)this.attributesMap.get("serviceInvariantUUID"); - } - - @Override - public String getServiceName() { - return (String)this.attributesMap.get("serviceName"); - } - - @Override - public String getServiceUUID() { - return (String)this.attributesMap.get("serviceUUID"); - } - - @Override - public String getServiceVersion() { - return (String)this.attributesMap.get("serviceVersion"); - } -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfo.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfo.java deleted file mode 100644 index 6f26fd0daa..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfo.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.emulators; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.IResourceInstance; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -public class JsonResourceInfo implements IResourceInstance { - - @JsonIgnore - private Map<String,Object> attributesMap = new HashMap<>(); - - @JsonProperty("artifacts") - @JsonDeserialize(using=JsonArtifactInfoDeserializer.class) - private List<IArtifactInfo> artifacts; - - public JsonResourceInfo() { - - } - - @Override - public List<IArtifactInfo> getArtifacts() { - return artifacts; - } - - @Override - public String getResourceInstanceName() { - return (String)attributesMap.get("resourceInstanceName"); - } - - @Override - public String getResourceInvariantUUID() { - return (String)attributesMap.get("resourceInvariantUUID"); - } - - @Override - public String getResourceCustomizationUUID() { - return (String)attributesMap.get("resourceCustomizationUUID"); - } - - @Override - public String getResourceName() { - return (String)attributesMap.get("resourceName"); - } - - @Override - public String getResourceType() { - return (String)attributesMap.get("resourceType"); - } - - @Override - public String getResourceUUID() { - return (String)attributesMap.get("resourceUUID"); - } - - @Override - public String getResourceVersion() { - return (String)attributesMap.get("resourceVersion"); - } - - @Override - public String getSubcategory() { - return (String)attributesMap.get("subCategory"); - } - - @Override - public String getCategory() { - return (String)attributesMap.get("category"); - } - - @SuppressWarnings("unused") - @JsonAnySetter - public final void setAttribute(String attrName, Object attrValue) { - if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) { - this.attributesMap.put(attrName,attrValue); - } - } -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfoDeserializer.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfoDeserializer.java deleted file mode 100644 index 49908e71a0..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfoDeserializer.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.emulators; - -import java.io.IOException; -import java.util.List; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class JsonResourceInfoDeserializer extends JsonDeserializer<List<JsonResourceInfo>>{ - - @Override - public List<JsonResourceInfo> deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - List<JsonResourceInfo> jsonResourceInfoList = new ObjectMapper().readValue(jp, new TypeReference<List<JsonResourceInfo>>(){}); - - return jsonResourceInfoList; - } - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonStatusData.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonStatusData.java deleted file mode 100644 index 25615b7a33..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonStatusData.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.emulators; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -import org.onap.sdc.api.notification.IStatusData; -import org.onap.sdc.utils.DistributionStatusEnum; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class JsonStatusData implements IStatusData { - - @JsonIgnore - private static ObjectMapper mapper = new ObjectMapper(); - - @JsonIgnore - private Map<String,Object> attributesMap = new HashMap<>(); - - public JsonStatusData() { - - } - - @Override - public String getErrorReason(){ - return "MSO FAILURE"; - } - - @Override - public String getDistributionID(){ - //return (String)this.attributesMap.get("distributionID"); - return "35120a87-1f82-4276-9735-f6de5a244d65"; - } - - @Override - public String getConsumerID(){ - //return (String)this.attributesMap.get("consumerID"); - return "mso.123456"; - } - - @Override - public String getComponentName(){ - //return (String)this.attributesMap.get("componentName"); - return "SDN-C"; - } - - @Override - public Long getTimestamp(){ - //return (String)this.attributesMap.get("timestamp"); - return null; - } - - @Override - public String getArtifactURL(){ - //return (String)this.attributesMap.get("artifactURL"); - return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"; - } - - @Override - public DistributionStatusEnum getStatus(){ - //return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK); - return DistributionStatusEnum.COMPONENT_DONE_OK; - } - - /** - * Method instantiate a INotificationData implementation from a JSON file. - * - * @param notifFilePath The file path in String - * @return A JsonNotificationData instance - * @throws IOException in case of the file is not readable or not accessible - */ - public static JsonStatusData instantiateNotifFromJsonFile(String notifFilePath) throws IOException { - - InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(notifFilePath + "status-structure.json"); - - //String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json"; - - //String source = fileLocation; - //InputStream is = IOUtils.toInputStream(source, "UTF-8"); - - //String myString = IOUtils.toString(is, "UTF-8"); - - - //System.out.println(myString); - - if (is == null) { - //throw new FileExistsException("Resource Path does not exist: "+notifFilePath); - } - return mapper.readValue(is, JsonStatusData.class); - } - - @SuppressWarnings("unused") - @JsonAnySetter - public final void setAttribute(String attrName, Object attrValue) { - if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) { - this.attributesMap.put(attrName,attrValue); - } - } - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonVfModuleMetaData.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonVfModuleMetaData.java deleted file mode 100644 index 765f14f78e..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/emulators/JsonVfModuleMetaData.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.emulators; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.openecomp.mso.asdc.installer.IVfModuleData; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class JsonVfModuleMetaData implements IVfModuleData { - - @JsonProperty("artifacts") - private List<String> artifacts; - @JsonProperty("properties") - //private List<Map<String, Object>> properties = new ArrayList<>(); - private Map<String,String> properties = new HashMap<>(); - - public Map<String, String> getProperties() { - return properties; - } - - @JsonIgnore - private Map<String,Object> attributesMap = new HashMap<>(); - - @Override - public List<String> getArtifacts() { - return artifacts; - } - - @Override - public String getVfModuleModelDescription() { - return (String)attributesMap.get("vfModuleModelDescription"); - } - - @Override - public String getVfModuleModelInvariantUUID() { - return (String)attributesMap.get("vfModuleModelInvariantUUID"); - } - - @Override - public String getVfModuleModelCustomizationUUID() { - return (String)attributesMap.get("vfModuleModelCustomizationUUID"); - } - - @Override - public String getVfModuleModelName() { - return (String)attributesMap.get("vfModuleModelName"); - } - - @Override - public String getVfModuleModelUUID() { - return (String)attributesMap.get("vfModuleModelUUID"); - } - - @Override - public String getVfModuleModelVersion() { - return (String)attributesMap.get("vfModuleModelVersion"); - } - - @Override - public boolean isBase() { - return (boolean)attributesMap.get("isBase"); - } - - @SuppressWarnings("unused") - @JsonAnySetter - public final void setAttribute(String attrName, Object attrValue) { - if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) { - this.attributesMap.put(attrName,attrValue); - } - } - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/rest/ASDCRestInterface.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/rest/ASDCRestInterface.java deleted file mode 100644 index ae434b1d3c..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/test/rest/ASDCRestInterface.java +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.test.rest;
-
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.openecomp.mso.asdc.client.ASDCController;
-import org.openecomp.mso.asdc.client.test.emulators.DistributionClientEmulator;
-import org.openecomp.mso.asdc.client.test.emulators.JsonNotificationData;
-import org.openecomp.mso.asdc.client.test.emulators.JsonStatusData;
-import org.openecomp.mso.asdc.installer.heat.ToscaResourceInstaller;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-/**
- * This is a TEST only rest interface. It is not used in production, it is used to aid in testing the ASDC service on jboss without the need to be connected
- * to the ASDC service broker. It starts the test at the treatNotification step and simulates both the notification step as well as the artifact download step.
- *
- * i.e. http://localhost:8080/asdc/treatNotification/v1
- *
- * i.e. http://localhost:8080/asdc/statusData/v1
- *
- * @author jm5423
- *
- */
-
-@Path("/")
-public class ASDCRestInterface {
-
- private static DistributionClientEmulator distributionClientEmulator;
-
- private static JsonNotificationData notifDataWithoutModuleInfo;
-
- private static JsonStatusData statusData;
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC);
-
- @GET
- @Path("/treatNotification/v1")
- @Produces(MediaType.APPLICATION_JSON)
- public Response invokeASDCService(String request) {
-
- try{
- distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
- notifDataWithoutModuleInfo = JsonNotificationData.instantiateNotifFromJsonFile("resource-examples/");
-
- ASDCController asdcController = new ASDCController("asdc-controller1", distributionClientEmulator);
- LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "initASDC()");
- asdcController.initASDC();
- LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "treatNotification()");
- asdcController.treatNotification(notifDataWithoutModuleInfo);
- LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "closeASDC()");
- asdcController.closeASDC();
- }catch(Exception e){
- System.out.println("Error caught " + e.getMessage());
- LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION,
- "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in invokeASDCService", e);
- }
- System.out.println("ASDC Updates are complete");
- LOGGER.info(MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "ASDC Updates Are Complete");
-
- return null;
- }
-
- @GET
- @Path("/statusData/v1")
- @Produces(MediaType.APPLICATION_JSON)
- public Response invokeASDCStatusData(String request) {
-
- ToscaResourceInstaller toscaInstaller = new ToscaResourceInstaller();
-
- try{
- distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
- statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
-
- ASDCController asdcController = new ASDCController("asdc-controller1", distributionClientEmulator);
- //LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "initASDC()");
- asdcController.initASDC();
- //LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "treatNotification()");
- toscaInstaller.installTheComponentStatus(statusData);
- //asdcController.treatNotification(notifDataWithoutModuleInfo);
- //LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "closeASDC()");
- asdcController.closeASDC();
- }catch(Exception e){
- System.out.println("Error caught " + e.getMessage());
- LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION,
- "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in invokeASDCService", e);
- }
- System.out.println("ASDC Updates are complete");
- LOGGER.info(MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC, statusData.getDistributionID(), "ASDC", "ASDC Updates Are Complete");
-
- return null;
- }
-}
|