import java.nio.file.Paths;
import java.util.List;
import java.util.Optional;
-import org.onap.so.logger.LoggingAnchor;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.consumer.IDistributionStatusMessage;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
import org.onap.sdc.api.results.IDistributionClientResult;
import org.onap.sdc.impl.DistributionClientFactory;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.utils.DistributionActionResultEnum;
import org.onap.sdc.utils.DistributionStatusEnum;
import org.onap.so.asdc.activity.DeployActivitySpecs;
import org.onap.so.asdc.tenantIsolation.DistributionStatus;
import org.onap.so.asdc.tenantIsolation.WatchdogDistribution;
import org.onap.so.asdc.util.ASDCNotificationLogging;
+import org.onap.so.asdc.util.ZipParser;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
-import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.controllerName = controllerConfigName;
}
+ public ASDCConfiguration getASDCConfiguration() {
+ return asdcConfig;
+ }
+
public int getNbOfNotificationsOngoing() {
return nbOfNotificationsOngoing;
}
protected void processResourceNotification(INotificationData iNotif) {
// For each artifact, create a structure describing the VFModule in a ordered flat level
+ ResourceStructure resourceStructure = null;
String msoConfigPath = getMsoConfigPath();
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath);
DistributionStatusEnum deployStatus = DistributionStatusEnum.DEPLOY_OK;
if (isCsarAlreadyDeployed(iNotif, toscaResourceStructure)) {
return;
}
+ // process NsstResource
+ this.processNsstNotification(iNotif, toscaResourceStructure);
+
+ if (iNotif.getResources().isEmpty()) {
+ logger.error("Service Model contains no resources.");
+ return;
+ }
- ResourceStructure resourceStructure = null;
for (IResourceInstance resource : iNotif.getResources()) {
String resourceType = resource.getResourceType();
"processCsarServiceArtifacts", ErrorCode.BusinessProcessError.getValue(),
"Exception in processCsarServiceArtifacts", e);
}
+ } else if (artifact.getArtifactType().equals(ASDCConfiguration.OTHER)) {
+ try {
+ IDistributionClientDownloadResult resultArtifact =
+ this.downloadTheArtifact(artifact, iNotif.getDistributionID());
+
+ writeArtifactToFile(artifact, resultArtifact);
+
+ toscaResourceStructure.setToscaArtifact(artifact);
+
+ toscaResourceStructure.setServiceVersion(iNotif.getServiceVersion());
+
+ } catch (ASDCDownloadException e) {
+ logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception caught during processCsarServiceArtifacts", "ASDC",
+ "processCsarServiceArtifacts", ErrorCode.BusinessProcessError.getValue(),
+ "Exception in processCsarServiceArtifacts", e);
+ }
}
*/
public String getAddress() {
if (asdcConfig != null) {
- return asdcConfig.getAsdcAddress();
+ return asdcConfig.getSdcAddress();
}
return UNKNOWN;
}
}
return UNKNOWN;
}
+
+ private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
+ Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
+ try {
+ String category = serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ boolean isNeedInital = (category.contains("NSST") || category.equalsIgnoreCase("TN Network Requirement"))
+ && iNotif.getResources().isEmpty();
+ if (isNeedInital) {
+ String artifactContent = null;
+ List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
+ Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream()
+ .filter(e -> e.getArtifactType().equalsIgnoreCase("WORKFLOW")).findFirst();
+ if (artifactOpt.isPresent()) {
+ IArtifactInfo artifactInfo = artifactOpt.get();
+ logger.debug("Ready to parse this serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
+ String filePath = Paths.get(getMsoConfigPath(), "ASDC", artifactInfo.getArtifactVersion(),
+ artifactInfo.getArtifactName()).normalize().toString();
+ ZipParser zipParserInstance = ZipParser.getInstance();
+ artifactContent = zipParserInstance.parseJsonForZip(filePath);
+ logger.debug(
+ "serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
+
+ ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
+ resourceStructure.setResourceType(ResourceType.OTHER);
+ toscaInstaller.installNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure,
+ artifactContent);
+ } else {
+ logger.debug("serviceArtifact is null");
+ toscaInstaller.installNsstService(toscaResourceStructure, null, null);
+ }
+
+ }
+
+ } catch (IOException e) {
+ logger.error("serviceArtifact parse failure for service uuid: "
+ + serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+ } catch (Exception e) {
+ logger.error("error NSST process resource failure ", e);
+ }
+ }
}