use of org.onap.so.asdc.installer.VfResourceStructure in project so by onap.
the class ToscaResourceInstaller method isResourceAlreadyDeployed.
public boolean isResourceAlreadyDeployed(ResourceStructure vfResourceStruct, boolean serviceDeployed) throws ArtifactInstallerException {
boolean status = false;
ResourceStructure vfResourceStructure = vfResourceStruct;
try {
status = vfResourceStructure.isDeployedSuccessfully();
} catch (RuntimeException e) {
status = false;
logger.debug("Exception :", e);
}
try {
Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
if (existingService != null && !serviceDeployed)
status = true;
if (status) {
logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(), vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), vfResourceStructure.getNotification().getServiceName(), BigDecimalVersion.castAndCheckNotificationVersionToString(vfResourceStructure.getNotification().getServiceVersion()), vfResourceStructure.getNotification().getServiceUUID(), vfResourceStructure.getResourceInstance().getResourceName(), "", "");
WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
watchdogCDStatusRepository.saveAndFlush(wdStatus);
} else {
logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(), vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), vfResourceStructure.getNotification().getServiceName(), BigDecimalVersion.castAndCheckNotificationVersionToString(vfResourceStructure.getNotification().getServiceVersion()), vfResourceStructure.getNotification().getServiceUUID(), vfResourceStructure.getResourceInstance().getResourceName(), "", "");
}
return status;
} catch (Exception e) {
logger.error(LoggingAnchor.THREE, MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(), "Exception - isResourceAlreadyDeployed");
throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
}
}
use of org.onap.so.asdc.installer.VfResourceStructure in project so by onap.
the class ASDCElementInfoTest method createASDCElementInfoFromVfModuleTest.
@Test
public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {
String resourceInstanceName = "Resource 1";
UUID generatedUUID = UUID.randomUUID();
INotificationData notificationData = Mockito.mock(INotificationData.class);
IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
// Create module structure now
String vfModuleModelName = "Module Model XYZ";
UUID generatedUUIDForModule = UUID.randomUUID();
IVfModuleData moduleMetadata = Mockito.mock(IVfModuleData.class);
Mockito.when(moduleMetadata.getVfModuleModelName()).thenReturn(vfModuleModelName);
Mockito.when(moduleMetadata.getVfModuleModelInvariantUUID()).thenReturn(generatedUUIDForModule.toString());
Mockito.when(moduleMetadata.getArtifacts()).thenReturn(Collections.<String>emptyList());
VfModuleStructure vfModuleStructure = new VfModuleStructure(vfResourceStructure, moduleMetadata);
ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);
assertTrue(elementInfoFromVfModule.toString().contains(vfModuleModelName));
assertTrue(elementInfoFromVfModule.toString().contains(generatedUUIDForModule.toString()));
assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromVfModule.getType()));
assertEquals(ASDCConfiguration.VF_MODULES_METADATA, elementInfoFromVfModule.getType());
assertFalse(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
elementInfoFromVfModule.addElementInfo("MyInfo2", "someValue");
assertTrue(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
}
use of org.onap.so.asdc.installer.VfResourceStructure in project so by onap.
the class ASDCController method processNsstNotification.
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);
}
}
use of org.onap.so.asdc.installer.VfResourceStructure in project so by onap.
the class ASDCController method getResourceStructure.
private ResourceStructure getResourceStructure(INotificationData iNotif, IResourceInstance resource, String resourceType) {
if ("VF".equals(resourceType)) {
return new VfResourceStructure(iNotif, resource);
}
if ("PNF".equals(resourceType)) {
return new PnfResourceStructure(iNotif, resource);
}
logger.info("No resources found for Service: {}", iNotif.getServiceUUID());
ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
resourceStructure.setResourceType(ResourceType.OTHER);
return resourceStructure;
}
use of org.onap.so.asdc.installer.VfResourceStructure in project so by onap.
the class ASDCController method notifyErrorToAsdc.
protected void notifyErrorToAsdc(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure, DistributionStatusEnum deployStatus, VfResourceStructure resourceStructure, String errorMessage) {
// do csar lever first
this.sendCsarDeployNotification(resourceStructure, toscaResourceStructure, deployStatus, errorMessage);
// at resource level
for (IResourceInstance resource : iNotif.getResources()) {
resourceStructure = new VfResourceStructure(iNotif, resource);
errorMessage = String.format("Resource with UUID: %s already exists", resource.getResourceUUID());
this.sendCsarDeployNotification(resourceStructure, toscaResourceStructure, deployStatus, errorMessage);
}
}
Aggregations