Search in sources :

Example 1 with CloudConfiguration

use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.

the class BpmnRequestBuilder method mapCloudConfigurationVolume.

public CloudConfiguration mapCloudConfigurationVolume(GenericVnf vnf, VolumeGroup volumeGroup) {
    CloudConfiguration cloudConfig = new CloudConfiguration();
    AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
    Optional<org.onap.aaiclient.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
    String tenantId = null;
    String cloudOwner = null;
    String lcpRegionId = null;
    if (relationshipsOpt.isPresent()) {
        tenantId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)).orElse(null);
        cloudOwner = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)).orElse(null);
        lcpRegionId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)).orElse(null);
    }
    if (tenantId == null || cloudOwner == null || lcpRegionId == null) {
        Map<String, String[]> filters = createQueryRequest("volumeGroupId", volumeGroup.getVolumeGroupId());
        Optional<ServiceInstancesRequest> request = findServiceInstanceRequest(filters);
        if (request.isPresent()) {
            tenantId = request.get().getRequestDetails().getCloudConfiguration().getTenantId();
            cloudOwner = request.get().getRequestDetails().getCloudConfiguration().getCloudOwner();
            lcpRegionId = request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId();
        } else {
            throw new CloudConfigurationNotFoundException(CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND);
        }
    }
    cloudConfig.setTenantId(tenantId);
    cloudConfig.setCloudOwner(cloudOwner);
    cloudConfig.setLcpCloudRegionId(lcpRegionId);
    return cloudConfig;
}
Also used : CloudConfigurationNotFoundException(org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 2 with CloudConfiguration

use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.

the class BpmnRequestBuilder method mapCloudConfiguration.

public CloudConfiguration mapCloudConfiguration(GenericVnf vnf, String vfModuleId) {
    CloudConfiguration cloudConfig = new CloudConfiguration();
    AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
    Optional<org.onap.aaiclient.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
    String tenantId = null;
    String cloudOwner = null;
    String lcpRegionId = null;
    if (relationshipsOpt.isPresent()) {
        tenantId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)).orElse(null);
        cloudOwner = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)).orElse(null);
        lcpRegionId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)).orElse(null);
    }
    if (tenantId == null || cloudOwner == null || lcpRegionId == null) {
        Map<String, String[]> filters = createQueryRequest("vfModuleId", vfModuleId);
        Optional<ServiceInstancesRequest> request = findServiceInstanceRequest(filters);
        if (request.isPresent()) {
            if (request.get().getRequestDetails() != null && request.get().getRequestDetails().getCloudConfiguration() != null) {
                if (request.get().getRequestDetails().getCloudConfiguration().getTenantId() != null) {
                    tenantId = request.get().getRequestDetails().getCloudConfiguration().getTenantId();
                }
                if (request.get().getRequestDetails().getCloudConfiguration().getCloudOwner() != null) {
                    cloudOwner = request.get().getRequestDetails().getCloudConfiguration().getCloudOwner();
                }
                if (request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId() != null) {
                    lcpRegionId = request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId();
                }
            }
        } else {
            throw new CloudConfigurationNotFoundException(CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND);
        }
    }
    cloudConfig.setTenantId(tenantId);
    cloudConfig.setCloudOwner(cloudOwner);
    cloudConfig.setLcpCloudRegionId(lcpRegionId);
    return cloudConfig;
}
Also used : CloudConfigurationNotFoundException(org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 3 with CloudConfiguration

use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.

the class BBInputSetupMapperLayerTest method testMapCloudRegion.

@Test
public void testMapCloudRegion() {
    CloudRegion expected = new CloudRegion();
    expected.setCloudOwner("test-owner-name");
    expected.setLcpCloudRegionId("cloudRegionId");
    expected.setTenantId("tenantId");
    expected.setCloudRegionVersion("cloudRegionVersion");
    CloudConfiguration cloudConfig = new CloudConfiguration();
    cloudConfig.setTenantId("tenantId");
    cloudConfig.setLcpCloudRegionId("cloudRegionId");
    cloudConfig.setAicNodeClli("aicNodeClli");
    org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
    cloudRegion.setCloudOwner("test-owner-name");
    cloudRegion.setCloudRegionId("cloudRegionId");
    cloudRegion.setCloudRegionVersion("cloudRegionVersion");
    CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
    assertThat(actual, sameBeanAs(expected));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Test(org.junit.Test)

Example 4 with CloudConfiguration

use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.

the class VolumeGroupDeleteValidatorTest method validateSuccessTest.

@Test
public void validateSuccessTest() {
    instanceIdMap.put("volumeGroupInstanceId", "1");
    ServiceInstancesRequest request = new ServiceInstancesRequest();
    RequestDetails details = new RequestDetails();
    details.setCloudConfiguration(new CloudConfiguration());
    request.setRequestDetails(details);
    when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule(any(CloudConfiguration.class), eq("1"))).thenReturn(false);
    Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, request, null, null);
    assertEquals(false, result.isPresent());
}
Also used : CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 5 with CloudConfiguration

use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.

the class ServiceInstancesUnitTest method getCloudConfigurationOnReplaceVnfTest.

@Test
public void getCloudConfigurationOnReplaceVnfTest() throws ApiException {
    CloudConfiguration cloudConfiguration = new CloudConfiguration();
    cloudConfiguration.setTenantId("tenantId");
    cloudConfiguration.setLcpCloudRegionId("lcpCloudRegionId");
    String requestScope = ModelType.vnf.toString();
    HashMap<String, String> instanceIdMap = new HashMap<>();
    instanceIdMap.put("vnfInstanceId", "17c10d8e-48f4-4ee6-b162-a801943df6d6");
    InfraActiveRequests currentActiveRequest = new InfraActiveRequests();
    doReturn(cloudConfiguration).when(bpmnRequestBuilder).mapCloudConfigurationVnf("17c10d8e-48f4-4ee6-b162-a801943df6d6");
    CloudConfiguration result = serviceInstances.getCloudConfigurationOnReplace(requestScope, instanceIdMap, currentActiveRequest);
    assertEquals(cloudConfiguration, result);
}
Also used : CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) HashMap(java.util.HashMap) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Aggregations

CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)42 Test (org.junit.Test)28 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)15 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)15 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)15 HashMap (java.util.HashMap)13 Service (org.onap.so.db.catalog.beans.Service)13 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)13 File (java.io.File)12 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)12 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)12 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)11 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)10 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)9 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)8 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)8 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)7 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)7 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)6