Search in sources :

Example 1 with CloudRegion

use of org.onap.aai.domain.yang.CloudRegion in project so by onap.

the class BBInputSetupUtilsTest method getCloudRegionTest.

@Test
public void getCloudRegionTest() {
    CloudConfiguration cloudConfig = new CloudConfiguration();
    cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
    Optional<CloudRegion> expected = Optional.of(new CloudRegion());
    doReturn(expected).when(MOCK_aaiResourcesClient).get(CloudRegion.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId())).depth(Depth.ONE).nodesOnly(true));
    assertThat(bbInputSetupUtils.getCloudRegion(cloudConfig), sameBeanAs(expected.get()));
}
Also used : CloudRegion(org.onap.aai.domain.yang.CloudRegion) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Test(org.junit.Test)

Example 2 with CloudRegion

use of org.onap.aai.domain.yang.CloudRegion in project so by onap.

the class BBInputSetupExistingServiceTest method test_getGBBMacro_getGBBMacroExistingService_shouldBeCalled.

@Test
public void test_getGBBMacro_getGBBMacroExistingService_shouldBeCalled() throws Exception {
    // given
    String resourceId = "123";
    String vnfType = "vnfType";
    String requestAction = this.requestAction;
    Service service = Mockito.mock(Service.class);
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    ServiceInstance serviceInstance = gBB.getServiceInstance();
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
    aaiServiceInstance.setModelVersionId("modelVersionId");
    CloudConfiguration cloudConfig = new CloudConfiguration();
    cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
    CloudRegion aaiCloudRegion = Mockito.mock(CloudRegion.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
    requestDetails.getRequestParameters().setUserParams(null);
    requestDetails.setCloudConfiguration(cloudConfig);
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    executeBB.setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName(this.bpmnFlowName).setKey(this.key);
    doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
    doReturn(aaiServiceInstance).when(bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
    doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
    doReturn(aaiCloudRegion).when(bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
    // when
    SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    // then
    verify(SPY_bbInputSetup, times(1)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(), any(String.class), isA(String.class), isA(CloudConfiguration.class));
}
Also used : CloudRegion(org.onap.aai.domain.yang.CloudRegion) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) File(java.io.File) Test(org.junit.Test)

Example 3 with CloudRegion

use of org.onap.aai.domain.yang.CloudRegion in project so by onap.

the class CloudRestImpl method mapCloudRegion.

protected CloudRegion mapCloudRegion(CloudSite cloudSite) {
    CloudRegion region = new CloudRegion();
    region.setCloudOwner(cloudSite.getCloudOwner());
    region.setCloudRegionId(cloudSite.getRegionId());
    region.setCloudRegionVersion(cloudSite.getCloudVersion());
    region.setOwnerDefinedType("cLCP");
    region.setCloudType("openstack");
    MavenLikeVersioning cloudVersion = new MavenLikeVersioning();
    cloudVersion.setVersion(cloudSite.getCloudVersion());
    if (cloudVersion.isMoreRecentThan("3.0")) {
        region.setCloudZone(cloudSite.getRegionId().substring(0, cloudSite.getRegionId().length() - 1));
    } else {
        region.setCloudZone(cloudSite.getRegionId());
    }
    region.setOrchestrationDisabled(false);
    region.setInMaint(false);
    return region;
}
Also used : CloudRegion(org.onap.aai.domain.yang.CloudRegion) MavenLikeVersioning(org.onap.so.db.catalog.utils.MavenLikeVersioning)

Example 4 with CloudRegion

use of org.onap.aai.domain.yang.CloudRegion in project so by onap.

the class CloudRestImpl method createCloudRegionInAAI.

protected void createCloudRegionInAAI(CloudSite cloudSite) {
    try {
        CloudRegion cloudRegion = mapCloudRegion(cloudSite);
        Optional<Complex> complex = retrieveComplex(cloudSite);
        if (complex.isPresent()) {
            cloudRegion.setComplexName(complex.get().getComplexName());
        }
        AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getCloudRegionId()));
        getAaiClient().createIfNotExists(cloudRegionURI, Optional.of(cloudRegion));
        if (complex.isPresent()) {
            AAIResourceUri complexURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().complex(cloudSite.getClli()));
            getAaiClient().connect(cloudRegionURI, complexURI);
        }
        createCloudRegionNetworkTechnologyRelationship(cloudSite, cloudRegionURI);
    } catch (Exception e) {
        logger.error("Error creating cloud region in AAI", e);
        throw new CloudException("Error creating cloud region in AAI: " + e.getMessage(), e);
    }
}
Also used : CloudRegion(org.onap.aai.domain.yang.CloudRegion) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Complex(org.onap.aai.domain.yang.Complex)

Example 5 with CloudRegion

use of org.onap.aai.domain.yang.CloudRegion in project so by onap.

the class CloudRegionRestImplTest method mapCloudRegionVersionGreaterThan3Test.

@Test
public void mapCloudRegionVersionGreaterThan3Test() {
    CloudSite cloudSite2 = new CloudSite();
    cloudSite2.setCloudVersion("3.0.1");
    cloudSite2.setRegionId("region1");
    cloudSite2.setCloudOwner("bob");
    CloudRegion mappedRegion = cloudRestImpl.mapCloudRegion(cloudSite2);
    CloudRegion testRegion2 = new CloudRegion();
    testRegion2.setCloudOwner("bob");
    testRegion2.setCloudRegionId("region1");
    testRegion2.setCloudRegionVersion("3.0.1");
    testRegion2.setInMaint(false);
    testRegion2.setOrchestrationDisabled(false);
    testRegion2.setOwnerDefinedType("cLCP");
    testRegion2.setCloudType("openstack");
    testRegion2.setCloudZone("region");
    assertThat(mappedRegion, sameBeanAs(testRegion2));
}
Also used : CloudRegion(org.onap.aai.domain.yang.CloudRegion) CloudSite(org.onap.so.db.catalog.beans.CloudSite) Test(org.junit.Test)

Aggregations

CloudRegion (org.onap.aai.domain.yang.CloudRegion)6 Test (org.junit.Test)4 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)2 File (java.io.File)1 Complex (org.onap.aai.domain.yang.Complex)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)1 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)1 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)1 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)1 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)1 CloudSite (org.onap.so.db.catalog.beans.CloudSite)1 Service (org.onap.so.db.catalog.beans.Service)1 MavenLikeVersioning (org.onap.so.db.catalog.utils.MavenLikeVersioning)1 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)1