Search in sources :

Example 1 with ResourceGroupUsage

use of com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method buildCloudStackParameters.

private Map<String, String> buildCloudStackParameters(String environmentCrn) {
    Map<String, String> params = new HashMap<>();
    params.put(CLOUD_STACK_TYPE_PARAMETER, FREEIPA_STACK_TYPE);
    Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environmentCrn);
    if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) {
        AzureResourceGroup resourceGroup = resourceGroupOptional.get();
        String resourceGroupName = resourceGroup.getName();
        ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage();
        params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName);
        params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name());
    }
    return params;
}
Also used : ResourceGroupUsage(com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage) HashMap(java.util.HashMap) AzureResourceGroup(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup)

Example 2 with ResourceGroupUsage

use of com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage in project cloudbreak by hortonworks.

the class AzureCloudProvider method withResourceGroup.

@Override
public EnvironmentTestDto withResourceGroup(EnvironmentTestDto environmentTestDto, String resourceGroupUsageString, String resourceGroupName) {
    ResourceGroupUsage resourceGroupUsage = ResourceGroupUsage.valueOf(resourceGroupUsageString);
    if (environmentTestDto.getAzure() == null) {
        environmentTestDto.setAzure(AzureEnvironmentParameters.builder().build());
    }
    AzureEnvironmentParameters azureEnvironmentParameters = environmentTestDto.getAzure();
    azureEnvironmentParameters.setResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(resourceGroupUsage).withName(resourceGroupName).build());
    environmentTestDto.setAzure(azureEnvironmentParameters);
    return environmentTestDto;
}
Also used : ResourceGroupUsage(com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage) AzureEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)

Example 3 with ResourceGroupUsage

use of com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method buildCloudInstanceParameters.

public Map<String, Object> buildCloudInstanceParameters(DetailedEnvironmentResponse environment, InstanceMetaData instanceMetaData, CloudPlatform platform) {
    Map<String, Object> params = new HashMap<>();
    putIfPresent(params, CloudInstance.DISCOVERY_NAME, getIfNotNull(instanceMetaData, InstanceMetaData::getShortHostname));
    putIfPresent(params, SUBNET_ID, getIfNotNull(instanceMetaData, InstanceMetaData::getSubnetId));
    putIfPresent(params, CloudInstance.INSTANCE_NAME, getIfNotNull(instanceMetaData, InstanceMetaData::getInstanceName));
    putIfPresent(params, CloudInstance.FQDN, getIfNotNull(instanceMetaData, InstanceMetaData::getDiscoveryFQDN));
    Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environment, platform);
    if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) {
        AzureResourceGroup resourceGroup = resourceGroupOptional.get();
        String resourceGroupName = resourceGroup.getName();
        ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage();
        params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName);
        params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name());
    }
    return params;
}
Also used : ResourceGroupUsage(com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage) HashMap(java.util.HashMap) AzureResourceGroup(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup)

Example 4 with ResourceGroupUsage

use of com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method buildCloudStackParameters.

private Map<String, String> buildCloudStackParameters(Stack stack, DetailedEnvironmentResponse environment) {
    Map<String, String> params = new HashMap<>(stack.getParameters());
    Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environment, CloudPlatform.valueOf(stack.getCloudPlatform()));
    if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) {
        AzureResourceGroup resourceGroup = resourceGroupOptional.get();
        String resourceGroupName = resourceGroup.getName();
        ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage();
        params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName);
        params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name());
    }
    params.put(RESOURCE_CRN_PARAMETER, stack.getResourceCrn());
    return params;
}
Also used : ResourceGroupUsage(com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage) HashMap(java.util.HashMap) AzureResourceGroup(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup)

Example 5 with ResourceGroupUsage

use of com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method buildCloudInstanceParameters.

public Map<String, Object> buildCloudInstanceParameters(String environmentCrn, InstanceMetaData instanceMetaData) {
    String hostName = instanceMetaData == null ? null : instanceMetaData.getDiscoveryFQDN();
    String subnetId = instanceMetaData == null ? null : instanceMetaData.getSubnetId();
    String instanceName = instanceMetaData == null ? null : instanceMetaData.getInstanceName();
    Map<String, Object> params = new HashMap<>();
    if (hostName != null) {
        hostName = getFreeIpaHostname(instanceMetaData, hostName);
        LOGGER.debug("Setting FreeIPA hostname to {}", hostName);
        params.put(CloudInstance.DISCOVERY_NAME, hostName);
    }
    if (subnetId != null) {
        params.put(SUBNET_ID, subnetId);
    }
    if (instanceName != null) {
        params.put(CloudInstance.INSTANCE_NAME, instanceName);
    }
    Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environmentCrn);
    if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) {
        AzureResourceGroup resourceGroup = resourceGroupOptional.get();
        String resourceGroupName = resourceGroup.getName();
        ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage();
        params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName);
        params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name());
    }
    return params;
}
Also used : ResourceGroupUsage(com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage) HashMap(java.util.HashMap) AzureResourceGroup(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup)

Aggregations

ResourceGroupUsage (com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage)6 AzureResourceGroup (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup)5 HashMap (java.util.HashMap)4 Json (com.sequenceiq.cloudbreak.common.json.Json)1 AzureEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 Map (java.util.Map)1 Optional (java.util.Optional)1