Search in sources :

Example 1 with VfModuleStructure

use of org.onap.so.asdc.installer.VfModuleStructure 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"));
}
Also used : VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) INotificationData(org.onap.sdc.api.notification.INotificationData) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) UUID(java.util.UUID) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) Test(org.junit.Test)

Example 2 with VfModuleStructure

use of org.onap.so.asdc.installer.VfModuleStructure in project so by onap.

the class ToscaResourceInstallerTest method prepareToscaResourceStructure.

private ToscaResourceStructure prepareToscaResourceStructure(boolean prepareVFModuleStructures, ToscaResourceInstaller toscaInstaller) throws ArtifactInstallerException {
    Metadata metadata = mock(Metadata.class);
    IResourceInstance resourceInstance = mock(ResourceInstance.class);
    NodeTemplate nodeTemplate = mock(NodeTemplate.class);
    ISdcCsarHelper csarHelper = mock(SdcCsarHelperImpl.class);
    IArtifactInfo inputCsar = mock(IArtifactInfo.class);
    String artifactUuid = "0122c05e-e13a-4c63-b5d2-475ccf23aa74";
    String checkSum = "MGUzNjJjMzk3OTBkYzExYzQ0MDg2ZDc2M2E3ZjZiZmY=";
    doReturn(checkSum).when(inputCsar).getArtifactChecksum();
    doReturn(artifactUuid).when(inputCsar).getArtifactUUID();
    doReturn("1.0").when(inputCsar).getArtifactVersion();
    doReturn("TestCsarWithGroupAndVFModule").when(inputCsar).getArtifactName();
    doReturn("Test Csar data with Group and VF module inputs").when(inputCsar).getArtifactDescription();
    doReturn("http://localhost/dummy/url/test.csar").when(inputCsar).getArtifactURL();
    ToscaResourceStructure toscaResourceStructObj = new ToscaResourceStructure();
    toscaResourceStructObj.setToscaArtifact(inputCsar);
    ToscaCsarRepository toscaCsarRepo = spy(ToscaCsarRepository.class);
    ToscaCsar toscaCsar = mock(ToscaCsar.class);
    Optional<ToscaCsar> returnValue = Optional.of(toscaCsar);
    doReturn(artifactUuid).when(toscaCsar).getArtifactUUID();
    doReturn(checkSum).when(toscaCsar).getArtifactChecksum();
    doReturn(returnValue).when(toscaCsarRepo).findById(artifactUuid);
    ReflectionTestUtils.setField(toscaInstaller, "toscaCsarRepo", toscaCsarRepo);
    NotificationDataImpl notificationData = new NotificationDataImpl();
    notificationData.setDistributionID("testStatusSuccessfulTosca");
    notificationData.setServiceVersion("1234567");
    notificationData.setServiceUUID("serviceUUID1");
    notificationData.setWorkloadContext("workloadContext1");
    String serviceType = "test-type1";
    String serviceRole = "test-role1";
    String category = "Network L3+";
    String description = "Customer Orderable service description";
    String name = "Customer_Orderable_Service";
    String uuid = "72db5868-4575-4804-b546-0b0d3c3b5ac6";
    String invariantUUID = "6f30bbe3-4590-4185-a7e0-4f9610926c6f";
    String namingPolicy = "naming Policy1";
    String ecompGeneratedNaming = "true";
    String environmentContext = "General_Revenue-Bearing1";
    String resourceCustomizationUUID = "0177ba22-5547-4e4e-bcf8-178f7f71de3a";
    doReturn(serviceType).when(metadata).getValue("serviceType");
    doReturn(serviceRole).when(metadata).getValue("serviceRole");
    doReturn(category).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
    doReturn(description).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
    doReturn("1.0").when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_VERSION);
    doReturn(name).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
    doReturn(uuid).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
    doReturn(environmentContext).when(metadata).getValue(metadata.getValue("environmentContext"));
    doReturn(invariantUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
    doReturn(namingPolicy).when(metadata).getValue("namingPolicy");
    doReturn(ecompGeneratedNaming).when(metadata).getValue("ecompGeneratedNaming");
    doReturn(resourceCustomizationUUID).when(metadata).getValue("vfModuleModelCustomizationUUID");
    ServiceRepository serviceRepo = spy(ServiceRepository.class);
    VnfResourceRepository vnfRepo = spy(VnfResourceRepository.class);
    doReturn(null).when(vnfRepo).findResourceByModelUUID(uuid);
    VFModuleRepository vfModuleRepo = spy(VFModuleRepository.class);
    InstanceGroupRepository instanceGroupRepo = spy(InstanceGroupRepository.class);
    WorkflowResource workflowResource = spy(WorkflowResource.class);
    ReflectionTestUtils.setField(toscaInstaller, "serviceRepo", serviceRepo);
    ReflectionTestUtils.setField(toscaInstaller, "vnfRepo", vnfRepo);
    ReflectionTestUtils.setField(toscaInstaller, "vfModuleRepo", vfModuleRepo);
    ReflectionTestUtils.setField(toscaInstaller, "instanceGroupRepo", instanceGroupRepo);
    ReflectionTestUtils.setField(toscaInstaller, "workflowResource", workflowResource);
    // doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper();
    toscaResourceStructObj.setSdcCsarHelper(csarHelper);
    doReturn(resourceCustomizationUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
    doReturn(uuid).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID);
    // vnfc instance group list
    List<Group> vnfcInstanceGroupList = new ArrayList<>();
    Group vnfcG1 = mock(Group.class);
    Map<String, Object> metaProperties = new HashMap<>();
    metaProperties.put(SdcPropertyNames.PROPERTY_NAME_UUID, "vnfc_group1_uuid");
    metaProperties.put(SdcPropertyNames.PROPERTY_NAME_NAME, "vnfc_group1_uuid");
    metaProperties.put(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID, "vnfc_group1_invariantid");
    metaProperties.put(SdcPropertyNames.PROPERTY_NAME_VERSION, "1.0");
    Metadata vnfcmetadata = new Metadata(metaProperties);
    doReturn(vnfcmetadata).when(vnfcG1).getMetadata();
    ArrayList<NodeTemplate> memberList = new ArrayList();
    doReturn(memberList).when(vnfcG1).getMemberNodes();
    vnfcInstanceGroupList.add(vnfcG1);
    SubstitutionMappings submappings = mock(SubstitutionMappings.class);
    doReturn(new ArrayList<Input>()).when(submappings).getInputs();
    doReturn(submappings).when(nodeTemplate).getSubMappingToscaTemplate();
    doReturn(notificationData).when(vfResourceStruct).getNotification();
    doReturn(resourceInstance).when(vfResourceStruct).getResourceInstance();
    if (prepareVFModuleStructures) {
        // VfModule list
        List<Group> vfModuleGroups = new ArrayList<>();
        Group g1 = mock(Group.class);
        doReturn(metadata).when(g1).getMetadata();
        vfModuleGroups.add(g1);
        doReturn(metadata).when(nodeTemplate).getMetaData();
        List<NodeTemplate> nodeList = new ArrayList<>();
        nodeList.add(nodeTemplate);
        IVfModuleData moduleMetadata = mock(IVfModuleData.class);
        doReturn(name).when(moduleMetadata).getVfModuleModelName();
        doReturn(invariantUUID).when(moduleMetadata).getVfModuleModelInvariantUUID();
        doReturn(Collections.<String>emptyList()).when(moduleMetadata).getArtifacts();
        doReturn(resourceCustomizationUUID).when(moduleMetadata).getVfModuleModelCustomizationUUID();
        doReturn(uuid).when(moduleMetadata).getVfModuleModelUUID();
        doReturn("1.0").when(moduleMetadata).getVfModuleModelVersion();
        VfModuleStructure moduleStructure = new VfModuleStructure(vfResourceStruct, moduleMetadata);
        List<VfModuleStructure> moduleStructures = new ArrayList<>();
        moduleStructures.add(moduleStructure);
        doReturn(moduleStructures).when(vfResourceStruct).getVfModuleStructure();
    }
    toscaResourceStructObj.setServiceMetadata(metadata);
    doReturn("resourceInstanceName1").when(resourceInstance).getResourceInstanceName();
    doReturn(resourceCustomizationUUID).when(resourceInstance).getResourceCustomizationUUID();
    doReturn("resourceName1").when(resourceInstance).getResourceName();
    Service service = toscaInstaller.createService(toscaResourceStructObj, vfResourceStruct);
    assertNotNull(service);
    service.setModelVersion("1.0");
    doReturn(service).when(serviceRepo).save(service);
    WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository = spy(WatchdogComponentDistributionStatusRepository.class);
    ReflectionTestUtils.setField(toscaInstaller, "watchdogCDStatusRepository", watchdogCDStatusRepository);
    doReturn(null).when(watchdogCDStatusRepository).save(any(WatchdogComponentDistributionStatus.class));
    VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo = spy(VnfcInstanceGroupCustomizationRepository.class);
    ReflectionTestUtils.setField(toscaInstaller, "vnfcInstanceGroupCustomizationRepo", vnfcInstanceGroupCustomizationRepo);
    doReturn(null).when(vnfcInstanceGroupCustomizationRepo).save(any(VnfcInstanceGroupCustomization.class));
    return toscaResourceStructObj;
}
Also used : Group(org.onap.sdc.toscaparser.api.Group) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ArrayList(java.util.ArrayList) WatchdogComponentDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) Input(org.onap.sdc.toscaparser.api.parameters.Input) NotificationDataImpl(org.onap.so.asdc.client.test.emulators.NotificationDataImpl) SubstitutionMappings(org.onap.sdc.toscaparser.api.SubstitutionMappings) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) WorkflowResource(org.onap.so.asdc.installer.bpmn.WorkflowResource) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) NodeTemplate(org.onap.sdc.toscaparser.api.NodeTemplate) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData)

