* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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.
try {
- if (iStatus.getStatus() != null) {
- if (iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK)
- || iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) {
- WatchdogDistributionStatus watchdogDistributionStatus = watchdogDistributionStatusRepository
- .findById(iStatus.getDistributionID()).orElseGet(() -> null);
- if (watchdogDistributionStatus == null) {
- watchdogDistributionStatus = new WatchdogDistributionStatus();
- watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID());
- watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
- }
- logger.debug(event);
- toscaInstaller.installTheComponentStatus(iStatus);
-
- }
+ if (iStatus.getStatus() == null) {
+ logger.info("Missing status on Status Object. ");
+ return;
+ }
+ if (!iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK)
+ && !iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) {
+ logger.info("Status is not 'Component Done OK' or 'Component Done Error'");
+ return;
}
+ WatchdogDistributionStatus watchdogDistributionStatus =
+ watchdogDistributionStatusRepository.findById(iStatus.getDistributionID()).orElseGet(() -> null);
+ if (watchdogDistributionStatus == null) {
+ watchdogDistributionStatus = new WatchdogDistributionStatus();
+ watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID());
+ watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
+ }
+ logger.debug(event);
+ toscaInstaller.installTheComponentStatus(iStatus);
+
} catch (ArtifactInstallerException e) {
logger.error("Error in ASDCStatusCallback {}", e.getMessage(), e);
logger.debug("Error in ASDCStatusCallback {}", e.getMessage());
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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.
public FinalDistributionStatusMessage(String distributionId, final DistributionStatusEnum distributionStatusEnum,
final long timestampL, String consumerId) {
- // componentName = componentname;
consumerID = consumerId;
distributionID = distributionId;
status = distributionStatusEnum;
this.timestamp = timestamp;
}
+ @Override
public String getComponentName() {
return componentName;
}
this.componentName = componentName;
}
+ @Override
public String getConsumerID() {
return consumerID;
}
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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.
@Override
public String getDistributionID() {
- // return (String)this.attributesMap.get("distributionID");
return "35120a87-1f82-4276-9735-f6de5a244d65";
}
@Override
public String getConsumerID() {
- // return (String)this.attributesMap.get("consumerID");
return "mso.123456";
}
@Override
public String getComponentName() {
- // return (String)this.attributesMap.get("componentName");
return "SDN-C";
}
@Override
public Long getTimestamp() {
- // return (String)this.attributesMap.get("timestamp");
return null;
}
@Override
public String getArtifactURL() {
- // return (String)this.attributesMap.get("artifactURL");
return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml";
}
@Override
public DistributionStatusEnum getStatus() {
- // return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK);
return DistributionStatusEnum.COMPONENT_DONE_OK;
}
/**
* Method instantiate a INotificationData implementation from a JSON file.
- *
+ *
* @param notifFilePath The file path in String
* @return A JsonNotificationData instance
* @throws IOException in case of the file is not readable or not accessible
InputStream is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(notifFilePath + "status-structure.json");
- // String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json";
-
- // String source = fileLocation;
- // InputStream is = IOUtils.toInputStream(source, "UTF-8");
-
- // String myString = IOUtils.toString(is, "UTF-8");
-
-
- // System.out.println(myString);
-
- if (is == null) {
- // throw new FileExistsException("Resource Path does not exist: "+notifFilePath);
- }
return mapper.readValue(is, JsonStatusData.class);
}
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import org.onap.sdc.api.notification.IVfModuleMetadata;
-import org.onap.so.asdc.client.ASDCConfiguration;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.db.catalog.beans.VfModule;
}
}
- public List<VfModuleArtifact> getOrderedArtifactList() {
-
- List<VfModuleArtifact> artifactsList = new LinkedList<>();
-
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT));
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV));
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
-
- artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED)));
-
- artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT)));
-
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
-
- return null;
- }
-
public IVfModuleData getVfModuleMetadata() {
return vfModuleMetadata;
}
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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
private Service catalogService;
- public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) {
- super(notificationdata, resourceinstance);
+ public VfResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) {
+ super(notificationData, resourceInstance);
this.resourceType = ResourceType.VF_RESOURCE;
vfModulesStructureList = new LinkedList<>();
vfModulesMetadataList = new ArrayList<>();
}
- public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
+ public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactInfo,
IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
- this.addArtifactToStructure(distributionClient, artifactinfo, clientResult, null);
+ this.addArtifactToStructure(artifactInfo, clientResult, null);
}
- public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
- IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate)
- throws UnsupportedEncodingException {
- VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo, clientResult, modifiedHeatTemplate);
- addArtifactByType(artifactinfo, clientResult, vfModuleArtifact);
- if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactinfo.getArtifactType())) {
+ public void addArtifactToStructure(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult,
+ String modifiedHeatTemplate) throws UnsupportedEncodingException {
+ VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactInfo, clientResult, modifiedHeatTemplate);
+ addArtifactByType(artifactInfo, clientResult, vfModuleArtifact);
+ if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactInfo.getArtifactType())) {
logger.debug("VF_MODULE_ARTIFACT: " + new String(clientResult.getArtifactPayload(), "UTF-8"));
logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(vfModulesMetadataList));
}
}
- public void addWorkflowArtifactToStructure(IArtifactInfo artifactinfo,
+ public void addWorkflowArtifactToStructure(IArtifactInfo artifactInfo,
IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
- WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactinfo, clientResult);
- workflowArtifactsMapByUUID.put(artifactinfo.getArtifactUUID(), workflowArtifact);
+ WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactInfo, clientResult);
+ workflowArtifactsMapByUUID.put(artifactInfo.getArtifactUUID(), workflowArtifact);
}
- protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult,
+ protected void addArtifactByType(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult,
VfModuleArtifact vfModuleArtifact) {
- switch (artifactinfo.getArtifactType()) {
+ switch (artifactInfo.getArtifactType()) {
case ASDCConfiguration.HEAT:
case ASDCConfiguration.HEAT_ENV:
case ASDCConfiguration.HEAT_VOL:
case ASDCConfiguration.HEAT_NET:
case ASDCConfiguration.OTHER:
case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT:
- artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact);
+ artifactsMapByUUID.put(artifactInfo.getArtifactUUID(), vfModuleArtifact);
break;
case ASDCConfiguration.VF_MODULES_METADATA:
vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload());
public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) {
try {
- List<IVfModuleData> listVFModuleMetaData =
- new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {});
- return listVFModuleMetaData;
+ return new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {});
} catch (JsonParseException e) {
logger.debug("JsonParseException : ", e);
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), csarFilePath,
ex.getMessage(), ErrorCode.DataError.getValue(), "ASDC reading CSAR with workflows failed");
}
- return;
}
public boolean containsWorkflows(String csarFilePath) {
- boolean workflowsInCsar = false;
try (ZipFile zipFile = new ZipFile(csarFilePath)) {
Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
while (zipEntries.hasMoreElements()) {
String fileName = zipEntries.nextElement().getName();
if (fileName.endsWith(BPMN_SUFFIX)) {
- workflowsInCsar = true;
- break;
+ return true;
}
}
} catch (Exception e) {
logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), csarFilePath,
e.getMessage(), ErrorCode.DataError.getValue(), "ASDC Unable to check CSAR entries");
}
- return workflowsInCsar;
+ return false;
}
- protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version) throws Exception {
+ protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version)
+ throws IOException, URISyntaxException {
HttpClient client = HttpClientBuilder.create().build();
URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH);
HttpPost post = new HttpPost(deploymentUri);
return client.execute(post);
}
- protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws Exception {
+ protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws IOException {
FileInputStream bpmnFileStream = new FileInputStream(
Paths.get(getMsoConfigPath(), "ASDC", version, bpmnFileName).normalize().toString());
return requestEntity;
}
- /* protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException */
protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) {
String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", fileName).normalize().toString();
- /* BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath)); */
try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))) {
byte[] bytesIn = new byte[4096];
- int read = 0;
+ int read;
while ((read = zipIn.read(bytesIn)) != -1) {
outputStream.write(bytesIn, 0, read);
}
- /* outputStream.close(); */
} catch (IOException e) {
logger.error("Unable to open file.", e);
}