Search in sources :

Example 1 with CloudConfigurationNotFoundException

use of org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException 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 CloudConfigurationNotFoundException

use of org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException 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 CloudConfigurationNotFoundException

use of org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException in project so by onap.

the class ServiceInstances method getCloudConfigurationOnReplace.

protected CloudConfiguration getCloudConfigurationOnReplace(String requestScope, HashMap<String, String> instanceIdMap, InfraActiveRequests currentActiveReq) throws ApiException {
    logger.debug("Replace request is missing cloudConfiguration, autofilling from create.");
    CloudConfiguration cloudConfiguration = null;
    if (requestScope.equals(ModelType.vfModule.toString())) {
        cloudConfiguration = bpmnRequestBuilder.getCloudConfigurationVfModuleReplace(instanceIdMap.get("vnfInstanceId"), instanceIdMap.get("vfModuleInstanceId"));
    } else {
        cloudConfiguration = bpmnRequestBuilder.mapCloudConfigurationVnf(instanceIdMap.get("vnfInstanceId"));
    }
    if (cloudConfiguration == null) {
        String errorMessage = "CloudConfiguration not found during autofill for replace request.";
        logger.error(errorMessage);
        updateStatus(currentActiveReq, Status.FAILED, errorMessage);
        throw new CloudConfigurationNotFoundException("CloudConfiguration not found during autofill for replace request.");
    }
    return cloudConfiguration;
}
Also used : CloudConfigurationNotFoundException(org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration)

Example 4 with CloudConfigurationNotFoundException

use of org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException in project so by onap.

the class BpmnRequestBuilder method mapCloudConfigurationVnf.

public CloudConfiguration mapCloudConfigurationVnf(String vnfId) {
    CloudConfiguration cloudConfig = new CloudConfiguration();
    String tenantId = null;
    String cloudOwner = null;
    String lcpRegionId = null;
    Map<String, String[]> filters = createQueryRequest("vnfId", vnfId);
    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)

Example 5 with CloudConfigurationNotFoundException

use of org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException in project so by onap.

the class BpmnRequestBuilder method mapCloudConfigurationNetwork.

public CloudConfiguration mapCloudConfigurationNetwork(L3Network network) {
    CloudConfiguration cloudConfig = new CloudConfiguration();
    String tenantId = null;
    String cloudOwner = null;
    String lcpRegionId = null;
    Map<String, String[]> filters = createQueryRequest("networkId", network.getNetworkId());
    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)

Aggregations

CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)5 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)5 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)4 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)2