Example 3 with VfModuleStructure

use of org.onap.so.asdc.installer.VfModuleStructure in project so by onap.

the class ToscaResourceInstaller method processVfModules.

protected void processVfModules(IEntityDetails vfEntityDetails, ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, Service service, Metadata metadata) throws Exception {
    String vfCustomizationCategory = vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
    logger.debug("VF Category is: {} ", vfCustomizationCategory);
    String vfCustomizationUUID = vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
    logger.debug("VFCustomizationUUID= {}", vfCustomizationUUID);
    IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
    // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
    // comparing their VF Modules UUID's
    logger.debug("Checking if Notification VF ResourceCustomizationUUID: {} matches Tosca VF Customization UUID: {}", vfNotificationResource.getResourceCustomizationUUID(), vfCustomizationUUID);
    if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
        logger.debug("vfCustomizationUUID: {}  matches vfNotificationResource CustomizationUUID ", vfCustomizationUUID);
        VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service);
        if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
            Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>();
            Set<VnfcCustomization> existingVnfcSet = new HashSet<>();
            List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom = new ArrayList<>();
            for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
                logger.debug("vfModuleStructure: {}", vfModuleStructure);
                List<IEntityDetails> vfModuleEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.groups.VfModule"), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).customizationUUID(vfCustomizationUUID), false);
                IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
                logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
                Optional<IEntityDetails> matchingObject = vfModuleEntityList.stream().peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"))).filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())).findFirst();
                if (matchingObject.isPresent()) {
                    VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet, existingCvnfcConfigurationCustom);
                    vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
                } else
                    throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
            }
        }
        // Check for VNFC Instance Group info and add it if there is
        List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
        Set<VnfcCustomization> existingVnfcGroupSet = new HashSet<>();
        for (IEntityDetails groupEntity : vfcEntityList) {
            VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(groupEntity, vfEntityDetails, vnfResource, toscaResourceStruct, existingVnfcGroupSet);
            vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
        }
        List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList);
        if (!CollectionUtils.isEmpty(seqResult)) {
            String resultStr = seqResult.stream().collect(Collectors.joining(","));
            vnfResource.setVnfcInstanceGroupOrder(resultStr);
            logger.debug("vnfcGroupOrder result for service uuid {}: {}", service.getModelUUID(), resultStr);
        }
        // add this vnfResource with existing vnfResource for this service
        addVnfCustomization(service, vnfResource);
    } else {
        logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " + "Tosca VF Customization UUID: " + vfCustomizationUUID);
    }
}
Also used : NetworkInstanceGroup(org.onap.so.db.catalog.beans.NetworkInstanceGroup) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) Property(org.onap.sdc.toscaparser.api.Property) VfModule(org.onap.so.db.catalog.beans.VfModule) PnfResourceRepository(org.onap.so.db.catalog.data.repository.PnfResourceRepository) Autowired(org.springframework.beans.factory.annotation.Autowired) WatchdogComponentDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository) EntityQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.EntityQuery.EntityQueryBuilder) Matcher(java.util.regex.Matcher) VnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository) Service(org.onap.so.db.catalog.beans.Service) VFModuleRepository(org.onap.so.db.catalog.data.repository.VFModuleRepository) Map(java.util.Map) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) ExternalServiceToInternalServiceRepository(org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) VnfcInstanceGroupCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) WatchdogDistributionStatus(org.onap.so.db.request.beans.WatchdogDistributionStatus) VfModuleArtifact(org.onap.so.asdc.installer.VfModuleArtifact) SdcTypes(org.onap.sdc.tosca.parser.enums.SdcTypes) HeatFiles(org.onap.so.db.catalog.beans.HeatFiles) HeatEnvironmentRepository(org.onap.so.db.catalog.data.repository.HeatEnvironmentRepository) Set(java.util.Set) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ASDCConfiguration(org.onap.so.asdc.client.ASDCConfiguration) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) NodeTemplate(org.onap.sdc.toscaparser.api.NodeTemplate) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) NetworkResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository) CollectionUtils(org.springframework.util.CollectionUtils) ConfigurationResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) InstanceGroupRepository(org.onap.so.db.catalog.data.repository.InstanceGroupRepository) CollectionResourceRepository(org.onap.so.db.catalog.data.repository.CollectionResourceRepository) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) VFModuleCustomizationRepository(org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository) TopologyTemplateQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery.TopologyTemplateQueryBuilder) InstanceGroupType(org.onap.so.db.catalog.beans.InstanceGroupType) AllottedResourceRepository(org.onap.so.db.catalog.data.repository.AllottedResourceRepository) VnfResource(org.onap.so.db.catalog.beans.VnfResource) HeatFilesRepository(org.onap.so.db.catalog.data.repository.HeatFilesRepository) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) ErrorCode(org.onap.logging.filter.base.ErrorCode) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment) PnfResource(org.onap.so.db.catalog.beans.PnfResource) ToscaCsarRepository(org.onap.so.db.catalog.data.repository.ToscaCsarRepository) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) CapabilityAssignment(org.onap.sdc.toscaparser.api.CapabilityAssignment) Input(org.onap.sdc.toscaparser.api.parameters.Input) MessageEnum(org.onap.so.logger.MessageEnum) SubType(org.onap.so.db.catalog.beans.SubType) NetworkResourceRepository(org.onap.so.db.catalog.data.repository.NetworkResourceRepository) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) WatchdogServiceModVerIdLookupRepository(org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) YamlEditor(org.onap.so.asdc.util.YamlEditor) TempNetworkHeatTemplateRepository(org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository) Collectors(java.util.stream.Collectors) List(java.util.List) ServiceInfo(org.onap.so.db.catalog.beans.ServiceInfo) Optional(java.util.Optional) LoggingAnchor(org.onap.so.logger.LoggingAnchor) Pattern(java.util.regex.Pattern) BigDecimalVersion(org.onap.so.asdc.installer.BigDecimalVersion) WatchdogDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository) TempNetworkHeatTemplateLookup(org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup) ServiceArtifact(org.onap.so.db.catalog.beans.ServiceArtifact) WatchdogServiceModVerIdLookup(org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup) HashMap(java.util.HashMap) CvnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository) ServiceProxyResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) ConfigurationResourceRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository) HashSet(java.util.HashSet) AllottedResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository) PnfCustomizationRepository(org.onap.so.db.catalog.data.repository.PnfCustomizationRepository) CollectionResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository) DistributionStatusEnum(org.onap.sdc.utils.DistributionStatusEnum) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) Logger(org.slf4j.Logger) EntityTemplateType(org.onap.sdc.tosca.parser.enums.EntityTemplateType) IStatusData(org.onap.sdc.api.notification.IStatusData) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) VnfResourceRepository(org.onap.so.db.catalog.data.repository.VnfResourceRepository) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HeatTemplateRepository(org.onap.so.db.catalog.data.repository.HeatTemplateRepository) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) Component(org.springframework.stereotype.Component) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) ServiceRepository(org.onap.so.db.catalog.data.repository.ServiceRepository) SdcPropertyNames(org.onap.sdc.tosca.parser.impl.SdcPropertyNames) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) GetInput(org.onap.sdc.toscaparser.api.functions.GetInput) Collections(java.util.Collections) WorkflowResource(org.onap.so.asdc.installer.bpmn.WorkflowResource) Transactional(org.springframework.transaction.annotation.Transactional) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) ArrayList(java.util.ArrayList) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) HashSet(java.util.HashSet)

