aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-10 13:47:15 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-10 13:53:45 -0400
commitae01b62624eb897ee1d556110bf2dd189335abc0 (patch)
treefb324aa9a547a15b5ed8ac0f805a4a5585b72514
parent45a9add1e79bad75405e5b93d614201ceabdd0d6 (diff)
Added isAlreadyDeployed check at the Service level.
- Committed changes for tabs verse spaces. - Added isAlreadyDeployed check at the Service level. Change-Id: I1f735830820f84745ed1fb9f5a9e76146ee23d3b Issue-ID: SO-1764 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java52
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java7
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java6
3 files changed, 51 insertions, 14 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index 92326b1907..57e9c173b9 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -1,5 +1,5 @@
/*-
-d * ============LICENSE_START=======================================================
+ * ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
@@ -250,9 +250,11 @@ public class ASDCController {
this.changeControllerStatus(ASDCControllerStatus.STOPPED);
}
- private boolean checkResourceAlreadyDeployed(VfResourceStructure resource) throws ArtifactInstallerException {
+ protected boolean checkResourceAlreadyDeployed(ResourceStructure resource, boolean serviceDeployed)
+ throws ArtifactInstallerException {
- if (toscaInstaller.isResourceAlreadyDeployed(resource)) {
+
+ if (toscaInstaller.isResourceAlreadyDeployed(resource, serviceDeployed)) {
logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(),
resource.getResourceInstance().getResourceInstanceName(),
resource.getResourceInstance().getResourceUUID(), resource.getResourceInstance().getResourceName());
@@ -656,6 +658,7 @@ public class ASDCController {
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath);
boolean deploySuccessful = true;
String errorMessage = null;
+ boolean serviceDeployed = false;
try {
this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
@@ -686,12 +689,45 @@ public class ASDCController {
resourceStructure.setResourceType(ResourceType.OTHER);
}
- for (IArtifactInfo artifact : resource.getArtifacts()) {
- IDistributionClientDownloadResult resultArtifact =
- this.downloadTheArtifact(artifact, iNotif.getDistributionID());
- if (resultArtifact != null) {
- resourceStructure.addArtifactToStructure(distributionClient, artifact, resultArtifact);
+ try {
+
+ if (!this.checkResourceAlreadyDeployed(resourceStructure, serviceDeployed)) {
+
+ logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: "
+ + resourceStructure.getResourceInstance().getResourceUUID());
+
+ if ("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)) {
+
+ 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(((VfResourceStructure) resourceStructure)
+ .decodeVfModuleArtifact(resultArtifact.getArtifactPayload())));
+ }
+ resourceStructure.addArtifactToStructure(distributionClient, artifact,
+ resultArtifact);
+ }
+ }
+
+ // Deploy VF resource and artifacts
+ logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID());
+
+
+ this.deployResourceStructure(resourceStructure, toscaResourceStructure);
+ serviceDeployed = true;
+ }
}
+
+ } catch (ArtifactInstallerException e) {
+ deploySuccessful = false;
+ errorMessage = e.getMessage();
+ logger.error("Exception occurred", e);
}
// Deploy VF resource and artifacts
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 0e30b77b01..e61aafac2e 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -249,9 +249,10 @@ public class ToscaResourceInstaller {
protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
- public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
+ public boolean isResourceAlreadyDeployed(ResourceStructure vfResourceStruct, boolean serviceDeployed)
+ throws ArtifactInstallerException {
boolean status = false;
- VfResourceStructure vfResourceStructure = vfResourceStruct;
+ ResourceStructure vfResourceStructure = vfResourceStruct;
try {
status = vfResourceStructure.isDeployedSuccessfully();
} catch (RuntimeException e) {
@@ -260,7 +261,7 @@ public class ToscaResourceInstaller {
try {
Service existingService =
serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
- if (existingService != null)
+ if (existingService != null && serviceDeployed == false)
status = true;
if (status) {
logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index 99833da3a3..d3c0bdef66 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -131,7 +131,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
doReturn("resourceName").when(resourceInstance).getResourceName();
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure, false);
WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(
watchdogCDStatusRepository.findByDistributionId(notificationData.getDistributionID()), MSO);
@@ -156,7 +156,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
doReturn("resourceName").when(resourceInstance).getResourceName();
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure, false);
verify(vfResourceStructure, times(3)).getResourceInstance();
verify(vfResourceStructure, times(4)).getNotification();
@@ -166,7 +166,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
public void isResourceAlreadyDeployedExceptionTest() throws ArtifactInstallerException {
expectedException.expect(ArtifactInstallerException.class);
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure, false);
}
@Test