aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/main/java/org')
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java28
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java118
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java34
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfModuleData.java54
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleMetaData.java99
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java50
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java118
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java424
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java210
9 files changed, 794 insertions, 341 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
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<String> SUPPORTED_ARTIFACT_TYPES_LIST = Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES));
-
+ 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
@@ -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.
*/
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java
index 5e59be526f..e649a992f8 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.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.
@@ -35,12 +35,12 @@ import org.openecomp.mso.asdc.client.ASDCConfiguration;
* A class representing a generic element whose information can be used for example to log artifacts, resource... data.
*/
public class ASDCElementInfo {
-
+
/**
* A default, empty instance used in case a source element was not correctly provided.
*/
public static final ASDCElementInfo EMPTY_INSTANCE = new ASDCElementInfo();
-
+
/**
* Used to define the other possible ASDC Element types (usually in addition to existing artifact types, etc.).<br/>
* <br/>
@@ -60,17 +60,17 @@ public class ASDCElementInfo {
* The map of element information fields useful for logging. The complete contents of this list will be concatenated.
*/
private final Map<String, String> elementInfoMap = new HashMap<>();
-
+
/**
* The type of this element.
*/
private final String type;
-
+
private ASDCElementInfo () {
// Private parameterless constructor. Not visible, only used for EMPTY_INSTANCE.
this.type = "";
}
-
+
/**
* Artifact-type based constructor. Requires a valid artifact type.
* @param artifactType The artifact type
@@ -79,7 +79,7 @@ public class ASDCElementInfo {
// We need the exact type name here...
this.type = artifactType;
}
-
+
/**
* 'Other element type'-based constructor. Requires a valid element type.
* @param elementType An ASDCElementTypeEnum entry. This will usually contain enumerated types not in the existing
@@ -88,10 +88,10 @@ public class ASDCElementInfo {
// We need the exact type name here...
this.type = elementType.name();
}
-
+
/**
* Add an information entry (name, UUID, etc.) from an artifact/resource/..., once a at time.
- *
+ *
* @param key The key (name) of the information entry (Artifact UUID, Resource Name, etc.)
* @param value The value bound to the information entry.
*/
@@ -100,7 +100,7 @@ public class ASDCElementInfo {
this.getElementInfoMap().put(key, value);
}
}
-
+
/**
* Returns an aggregated, formatted list of the expected details about an ASDC element.
* (non-Javadoc)
@@ -123,7 +123,7 @@ public class ASDCElementInfo {
}
return sb.toString();
}
-
+
/**
* The type that was defined at creation time. This is typically VNF_RESOURCE, VF_MODULE_METADATA, HEAT_ENV, etc.
* @return The type of this element information type. This will usually be either an ArtifactTypeEnum entry name or an ASDCElementTypeEnum entry name.
@@ -150,7 +150,7 @@ public class ASDCElementInfo {
* <li>Resource Instance Name</li>
* <li>Resource Instance UUID</li>
* </ul>
- *
+ *
* @param vfResourceStructure The VfResourceStructure to use as source of information (see {@link VfResourceStructure}).
* @return an ASDCElementInfo using the information held in the VNF Resource.
*/
@@ -173,7 +173,7 @@ public class ASDCElementInfo {
* <li>Module Model Name</li>
* <li>Module Model UUID</li>
* </ul>
- *
+ *
* @param vfModuleStructure The VfModuleStructure to use as source of information (see {@link VfModuleStructure}).
* @return an ASDCElementInfo using the information held in the VF Module.
*/
@@ -182,12 +182,12 @@ public class ASDCElementInfo {
return EMPTY_INSTANCE;
}
ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCConfiguration.VF_MODULES_METADATA);
- IVfModuleMetadata moduleMetadata = vfModuleStructure.getVfModuleMetadata();
+ IVfModuleData moduleMetadata = vfModuleStructure.getVfModuleMetadata();
elementInfo.addElementInfo("Module Model Name", moduleMetadata.getVfModuleModelName());
elementInfo.addElementInfo("Module Model Invariant UUID", moduleMetadata.getVfModuleModelInvariantUUID());
return elementInfo;
}
-
+
/**
* Create an ASDCElementInfo object from an IArtfiactInfo instance.<br/>
* <br/>
@@ -196,7 +196,7 @@ public class ASDCElementInfo {
* <li>IArtifactInfo Name</li>
* <li>IArtifactInfo UUID</li>
* </ul>
- *
+ *
* @param artifactInfo The VfModuleStructure to use as source of information (see {@link IArtifactInfo}).
* @return an ASDCElementInfo using the information held in the IArtifactInfo instance.
*/
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfModuleData.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfModuleData.java
new file mode 100644
index 0000000000..d3aa0411a9
--- /dev/null
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfModuleData.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.asdc.installer;
+
+import java.util.Map;
+
+
+public interface IVfModuleData {
+
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelName();
+
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelInvariantUUID();
+
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelCustomizationUUID();
+
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelVersion();
+
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelUUID();
+
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelDescription();
+
+ // Method descriptor #10 ()Z
+ public abstract boolean isBase();
+
+ // Method descriptor #12 ()Ljava/util/List;
+ // Signature: ()Ljava/util/List<Ljava/lang/String;>;
+ public abstract java.util.List<String> getArtifacts();
+
+ public abstract java.util.Map<String,String> getProperties();
+}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleMetaData.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleMetaData.java
new file mode 100644
index 0000000000..284141b91d
--- /dev/null
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleMetaData.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.asdc.installer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonAnySetter;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import org.openecomp.sdc.api.notification.IVfModuleMetadata;
+
+public class VfModuleMetaData 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<>();
+
+ @JsonIgnore
+ private Map<String,Object> attributesMap = new HashMap<>();
+
+ @Override
+ public List<String> getArtifacts() {
+ return artifacts;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public String getVfModuleModelDescription() {
+ return (String)attributesMap.get("vfModuleModelDescription");
+ }
+
+ @Override
+ public String getVfModuleModelInvariantUUID() {
+ return (String)attributesMap.get("vfModuleModelInvariantUUID");
+ }
+
+ 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/installer/VfModuleStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java
index 239bc8ab99..b1e670883c 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.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.
@@ -31,24 +31,24 @@ import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
import org.openecomp.mso.db.catalog.beans.VfModule;
public final class VfModuleStructure {
-
- private final IVfModuleMetadata vfModuleMetadata;
-
+
+ private final IVfModuleData vfModuleMetadata;
+
private final VfResourceStructure parentVfResource;
-
+
private VfModule catalogVfModule;
/**
* The list of artifact existing in this resource hashed by artifactType.
*/
private final Map<String, List<VfModuleArtifact>> artifactsMap;
-
- public VfModuleStructure(VfResourceStructure vfParentResource,IVfModuleMetadata vfmoduleMetadata) throws ArtifactInstallerException {
-
+
+ public VfModuleStructure(VfResourceStructure vfParentResource,IVfModuleData vfmoduleMetadata) throws ArtifactInstallerException {
+
vfModuleMetadata = vfmoduleMetadata;
parentVfResource = vfParentResource;
-
+
artifactsMap = new HashMap<String, List<VfModuleArtifact>>();
-
+
for (String artifactUUID:this.vfModuleMetadata.getArtifacts()) {
if (vfParentResource.getArtifactsMapByUUID().containsKey(artifactUUID)) {
this.addToStructure(vfParentResource.getArtifactsMapByUUID().get(artifactUUID));
@@ -57,42 +57,42 @@ public final class VfModuleStructure {
}
}
}
-
+
private void addToStructure(VfModuleArtifact vfModuleArtifact) {
-
+
if (artifactsMap.containsKey(vfModuleArtifact.getArtifactInfo().getArtifactType())) {
artifactsMap.get(vfModuleArtifact.getArtifactInfo().getArtifactType()).add(vfModuleArtifact);
-
+
} else {
List<VfModuleArtifact> nestedList = new LinkedList<VfModuleArtifact>();
nestedList.add(vfModuleArtifact);
-
+
artifactsMap.put(vfModuleArtifact.getArtifactInfo().getArtifactType(), nestedList);
}
}
-
+
public List<VfModuleArtifact> getOrderedArtifactList() {
-
+
List <VfModuleArtifact> artifactsList = new LinkedList <VfModuleArtifact>();
-
+
artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT));
artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV));
artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
-
+
for (VfModuleArtifact artifact:(artifactsMap.get(ASDCConfiguration.HEAT_NESTED))) {
artifactsList.add(artifact);
}
-
+
for (VfModuleArtifact artifact:(artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT))) {
artifactsList.add(artifact);
}
-
+
artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
-
+
return null;
}
- public IVfModuleMetadata getVfModuleMetadata() {
+ public IVfModuleData getVfModuleMetadata() {
return vfModuleMetadata;
}
@@ -112,6 +112,6 @@ public final class VfModuleStructure {
public void setCatalogVfModule(VfModule catalogVfModule) {
this.catalogVfModule = catalogVfModule;
}
-
-
+
+
}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java
index 7be5e7010b..d27819bb38 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.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.
@@ -20,13 +20,18 @@
package org.openecomp.mso.asdc.installer;
-
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
import org.openecomp.sdc.api.IDistributionClient;
import org.openecomp.sdc.api.notification.IArtifactInfo;
import org.openecomp.sdc.api.notification.INotificationData;
@@ -35,72 +40,84 @@ import org.openecomp.sdc.api.notification.IVfModuleMetadata;
import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
import org.openecomp.mso.asdc.client.ASDCConfiguration;
import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
+import org.openecomp.mso.db.catalog.beans.ServiceToNetworks;
import org.openecomp.mso.db.catalog.beans.VnfResource;
/**
* This structure exists to avoid having issues if the order of the vfResource/vfmodule artifact is not good (tree structure).
- *
*
*/
public final class VfResourceStructure {
-
+
private boolean isDeployedSuccessfully=false;
/**
- * The Raw notification data.
+ * The Raw notification data.
*/
private final INotificationData notification;
-
+
/**
* The resource we will try to deploy.
*/
private final IResourceInstance resourceInstance;
-
+
/**
* The list of VfModules defined for this resource.
*/
private final List<VfModuleStructure> vfModulesStructureList;
-
+
/**
* The list of VfModulesMetadata defined for this resource.
*/
- private List<IVfModuleMetadata> vfModulesMetadataList;
-
+ private List<IVfModuleData> vfModulesMetadataList;
+
private VnfResource catalogVnfResource;
-
+
+ private NetworkResourceCustomization catalogNetworkResourceCustomization;
+
+ private ServiceToNetworks catalogServiceToNetworks;
+
+ private ServiceToAllottedResources catalogServiceToAllottedResources;
+
+ private AllottedResourceCustomization catalogResourceCustomization;
+
private Service catalogService;
-
+
/**
* The list of artifacts existing in this resource hashed by UUID.
*/
- private final Map<String, VfModuleArtifact> artifactsMapByUUID;
-
-
+ private final Map<String, VfModuleArtifact> artifactsMapByUUID;
+
+
public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) {
notification=notificationdata;
resourceInstance=resourceinstance;
-
+
vfModulesStructureList = new LinkedList<VfModuleStructure>();
artifactsMapByUUID = new HashMap<String, VfModuleArtifact>();
}
-
+
+ //@Override
public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult);
-
+
switch(artifactinfo.getArtifactType()) {
case ASDCConfiguration.HEAT:
case ASDCConfiguration.HEAT_ENV:
case ASDCConfiguration.HEAT_VOL:
case ASDCConfiguration.HEAT_NESTED: // For 1607 only 1 level tree is supported
- case ASDCConfiguration.HEAT_ARTIFACT:
+ case ASDCConfiguration.HEAT_ARTIFACT:
case ASDCConfiguration.HEAT_NET:
case ASDCConfiguration.OTHER:
artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact);
break;
case ASDCConfiguration.VF_MODULES_METADATA:
- vfModulesMetadataList = distributionClient.decodeVfModuleArtifact(clientResult.getArtifactPayload());
+ vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload());
break;
default:
@@ -110,15 +127,15 @@ public final class VfResourceStructure {
}
public void createVfModuleStructures() throws ArtifactInstallerException {
-
+
if (vfModulesMetadataList == null) {
throw new ArtifactInstallerException("VfModule Meta DATA could not be decoded properly or was not present in the notification");
}
- for (IVfModuleMetadata vfModuleMeta:vfModulesMetadataList) {
+ for (IVfModuleData vfModuleMeta:vfModulesMetadataList) {
vfModulesStructureList.add(new VfModuleStructure(this,vfModuleMeta));
}
}
-
+
public INotificationData getNotification() {
return notification;
}
@@ -134,7 +151,7 @@ public final class VfResourceStructure {
public boolean isDeployedSuccessfully() {
return isDeployedSuccessfully;
}
-
+
public void setSuccessfulDeployment() {
isDeployedSuccessfully = true;
}
@@ -155,6 +172,42 @@ public final class VfResourceStructure {
this.catalogVnfResource = catalogVnfResource;
}
+ // Network Only
+ public NetworkResourceCustomization getCatalogNetworkResourceCustomization() {
+ return catalogNetworkResourceCustomization;
+ }
+ // Network Only
+ public void setCatalogNetworkResourceCustomization(NetworkResourceCustomization catalogNetworkResourceCustomization) {
+ this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization;
+ }
+ // Network Only
+ public ServiceToNetworks getCatalogServiceToNetworks() {
+ return catalogServiceToNetworks;
+ }
+ // Network Only
+ public void setCatalogServiceToNetworks(
+ ServiceToNetworks catalogServiceToNetworks) {
+ this.catalogServiceToNetworks = catalogServiceToNetworks;
+ }
+
+ public ServiceToAllottedResources getCatalogServiceToAllottedResources() {
+ return catalogServiceToAllottedResources;
+ }
+
+ public void setCatalogServiceToAllottedResources(
+ ServiceToAllottedResources catalogServiceToAllottedResources) {
+ this.catalogServiceToAllottedResources = catalogServiceToAllottedResources;
+ }
+
+ public AllottedResourceCustomization getCatalogResourceCustomization() {
+ return catalogResourceCustomization;
+ }
+
+ public void setCatalogResourceCustomization(
+ AllottedResourceCustomization catalogResourceCustomization) {
+ this.catalogResourceCustomization = catalogResourceCustomization;
+ }
+
public Service getCatalogService() {
return catalogService;
}
@@ -162,4 +215,19 @@ public final class VfResourceStructure {
public void setCatalogService(Service catalogService) {
this.catalogService = catalogService;
}
+
+ public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) {
+ try {
+ List<IVfModuleData> listVFModuleMetaData = new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>(){});
+ return listVFModuleMetaData;
+
+ } catch (JsonParseException e) {
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java
index 4cef0f1013..114f6f246b 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.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.
@@ -20,15 +20,19 @@
package org.openecomp.mso.asdc.installer.heat;
-
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
-
import org.openecomp.sdc.api.notification.IArtifactInfo;
+
import org.openecomp.mso.asdc.client.ASDCConfiguration;
import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
import org.openecomp.mso.asdc.installer.ASDCElementInfo;
@@ -43,7 +47,11 @@ import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
import org.openecomp.mso.db.catalog.beans.HeatFiles;
import org.openecomp.mso.db.catalog.beans.HeatTemplate;
import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
+import org.openecomp.mso.db.catalog.beans.ServiceToNetworks;
import org.openecomp.mso.db.catalog.beans.VfModule;
import org.openecomp.mso.db.catalog.beans.VnfResource;
import org.openecomp.mso.logger.MessageEnum;
@@ -58,18 +66,26 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
@Override
- public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStructure)
+ public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct)
throws ArtifactInstallerException {
+
+ CatalogDatabase db = new CatalogDatabase();
boolean status = false;
+ VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;
+
+ try {
- try (CatalogDatabase db = new CatalogDatabase()) {
+ String resourceType = vfResourceStruct.getResourceInstance().getResourceType();
+ String category = vfResourceStruct.getResourceInstance().getCategory();
- logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "VNFResource",
+ // Check for duplicate VF Module that is not an Allotted Resource
+ if(resourceType.equals("VF") && !category.equalsIgnoreCase("Allotted Resource")){
+ logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "VNFResource",
VfResourceInstaller.createVNFName(vfResourceStructure),
BigDecimalVersion.castAndCheckNotificationVersionToString(
vfResourceStructure.getNotification().getServiceVersion()), "", "");
- VnfResource vnfResource = db.getVnfResource(
+ VnfResource vnfResource = db.getVnfResource(
VfResourceInstaller.createVNFName(vfResourceStructure),
BigDecimalVersion.castAndCheckNotificationVersionToString(
vfResourceStructure.getNotification().getServiceVersion()));
@@ -79,23 +95,73 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
+ }
+
+ // Check dup for VF Allotted Resource
+ if(resourceType.equals("VF") && category.equalsIgnoreCase("Allotted Resource")){
+ logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "AllottedResource",
+ vfResourceStruct.getResourceInstance().getResourceInstanceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()), "", "");
+
+ List<AllottedResourceCustomization> allottedResources = db.getAllAllottedResourcesByServiceModelUuid(vfResourceStruct.getNotification().getServiceUUID());
+
+ if(allottedResources != null && allottedResources.size() > 0){
+ for(AllottedResourceCustomization allottedResource : allottedResources){
+
+ String existingAllottedResource = allottedResource.getModelCustomizationUuid();
+ String notificationAllottedResource = vfResourceStruct.getResourceInstance().getResourceCustomizationUUID();
+
+ if(existingAllottedResource.equals(notificationAllottedResource)){
+ status=true;
+ break;
+ }
+ }
+
+ }
+ }
+
+ // Check Network for duplicates
+ if(resourceType.equals("VL")){
+ logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "NetworkResource",
+ vfResourceStruct.getResourceInstance().getResourceInstanceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()), "", "");
+
+ List<NetworkResourceCustomization> networkResources = db.getAllNetworksByServiceModelUuid(vfResourceStruct.getNotification().getServiceUUID());
+
+ if(networkResources != null && networkResources.size() > 0){
+ for(NetworkResourceCustomization networkResource : networkResources){
+
+ String existingNetworkResource = networkResource.getModelCustomizationUuid();
+ String notificationNetworkResource = vfResourceStruct.getResourceInstance().getResourceCustomizationUUID();
+
+ if(existingNetworkResource.equals(notificationNetworkResource)){
+ status=true;
+ break;
+ }
+ }
+
+ }
+ }
+
if (status) {
logger.info(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL,
vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
vfResourceStructure.getNotification().getServiceName(),
BigDecimalVersion.castAndCheckNotificationVersionToString(
vfResourceStructure.getNotification().getServiceVersion()),
vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(), "", "");
+ vfResourceStructure.getResourceInstance().getResourceName(),"", "");
} else {
logger.info(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL,
vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
vfResourceStructure.getNotification().getServiceName(),
BigDecimalVersion.castAndCheckNotificationVersionToString(
vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
+ vfResourceStructure.getNotification().getServiceUUID(),
vfResourceStructure.getResourceInstance().getResourceName(),"", "");
}
@@ -108,13 +174,15 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
@Override
- public void installTheResource(VfResourceStructure vfResourceStructure) throws ArtifactInstallerException {
+ public void installTheResource(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
// 1. Add the DB object list (Hashed) to be created from the HashMap
// UUID
// The DB objects will be stored in each VfModuleArtifact objects
// Those objects could be reused by different VfModule
+ VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;
+
for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
@@ -138,26 +206,53 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
}
-
+
// in case of deployment failure, use a string that will represent the type of artifact that failed...
List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
-
+
CatalogDatabase catalogDB = new CatalogDatabase();
// 2. Create the VFModules/VNFResource objects by linking them to the
// objects created before and store them in Resource/module structure
// Opening a DB transaction, starting from here
try {
-
+
VfResourceInstaller.createService(vfResourceStructure);
-
- VfResourceInstaller.createVnfResource(vfResourceStructure);
+
+ String resourceType = vfResourceStructure.getResourceInstance().getResourceType();
+ String resourceCategory = vfResourceStructure.getResourceInstance().getCategory();
+
+ if(resourceType.equals("VF")){
+
+ if(resourceCategory.equalsIgnoreCase("Allotted Resource")){
+ VfResourceInstaller.createAllottedResourceCustomization(vfResourceStructure);
+ catalogDB.saveAllottedResourceCustomization(vfResourceStructure.getCatalogResourceCustomization());
+ } else {
+ VfResourceInstaller.createVnfResource(vfResourceStructure);
+ catalogDB.saveOrUpdateVnfResource(vfResourceStructure.getCatalogVnfResource());
+ }
+ }
+
+ if(resourceType.equals("VL")){
+ VfResourceInstaller.createNetworkResourceCustomization(vfResourceStructure);
+ catalogDB.saveNetworkResourceCustomization(vfResourceStructure.getCatalogNetworkResourceCustomization());
+ }
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure));
-
- catalogDB.saveOrUpdateVnfResource(vfResourceStructure.getCatalogVnfResource());
+
+ //catalogDB.saveOrUpdateVnfResource(vfResourceStructure.getCatalogVnfResource());
catalogDB.saveService(vfResourceStructure.getCatalogService());
-
+
+ // Now that the service has been added we can populate the Service_to_AllottedResources table
+ if(resourceType.equals("VF") && resourceCategory.equalsIgnoreCase("Allotted Resource")){
+ catalogDB.saveServiceToAllottedResources(vfResourceStructure.getCatalogServiceToAllottedResources());
+ }
+
+ // Now that the service has been added we can populate the Service_to_Network table
+ if(resourceType.equals("VL")){
+ catalogDB.saveServiceToNetworks(vfResourceStructure.getCatalogServiceToNetworks());
+ }
+
for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
// Here we set the right db structure according to the Catalog
@@ -170,14 +265,14 @@ public class VfResourceInstaller implements IVfResourceInstaller {
HeatTemplate heatMainTemplate = null;
HeatEnvironment heatEnv = null;
-
+
HeatTemplate heatVolumeTemplate = null;
HeatEnvironment heatVolumeEnv = null;
-
+
if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT)) {
IArtifactInfo mainEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT)
.get(0).getArtifactInfo().getGeneratedArtifact();
-
+
// MAIN HEAT
heatMainTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap()
.get(ASDCConfiguration.HEAT).get(0).getCatalogObject();
@@ -185,77 +280,77 @@ public class VfResourceInstaller implements IVfResourceInstaller {
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo
.createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo()));
-
+
catalogDB.saveHeatTemplate(heatMainTemplate, heatMainTemplate.getParameters());
// Indicate we have deployed it in the DB
vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).incrementDeployedInDB();
-
-
+
+
// VOLUME HEAT
// We expect only one VOL HEAT per VFMODULE
// we can also obtain from it the Env ArtifactInfo, that's why
// we get the Volume IArtifactInfo
-
+
if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_VOL)) {
IArtifactInfo volEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0)
.getArtifactInfo().getGeneratedArtifact();
-
+
heatVolumeTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap()
.get(ASDCConfiguration.HEAT_VOL).get(0).getCatalogObject();
-
+
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()));
catalogDB.saveHeatTemplate(heatVolumeTemplate, heatVolumeTemplate.getParameters());
// Indicate we have deployed it in the DB
vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).incrementDeployedInDB();
-
+
if (volEnvArtifactInfo != null) {
heatVolumeEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID()
.get(volEnvArtifactInfo.getArtifactUUID()).getCatalogObject();
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(volEnvArtifactInfo));
-
+
catalogDB.saveHeatEnvironment(heatVolumeEnv);
// Indicate we have deployed it in the DB
vfResourceStructure.getArtifactsMapByUUID().get(volEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB();
}
-
+
}
-
+
// NESTED HEAT
// Here we expect many HEAT_NESTED template to be there
// check first if we really have nested heat templates
if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_NESTED)) {
for (VfModuleArtifact heatNestedArtifact : vfModuleStructure.getArtifactsMap()
.get(ASDCConfiguration.HEAT_NESTED)) {
-
+
// Check if this nested is well referenced by the MAIN HEAT
String parentArtifactType = VfResourceInstaller.identifyParentOfNestedTemplate(vfModuleStructure,heatNestedArtifact);
HeatTemplate heatNestedTemplate = (HeatTemplate) heatNestedArtifact.getCatalogObject();
-
+
if (parentArtifactType != null) {
-
+
switch (parentArtifactType) {
case ASDCConfiguration.HEAT:
-
+
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
-
+
catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
// Indicate we have deployed it in the DB
heatNestedArtifact.incrementDeployedInDB();
break;
case ASDCConfiguration.HEAT_VOL:
-
+
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
// Indicate we have deployed it in the DB
heatNestedArtifact.incrementDeployedInDB();
break;
-
+
default:
break;
@@ -263,49 +358,49 @@ public class VfResourceInstaller implements IVfResourceInstaller {
} else { // Assume it belongs to HEAT MAIN
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
-
+
catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
// Indicate we have deployed it in the DB
heatNestedArtifact.incrementDeployedInDB();
}
}
}
-
+
if (mainEnvArtifactInfo != null) {
heatEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID()
.get(mainEnvArtifactInfo.getArtifactUUID()).getCatalogObject();
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(mainEnvArtifactInfo));
-
+
catalogDB.saveHeatEnvironment(heatEnv);
// Indicate we have deployed it in the DB
vfResourceStructure.getArtifactsMapByUUID().get(mainEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB();
}
-
+
}
-
-
+
+
// here we expect one VFModule to be there
VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv);
VfModule vfModule = vfModuleStructure.getCatalogVfModule();
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure));
-
+
catalogDB.saveOrUpdateVfModule(vfModule);
// Here we expect many HEAT_TEMPLATE files to be there
if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_ARTIFACT)) {
for (VfModuleArtifact heatArtifact : vfModuleStructure.getArtifactsMap()
.get(ASDCConfiguration.HEAT_ARTIFACT)) {
-
+
HeatFiles heatFile = (HeatFiles) heatArtifact.getCatalogObject();
-
+
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo()));
-
-
+
+
catalogDB.saveVfModuleToHeatFiles (vfModule.getId(), heatFile);
// Indicate we will deploy it in the DB
heatArtifact.incrementDeployedInDB();
@@ -313,10 +408,10 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
}
-
+
catalogDB.commit();
vfResourceStructure.setSuccessfulDeployment();
-
+
} catch (Exception e) {
Throwable dbExceptionToCapture = e;
@@ -329,12 +424,12 @@ public class VfResourceInstaller implements IVfResourceInstaller {
logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED, vfResourceStructure.getResourceInstance().getResourceName(),
vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
} else {
- String endEvent = "Exception caught during installation of the VFResource. Transaction rollback.";
+ String endEvent = "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.";
String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed");
- logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of the VFResource. Transaction rollback", e);
+ logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback", e);
catalogDB.rollback();
throw new ArtifactInstallerException(
- "Exception caught during installation of the VFResource. Transaction rollback.", e);
+ "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
}
} finally {
@@ -344,10 +439,10 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
}
-
+
private static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,VfModuleArtifact heatNestedArtifact) {
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null
+ if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null
&& vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
.getArtifactInfo().getRelatedArtifacts()) {
@@ -356,29 +451,29 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
}
- }
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
+ }
+
+ if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
&& vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
for (IArtifactInfo unknownArtifact:vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts()) {
if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
return ASDCConfiguration.HEAT_VOL;
}
-
+
}
}
-
+
// Does not belong to anything
return null;
-
+
}
-
+
private static void createVnfResource(VfResourceStructure vfResourceStructure) {
VnfResource vnfResource = new VnfResource();
-
+
vnfResource.setAsdcUuid(vfResourceStructure.getResourceInstance().getResourceUUID());
vnfResource.setDescription(vfResourceStructure.getNotification().getServiceDescription());
-
+
vnfResource.setOrchestrationMode("HEAT");
// Set the version but Version is stored into ASDC_SERVICE_MODEL_VERSION
vnfResource.setVersion(BigDecimalVersion
@@ -386,15 +481,59 @@ public class VfResourceInstaller implements IVfResourceInstaller {
vnfResource.setVnfType(VfResourceInstaller.createVNFName(vfResourceStructure));
vnfResource.setModelVersion(BigDecimalVersion
.castAndCheckNotificationVersionToString(vfResourceStructure.getResourceInstance().getResourceVersion()));
-
+
vnfResource.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID());
vnfResource.setModelCustomizationName(vfResourceStructure.getResourceInstance().getResourceInstanceName());
+ vnfResource.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID());
vnfResource.setModelName(vfResourceStructure.getResourceInstance().getResourceName());
vnfResource.setServiceModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID());
-
+ //vnfResource.setCreated(getCurrentTimeStamp());
+
vfResourceStructure.setCatalogVnfResource(vnfResource);
}
+ private static void createNetworkResourceCustomization(VfResourceStructure vfResourceStructure) {
+ NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
+
+ networkResourceCustomization.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID().trim());
+ networkResourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim());
+ networkResourceCustomization.setModelInstanceName(vfResourceStructure.getResourceInstance().getResourceInstanceName().trim());
+ networkResourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim());
+ networkResourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim());
+ networkResourceCustomization.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim());
+ //networkResourceCustomization.setCreated(getCurrentTimeStamp());
+
+ vfResourceStructure.setCatalogNetworkResourceCustomization(networkResourceCustomization);
+
+ ServiceToNetworks serviceNetworks = new ServiceToNetworks();
+ serviceNetworks.setNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid());
+ serviceNetworks.setServiceModelUuid(vfResourceStructure.getNotification().getServiceUUID());
+
+ vfResourceStructure.setCatalogServiceToNetworks(serviceNetworks);
+
+ }
+
+ private static void createAllottedResourceCustomization(VfResourceStructure vfResourceStructure) {
+ AllottedResourceCustomization resourceCustomization = new AllottedResourceCustomization();
+
+ resourceCustomization.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID().trim());
+ resourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim());
+ resourceCustomization.setModelInstanceName(vfResourceStructure.getResourceInstance().getResourceInstanceName().trim());
+ resourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim());
+ resourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim());
+ resourceCustomization.setVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim());
+ //resourceCustomization.setCreated(getCurrentTimeStamp());
+
+ vfResourceStructure.setCatalogResourceCustomization(resourceCustomization);
+
+ ServiceToAllottedResources serviceAllottedResources = new ServiceToAllottedResources();
+ serviceAllottedResources.setArModelCustomizationUuid(resourceCustomization.getModelCustomizationUuid());
+ serviceAllottedResources.setServiceModelUuid(vfResourceStructure.getNotification().getServiceUUID());
+
+ vfResourceStructure.setCatalogServiceToAllottedResources(serviceAllottedResources);
+
+ }
+
private static void createVfModule(VfModuleStructure vfModuleStructure,HeatTemplate heatMain, HeatTemplate heatVolume,HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) {
VfModule vfModule = new VfModule();
vfModule.setType(createVfModuleName(vfModuleStructure));
@@ -407,21 +546,41 @@ public class VfResourceInstaller implements IVfResourceInstaller {
vfModule.setIsBase(0);
}
+ vfModule.setModelCustomizationUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelCustomizationUUID());
vfModule.setModelInvariantUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelInvariantUUID());
vfModule.setModelName(vfModuleStructure.getVfModuleMetadata().getVfModuleModelName());
-
+
vfModule.setVersion(BigDecimalVersion.castAndCheckNotificationVersionToString(vfModuleStructure.getParentVfResource().getNotification().getServiceVersion()));
vfModule.setModelVersion(BigDecimalVersion.castAndCheckNotificationVersionToString(
vfModuleStructure.getVfModuleMetadata().getVfModuleModelVersion()));
-
+
+ Map<String,String> map = vfModuleStructure.getVfModuleMetadata().getProperties();
+
+ if(map != null){
+
+ if(map.get("vf_module_label") != null){
+ vfModule.setLabel(map.get("vf_module_label"));
+ }
+ if(map.get("initial_count") != null && map.get("initial_count").length() > 0){
+ vfModule.setInitialCount(Integer.parseInt(map.get("initial_count")));
+ }
+ if(map.get("min_vf_module_instances") != null && map.get("min_vf_module_instances").length() > 0){
+ vfModule.setMinInstances(Integer.parseInt(map.get("min_vf_module_instances")));
+ }
+ if(map.get("max_vf_module_instances") != null && map.get("max_vf_module_instances").length() > 0){
+ vfModule.setMaxInstances(Integer.parseInt(map.get("max_vf_module_instances")));
+ }
+
+ }
+
vfModuleStructure.setCatalogVfModule(vfModule);
-
+
VfResourceInstaller.createVfModuleLinks(vfModule, vfModuleStructure.getParentVfResource().getCatalogVnfResource(), heatMain,heatVolume, heatEnv,heatVolumeEnv);
}
private static void createVfModuleLinks(VfModule vfModule, VnfResource vnfResource, HeatTemplate heatMain,
HeatTemplate heatVolume, HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) {
-
+
if (heatMain !=null) {
vfModule.setTemplateId(heatMain.getId());
}
@@ -434,7 +593,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
if (heatVolumeEnv != null) {
vfModule.setVolEnvironmentId(heatVolumeEnv.getId());
}
-
+
vfModule.setVnfResourceId(vnfResource.getId());
}
@@ -448,53 +607,53 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
-
+
public static String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure, List<String> listTypes) {
String newFileBody = filebody;
for (VfModuleArtifact moduleArtifact:vfResourceStructure.getArtifactsMapByUUID().values()) {
-
+
if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
-
+
newFileBody = verifyTheFilePrefixInString(newFileBody,moduleArtifact.getArtifactInfo().getArtifactName());
}
}
return newFileBody;
}
-
+
public static String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
-
+
String needlePrefix = "file:///";
String prefixedFilenameToVerify = needlePrefix+filenameToVerify;
-
- if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
- return body;
- }
-
- StringBuffer sb = new StringBuffer(body.length());
-
- int currentIndex = 0;
- int startIndex = 0;
-
- while (currentIndex != -1) {
- startIndex = currentIndex;
- currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
-
- if (currentIndex == -1) {
- break;
- }
-
- // We append from the startIndex up to currentIndex (start of File Name)
- sb.append(body.substring(startIndex, currentIndex));
- sb.append(filenameToVerify);
-
- currentIndex += prefixedFilenameToVerify.length();
- }
-
- sb.append(body.substring(startIndex));
-
+
+ if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
+ return body;
+ }
+
+ StringBuffer sb = new StringBuffer(body.length());
+
+ int currentIndex = 0;
+ int startIndex = 0;
+
+ while (currentIndex != -1) {
+ startIndex = currentIndex;
+ currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
+
+ if (currentIndex == -1) {
+ break;
+ }
+
+ // We append from the startIndex up to currentIndex (start of File Name)
+ sb.append(body.substring(startIndex, currentIndex));
+ sb.append(filenameToVerify);
+
+ currentIndex += prefixedFilenameToVerify.length();
+ }
+
+ sb.append(body.substring(startIndex));
+
return sb.toString();
}
-
+
private static void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
VfModuleArtifact vfModuleArtifact) {
HeatTemplate heatTemplate = new HeatTemplate();
@@ -505,11 +664,11 @@ public class VfResourceInstaller implements IVfResourceInstaller {
// reused
heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
+
List<String> typeList = new ArrayList<String>();
typeList.add(ASDCConfiguration.HEAT_NESTED);
typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
-
+
heatTemplate.setTemplateBody(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList));
heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
@@ -522,6 +681,13 @@ public class VfResourceInstaller implements IVfResourceInstaller {
heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
heatTemplate.setVersion(BigDecimalVersion
.castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+
+ if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
+ heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatTemplate.setArtifactChecksum("MANUAL_RECORD");
+ }
+
Set<HeatTemplateParam> heatParam = VfResourceInstaller
.extractHeatTemplateParameters(vfModuleArtifact.getResult());
heatTemplate.setParameters(heatParam);
@@ -536,11 +702,11 @@ public class VfResourceInstaller implements IVfResourceInstaller {
heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
// TODO Set the label
heatEnvironment.setAsdcLabel("Label");
-
+
List<String> typeList = new ArrayList<String>();
typeList.add(ASDCConfiguration.HEAT);
typeList.add(ASDCConfiguration.HEAT_VOL);
-
+
heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList));
heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
@@ -548,8 +714,14 @@ public class VfResourceInstaller implements IVfResourceInstaller {
.castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure));
+ if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
+ heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else{
+ heatEnvironment.setArtifactChecksum("MANUAL_RECORD");
+ }
+
vfModuleArtifact.setCatalogObject(heatEnvironment);
-
+
}
private static void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
@@ -566,31 +738,45 @@ public class VfResourceInstaller implements IVfResourceInstaller {
.castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
+
+ if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
+ heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatFile.setArtifactChecksum("MANUAL_RECORD");
+ }
+
vfModuleArtifact.setCatalogObject(heatFile);
-
+
}
private static void createService(VfResourceStructure vfResourceStructure) {
-
+
Service service = new Service();
service.setDescription(vfResourceStructure.getNotification().getServiceDescription());
service.setServiceName(vfResourceStructure.getNotification().getServiceName());
service.setServiceNameVersionId(vfResourceStructure.getNotification().getServiceUUID());
service.setVersion(vfResourceStructure.getNotification().getServiceVersion());
service.setModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID());
-
+
vfResourceStructure.setCatalogService(service);
}
-
-
+
+
private static String createVNFName(VfResourceStructure vfResourceStructure) {
return vfResourceStructure.getNotification().getServiceName() + "/" + vfResourceStructure.getResourceInstance().getResourceInstanceName();
}
private static String createVfModuleName(VfModuleStructure vfModuleStructure) {
-
+
return createVNFName(vfModuleStructure.getParentVfResource())+"::"+vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
}
+
+ private static Timestamp getCurrentTimeStamp() {
+
+ return new Timestamp(new Date().getTime());
+ }
+
+
}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java
index 312613d1bc..a355f0547a 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.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.
@@ -22,122 +22,126 @@ package org.openecomp.mso.asdc.util;
import java.util.List;
+import java.util.Map;
import org.openecomp.sdc.api.notification.IArtifactInfo;
import org.openecomp.sdc.api.notification.INotificationData;
import org.openecomp.sdc.api.notification.IResourceInstance;
-import org.openecomp.sdc.api.notification.IVfModuleMetadata;
+
+import org.openecomp.mso.asdc.installer.IVfModuleData;
public class ASDCNotificationLogging {
public static String dumpASDCNotification(INotificationData asdcNotification) {
-
+
if (asdcNotification == null) {
return "NULL";
}
StringBuffer buffer = new StringBuffer("ASDC Notification:");
buffer.append(System.lineSeparator());
-
+
buffer.append("DistributionID:");
buffer.append(testNull(asdcNotification.getDistributionID()));
buffer.append(System.lineSeparator());
-
-
+
+
buffer.append("ServiceName:");
buffer.append(testNull(asdcNotification.getServiceName()));
buffer.append(System.lineSeparator());
-
-
+
+
buffer.append("ServiceVersion:");
buffer.append(testNull(asdcNotification.getServiceVersion()));
buffer.append(System.lineSeparator());
-
-
+
+
buffer.append("ServiceUUID:");
buffer.append(testNull(asdcNotification.getServiceUUID()));
buffer.append(System.lineSeparator());
-
-
+
+
buffer.append("ServiceInvariantUUID:");
buffer.append(testNull(asdcNotification.getServiceInvariantUUID()));
buffer.append(System.lineSeparator());
-
-
+
+
buffer.append("ServiceDescription:");
buffer.append(testNull(asdcNotification.getServiceDescription()));
buffer.append(System.lineSeparator());
-
-
+
+
buffer.append("Service Artifacts List:");
buffer.append(System.lineSeparator());
buffer.append(testNull(dumpArtifactInfoList(asdcNotification.getServiceArtifacts())));
buffer.append(System.lineSeparator());
-
+
buffer.append("Resource Instances List:");
buffer.append(System.lineSeparator());
buffer.append(testNull(dumpASDCResourcesList(asdcNotification)));
buffer.append(System.lineSeparator());
-
-
+
+
return buffer.toString();
}
-
- public static String dumpVfModuleMetaDataList(List<IVfModuleMetadata> moduleMetaDataList) {
+
+ public static String dumpVfModuleMetaDataList(List<IVfModuleData> moduleMetaDataList) {
if (moduleMetaDataList == null ) {
return null;
}
-
- StringBuffer buffer = new StringBuffer();
+
+ StringBuffer buffer = new StringBuffer("VfModuleMetaData List:");
+ buffer.append(System.lineSeparator());
+
buffer.append("{");
-
- for (IVfModuleMetadata moduleMetaData:moduleMetaDataList) {
+
+ for (IVfModuleData moduleMetaData:moduleMetaDataList) {
buffer.append(System.lineSeparator());
buffer.append(testNull(dumpVfModuleMetaData(moduleMetaData)));
buffer.append(System.lineSeparator());
buffer.append(",");
-
+
}
buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
buffer.append("}");
buffer.append(System.lineSeparator());
-
+
return buffer.toString();
}
-
- private static String dumpVfModuleMetaData(IVfModuleMetadata moduleMetaData) {
-
+
+ private static String dumpVfModuleMetaData(IVfModuleData moduleMetaData) {
+
if (moduleMetaData == null ) {
return "NULL";
}
-
+
StringBuffer buffer = new StringBuffer("VfModuleMetaData:");
buffer.append(System.lineSeparator());
-
+
buffer.append("VfModuleModelName:");
buffer.append(testNull(moduleMetaData.getVfModuleModelName()));
buffer.append(System.lineSeparator());
-
+
buffer.append("VfModuleModelVersion:");
buffer.append(testNull(moduleMetaData.getVfModuleModelVersion()));
buffer.append(System.lineSeparator());
-
+
buffer.append("VfModuleModelUUID:");
buffer.append(testNull(moduleMetaData.getVfModuleModelUUID()));
buffer.append(System.lineSeparator());
-
+
buffer.append("VfModuleModelInvariantUUID:");
buffer.append(testNull(moduleMetaData.getVfModuleModelInvariantUUID()));
buffer.append(System.lineSeparator());
-
+
buffer.append("VfModuleModelDescription:");
buffer.append(testNull(moduleMetaData.getVfModuleModelDescription()));
buffer.append(System.lineSeparator());
-
+
buffer.append("Artifacts UUID List:");
-
+
if (moduleMetaData.getArtifacts() != null) {
buffer.append("{");
-
+
for (String artifactUUID:moduleMetaData.getArtifacts()) {
buffer.append(System.lineSeparator());
buffer.append(testNull(artifactUUID));
@@ -150,17 +154,33 @@ public class ASDCNotificationLogging {
} else {
buffer.append("NULL");
}
-
-
+
+ if (moduleMetaData.getProperties() != null) {
+ Map<String, String> vfModuleMap = moduleMetaData.getProperties();
+ buffer.append("Properties List:");
+ buffer.append("{");
+
+ for (Map.Entry<String, String> entry : vfModuleMap.entrySet()) {
+ buffer.append(System.lineSeparator());
+ buffer.append(" " + entry.getKey() + " : " + entry.getValue());
+ }
+ buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
+ buffer.append("}");
+ buffer.append(System.lineSeparator());
+ } else {
+ buffer.append("NULL");
+ }
+
+
buffer.append(System.lineSeparator());
-
+
buffer.append("isBase:");
buffer.append(moduleMetaData.isBase());
buffer.append(System.lineSeparator());
-
+
return buffer.toString();
}
-
+
private static String testNull(Object object) {
if (object == null) {
return "NULL";
@@ -172,15 +192,15 @@ public class ASDCNotificationLogging {
return "Type not recognized";
}
}
-
+
private static String dumpASDCResourcesList(INotificationData asdcNotification) {
if (asdcNotification == null || asdcNotification.getResources() == null) {
return null;
}
-
- StringBuffer buffer = new StringBuffer();
+
+ StringBuffer buffer = new StringBuffer();
buffer.append("{");
-
+
for (IResourceInstance resourceInstanceElem:asdcNotification.getResources()) {
buffer.append(System.lineSeparator());
buffer.append(testNull(dumpASDCResourceInstance(resourceInstanceElem)));
@@ -190,136 +210,148 @@ public class ASDCNotificationLogging {
buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
buffer.append("}");
buffer.append(System.lineSeparator());
-
+
return buffer.toString();
-
+
}
-
+
private static String dumpASDCResourceInstance(IResourceInstance resourceInstance) {
-
+
if (resourceInstance == null) {
return null;
}
-
+
StringBuffer buffer = new StringBuffer("Resource Instance Info:");
buffer.append(System.lineSeparator());
-
+
buffer.append("ResourceInstanceName:");
buffer.append(testNull(resourceInstance.getResourceInstanceName()));
buffer.append(System.lineSeparator());
-
+
+ buffer.append("ResourceCustomizationUUID:");
+ buffer.append(testNull(resourceInstance.getResourceCustomizationUUID()));
+ buffer.append(System.lineSeparator());
+
buffer.append("ResourceInvariantUUID:");
buffer.append(testNull(resourceInstance.getResourceInvariantUUID()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ResourceName:");
buffer.append(testNull(resourceInstance.getResourceName()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ResourceType:");
buffer.append(testNull(resourceInstance.getResourceType()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ResourceUUID:");
buffer.append(testNull(resourceInstance.getResourceUUID()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ResourceVersion:");
buffer.append(testNull(resourceInstance.getResourceVersion()));
buffer.append(System.lineSeparator());
-
+
+ buffer.append("Category:");
+ buffer.append(testNull(resourceInstance.getCategory()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("SubCategory:");
+ buffer.append(testNull(resourceInstance.getSubcategory()));
+ buffer.append(System.lineSeparator());
+
buffer.append("Resource Artifacts List:");
buffer.append(System.lineSeparator());
buffer.append(testNull(dumpArtifactInfoList(resourceInstance.getArtifacts())));
buffer.append(System.lineSeparator());
-
+
return buffer.toString();
-
+
}
-
-
+
+
private static String dumpArtifactInfoList(List<IArtifactInfo> artifactsList) {
-
+
if (artifactsList == null || artifactsList.isEmpty()) {
return null;
}
-
- StringBuffer buffer = new StringBuffer();
+
+ StringBuffer buffer = new StringBuffer();
buffer.append("{");
for (IArtifactInfo artifactInfoElem:artifactsList) {
buffer.append(System.lineSeparator());
buffer.append(testNull(dumpASDCArtifactInfo(artifactInfoElem)));
buffer.append(System.lineSeparator());
buffer.append(",");
-
+
}
buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
buffer.append("}");
buffer.append(System.lineSeparator());
-
+
return buffer.toString();
}
-
+
private static String dumpASDCArtifactInfo(IArtifactInfo artifactInfo) {
-
+
if (artifactInfo == null) {
return null;
}
-
+
StringBuffer buffer = new StringBuffer("Service Artifacts Info:");
buffer.append(System.lineSeparator());
-
+
buffer.append("ArtifactName:");
buffer.append(testNull(artifactInfo.getArtifactName()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ArtifactVersion:");
buffer.append(testNull(artifactInfo.getArtifactVersion()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ArtifactType:");
buffer.append(testNull(artifactInfo.getArtifactType()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ArtifactDescription:");
buffer.append(testNull(artifactInfo.getArtifactDescription()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ArtifactTimeout:");
buffer.append(testNull(artifactInfo.getArtifactTimeout()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ArtifactURL:");
buffer.append(testNull(artifactInfo.getArtifactURL()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ArtifactUUID:");
buffer.append(testNull(artifactInfo.getArtifactUUID()));
buffer.append(System.lineSeparator());
-
+
buffer.append("ArtifactChecksum:");
buffer.append(testNull(artifactInfo.getArtifactChecksum()));
buffer.append(System.lineSeparator());
-
+
buffer.append("GeneratedArtifact:");
buffer.append("{");
buffer.append(testNull(dumpASDCArtifactInfo(artifactInfo.getGeneratedArtifact())));
buffer.append(System.lineSeparator());
buffer.append("}");
buffer.append(System.lineSeparator());
-
+
buffer.append("RelatedArtifacts:");
-
-
+
+
if (artifactInfo.getRelatedArtifacts() != null) {
buffer.append("{");
buffer.append(System.lineSeparator());
for (IArtifactInfo artifactInfoElem:artifactInfo.getRelatedArtifacts()) {
-
+
buffer.append(testNull(dumpASDCArtifactInfo(artifactInfoElem)));
buffer.append(System.lineSeparator());
buffer.append(",");
-
+
}
buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
buffer.append("}");
@@ -327,9 +359,9 @@ public class ASDCNotificationLogging {
} else {
buffer.append("NULL");
}
-
+
buffer.append(System.lineSeparator());
-
+
return buffer.toString();
}
}