Example 4 with VfModuleStructure

use of org.onap.so.asdc.installer.VfModuleStructure in project so by onap.

the class ToscaResourceInstaller method setHeatInformationForVfModule.

protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization, Metadata vfMetadata) {
    Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream().filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID().equalsIgnoreCase(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))).findFirst();
    if (matchingObject.isPresent()) {
        List<HeatFiles> heatFilesList = new ArrayList<>();
        List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<>();
        List<HeatTemplate> heatChildTemplates = new ArrayList<>();
        HeatTemplate parentHeatTemplate = new HeatTemplate();
        String parentArtifactType = null;
        Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
        for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
            List<HeatTemplate> childNestedHeatTemplates = new ArrayList<>();
            if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
                checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact, childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
            }
            if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
                parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
                if (!childNestedHeatTemplates.isEmpty()) {
                    if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
                        volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
                    } else {
                        heatChildTemplates.add(childNestedHeatTemplates.get(0));
                    }
                }
            }
        }
        if (!heatFilesList.isEmpty()) {
            vfModule.setHeatFiles(heatFilesList);
        }
        // Set all Child Templates related to HEAT_VOLUME
        if (!volumeHeatChildTemplates.isEmpty()) {
            if (vfModule.getVolumeHeatTemplate() != null) {
                vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
            } else {
                logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
            }
        }
        // Set all Child Templates related to HEAT
        if (!heatChildTemplates.isEmpty()) {
            if (vfModule.getModuleHeatTemplate() != null) {
                vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
            } else {
                logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
            }
        }
    }
}
Also used : NetworkInstanceGroup(org.onap.so.db.catalog.beans.NetworkInstanceGroup) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) Property(org.onap.sdc.toscaparser.api.Property) VfModule(org.onap.so.db.catalog.beans.VfModule) PnfResourceRepository(org.onap.so.db.catalog.data.repository.PnfResourceRepository) Autowired(org.springframework.beans.factory.annotation.Autowired) WatchdogComponentDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository) EntityQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.EntityQuery.EntityQueryBuilder) Matcher(java.util.regex.Matcher) VnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository) Service(org.onap.so.db.catalog.beans.Service) VFModuleRepository(org.onap.so.db.catalog.data.repository.VFModuleRepository) Map(java.util.Map) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) ExternalServiceToInternalServiceRepository(org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) VnfcInstanceGroupCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) WatchdogDistributionStatus(org.onap.so.db.request.beans.WatchdogDistributionStatus) VfModuleArtifact(org.onap.so.asdc.installer.VfModuleArtifact) SdcTypes(org.onap.sdc.tosca.parser.enums.SdcTypes) HeatFiles(org.onap.so.db.catalog.beans.HeatFiles) HeatEnvironmentRepository(org.onap.so.db.catalog.data.repository.HeatEnvironmentRepository) Set(java.util.Set) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ASDCConfiguration(org.onap.so.asdc.client.ASDCConfiguration) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) NodeTemplate(org.onap.sdc.toscaparser.api.NodeTemplate) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) NetworkResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository) CollectionUtils(org.springframework.util.CollectionUtils) ConfigurationResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) InstanceGroupRepository(org.onap.so.db.catalog.data.repository.InstanceGroupRepository) CollectionResourceRepository(org.onap.so.db.catalog.data.repository.CollectionResourceRepository) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) VFModuleCustomizationRepository(org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository) TopologyTemplateQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery.TopologyTemplateQueryBuilder) InstanceGroupType(org.onap.so.db.catalog.beans.InstanceGroupType) AllottedResourceRepository(org.onap.so.db.catalog.data.repository.AllottedResourceRepository) VnfResource(org.onap.so.db.catalog.beans.VnfResource) HeatFilesRepository(org.onap.so.db.catalog.data.repository.HeatFilesRepository) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) ErrorCode(org.onap.logging.filter.base.ErrorCode) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment) PnfResource(org.onap.so.db.catalog.beans.PnfResource) ToscaCsarRepository(org.onap.so.db.catalog.data.repository.ToscaCsarRepository) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) CapabilityAssignment(org.onap.sdc.toscaparser.api.CapabilityAssignment) Input(org.onap.sdc.toscaparser.api.parameters.Input) MessageEnum(org.onap.so.logger.MessageEnum) SubType(org.onap.so.db.catalog.beans.SubType) NetworkResourceRepository(org.onap.so.db.catalog.data.repository.NetworkResourceRepository) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) WatchdogServiceModVerIdLookupRepository(org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) YamlEditor(org.onap.so.asdc.util.YamlEditor) TempNetworkHeatTemplateRepository(org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository) Collectors(java.util.stream.Collectors) List(java.util.List) ServiceInfo(org.onap.so.db.catalog.beans.ServiceInfo) Optional(java.util.Optional) LoggingAnchor(org.onap.so.logger.LoggingAnchor) Pattern(java.util.regex.Pattern) BigDecimalVersion(org.onap.so.asdc.installer.BigDecimalVersion) WatchdogDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository) TempNetworkHeatTemplateLookup(org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup) ServiceArtifact(org.onap.so.db.catalog.beans.ServiceArtifact) WatchdogServiceModVerIdLookup(org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup) HashMap(java.util.HashMap) CvnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository) ServiceProxyResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) ConfigurationResourceRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository) HashSet(java.util.HashSet) AllottedResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository) PnfCustomizationRepository(org.onap.so.db.catalog.data.repository.PnfCustomizationRepository) CollectionResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository) DistributionStatusEnum(org.onap.sdc.utils.DistributionStatusEnum) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) Logger(org.slf4j.Logger) EntityTemplateType(org.onap.sdc.tosca.parser.enums.EntityTemplateType) IStatusData(org.onap.sdc.api.notification.IStatusData) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) VnfResourceRepository(org.onap.so.db.catalog.data.repository.VnfResourceRepository) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HeatTemplateRepository(org.onap.so.db.catalog.data.repository.HeatTemplateRepository) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) Component(org.springframework.stereotype.Component) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) ServiceRepository(org.onap.so.db.catalog.data.repository.ServiceRepository) SdcPropertyNames(org.onap.sdc.tosca.parser.impl.SdcPropertyNames) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) GetInput(org.onap.sdc.toscaparser.api.functions.GetInput) Collections(java.util.Collections) WorkflowResource(org.onap.so.asdc.installer.bpmn.WorkflowResource) Transactional(org.springframework.transaction.annotation.Transactional) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) HeatFiles(org.onap.so.db.catalog.beans.HeatFiles) ArrayList(java.util.ArrayList) VfModuleArtifact(org.onap.so.asdc.installer.VfModuleArtifact) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) HashSet(java.util.HashSet)

Aggregations

IResourceInstance (org.onap.sdc.api.notification.IResourceInstance)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 IArtifactInfo (org.onap.sdc.api.notification.IArtifactInfo)3 ISdcCsarHelper (org.onap.sdc.tosca.parser.api.ISdcCsarHelper)3 NodeTemplate (org.onap.sdc.toscaparser.api.NodeTemplate)3 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)3 Input (org.onap.sdc.toscaparser.api.parameters.Input)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Timestamp (java.sql.Timestamp)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2