summaryrefslogtreecommitdiffstats
path: root/asdc-controller
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller')
-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