From b6b7bef8bdcad15af01ac88a038dd763ce59f68f Mon Sep 17 00:00:00 2001 From: xg353y Date: Tue, 11 Apr 2017 13:30:42 +0200 Subject: [MSO-8] Update the maven dependency Update the maven depenency for sdc-distribution-client to cooperate with the sdc changes. Change-Id: I2da936e5c40cb68c7181bb78307192dd5655b5dc Signed-off-by: xg353y --- .../mso/asdc/client/ASDCConfiguration.java | 28 +++-- .../openecomp/mso/asdc/client/ASDCController.java | 118 +++++++++++---------- 2 files changed, 80 insertions(+), 66 deletions(-) (limited to 'asdc-controller/src/main/java/org/openecomp/mso/asdc/client') 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 index 1d87ccbe21..61ca698678 100644 --- 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -75,8 +75,8 @@ public class ASDCConfiguration implements IConfiguration { public static final String HEAT_VOL="HEAT_VOL"; public static final String OTHER="OTHER"; public static final String VF_MODULES_METADATA="VF_MODULES_METADATA"; - - + + private static final String[] SUPPORTED_ARTIFACT_TYPES = {HEAT, HEAT_ARTIFACT, HEAT_ENV, @@ -84,10 +84,10 @@ public class ASDCConfiguration implements IConfiguration { HEAT_NET, HEAT_VOL, OTHER, - VF_MODULES_METADATA}; - - public static final List SUPPORTED_ARTIFACT_TYPES_LIST = Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES)); - + VF_MODULES_METADATA}; + + public static final List 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 @@ -97,7 +97,7 @@ public class ASDCConfiguration implements IConfiguration { * @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; @@ -287,7 +287,7 @@ public class ASDCConfiguration implements IConfiguration { return 0; } } - + @Override public boolean activateServerTLSAuth() { JsonNode masterConfigNode = getASDCControllerConfigJsonNode(); @@ -415,4 +415,12 @@ public class ASDCConfiguration implements IConfiguration { } + /** + * 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 index b553100816..a0de24a9cd 100644 --- 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -270,17 +270,17 @@ public class ASDCController { this.changeControllerStatus (ASDCControllerStatus.STOPPED); } - private boolean checkResourceAlreadyDeployed (VfResourceStructure vfResource) throws ArtifactInstallerException { + private boolean checkResourceAlreadyDeployed (VfResourceStructure resource) throws ArtifactInstallerException { - if (this.resourceInstaller.isResourceAlreadyDeployed (vfResource)) { + if (this.resourceInstaller.isResourceAlreadyDeployed (resource)) { LOGGER.info (MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST, - vfResource.getResourceInstance().getResourceInstanceName(), - vfResource.getResourceInstance().getResourceUUID(), - vfResource.getResourceInstance().getResourceName(), "", ""); - - this.sendDeployNotificationsForResource(vfResource,DistributionStatusEnum.ALREADY_DOWNLOADED,null); - this.sendDeployNotificationsForResource(vfResource,DistributionStatusEnum.ALREADY_DEPLOYED,null); - + 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; @@ -289,7 +289,7 @@ public class ASDCController { } private final static String UUID_PARAM = "(UUID:"; - + private IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact, String distributionId) throws ASDCDownloadException { @@ -299,7 +299,7 @@ public class ASDCController { + ")"); IDistributionClientDownloadResult downloadResult; - + try { downloadResult = distributionClient.download (artifact); if (null == downloadResult) { @@ -366,14 +366,14 @@ public class ASDCController { } - + private void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) { - + for (IArtifactInfo artifactInfo : vfResourceStructure.getResourceInstance().getArtifacts()) { - - if (DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) + + if (DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) // This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP - && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null + && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()).getDeployedInDb() == 0) { this.sendASDCNotification (NotificationType.DEPLOY, artifactInfo.getArtifactURL (), @@ -393,26 +393,30 @@ public class ASDCController { } } } - - private void deployResourceStructure (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException { - LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, vfResourceStructure.getResourceInstance().getResourceInstanceName(), vfResourceStructure.getResourceInstance().getResourceUUID(), "ASDC", "deployResourceStructure"); + private void deployResourceStructure (VfResourceStructure resourceStructure) throws ArtifactInstallerException { + + LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, resourceStructure.getResourceInstance().getResourceInstanceName(), resourceStructure.getResourceInstance().getResourceUUID(), "ASDC", "deployResourceStructure"); try { - vfResourceStructure.createVfModuleStructures(); - resourceInstaller.installTheResource (vfResourceStructure); - + String resourceType = resourceStructure.getResourceInstance().getResourceType(); + String category = resourceStructure.getResourceInstance().getCategory(); + if(resourceType.equals("VF") && !category.equalsIgnoreCase("Allotted Resource")){ + resourceStructure.createVfModuleStructures(); + } + resourceInstaller.installTheResource (resourceStructure); + } catch (ArtifactInstallerException e) { - - sendDeployNotificationsForResource(vfResourceStructure,DistributionStatusEnum.DEPLOY_ERROR,e.getMessage()); + + sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.DEPLOY_ERROR,e.getMessage()); throw e; } - if (vfResourceStructure.isDeployedSuccessfully()) { + if (resourceStructure.isDeployedSuccessfully()) { LOGGER.info (MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC, - vfResourceStructure.getResourceInstance().getResourceName(), - vfResourceStructure.getResourceInstance().getResourceUUID(), - String.valueOf (vfResourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure"); - sendDeployNotificationsForResource(vfResourceStructure,DistributionStatusEnum.DEPLOY_OK ,null); + resourceStructure.getResourceInstance().getResourceName(), + resourceStructure.getResourceInstance().getResourceUUID(), + String.valueOf (resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure"); + sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.DEPLOY_OK ,null); } } @@ -428,14 +432,14 @@ public class ASDCController { 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+")"; } @@ -480,7 +484,7 @@ public class ASDCController { } public void treatNotification (INotificationData iNotif) { - + int noOfArtifacts = 0; for (IResourceInstance resource : iNotif.getResources ()) { noOfArtifacts += resource.getArtifacts ().size (); @@ -488,7 +492,7 @@ public class ASDCController { 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"); @@ -496,14 +500,15 @@ public class ASDCController { // Process only the Resource artifacts in MSO for (IResourceInstance resource : iNotif.getResources()) { + // We process only VNF(VF) and Network(VL) resources on MSO Side // We process only VNF resource on MSO Side - if ("VF".equals(resource.getResourceType())) { - this.processResourceNotification(iNotif,resource); + if ("VF".equals(resource.getResourceType()) || "VL".equals(resource.getResourceType())) { + this.processResourceNotification(iNotif,resource); } } - - - + + + } catch (RuntimeException e) { LOGGER.error (MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, "Unexpected exception caught during the notification processing", "ASDC", "treatNotification", MsoLogger.ErrorCode.SchemaError, "RuntimeException in treatNotification", @@ -513,40 +518,41 @@ public class ASDCController { } } - + private void processResourceNotification (INotificationData iNotif,IResourceInstance resource) { // For each artifact, create a structure describing the VFModule in a ordered flat level - VfResourceStructure vfResourceStructure = new VfResourceStructure(iNotif,resource); + VfResourceStructure resourceStructure = new VfResourceStructure(iNotif,resource); + try { - - if (!this.checkResourceAlreadyDeployed(vfResourceStructure)) { + + if (!this.checkResourceAlreadyDeployed(resourceStructure)) { for (IArtifactInfo artifact : resource.getArtifacts()) { - - IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, + + IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, iNotif.getDistributionID()); if (resultArtifact != null) { if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) { LOGGER.debug("VF_MODULE_ARTIFACT: "+new String(resultArtifact.getArtifactPayload(),"UTF-8")); - LOGGER.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(distributionClient.decodeVfModuleArtifact(resultArtifact.getArtifactPayload()))); + LOGGER.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(resourceStructure.decodeVfModuleArtifact(resultArtifact.getArtifactPayload()))); } - vfResourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact); - - } + resourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact); + + } } - - this.deployResourceStructure(vfResourceStructure); - - } + + this.deployResourceStructure(resourceStructure); + + } } catch (ArtifactInstallerException | ASDCDownloadException | UnsupportedEncodingException e) { LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, "Exception caught during Installation of artifact", "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e); } } - + private static final String UNKNOWN="Unknown"; - + /** * @return the address of the ASDC we are connected to. */ -- cgit 1.2.3-korg