Search in sources :

Example 1 with DeploymentOperations

use of com.microsoft.azure.management.resources.DeploymentOperations in project cloudbreak by hortonworks.

the class AzureUtils method getTemplateStatus.

public CloudResourceStatus getTemplateStatus(CloudResource resource, Deployment templateDeployment, AzureClient access, String stackName) {
    String status = templateDeployment.provisioningState();
    LOGGER.info("Azure stack status of: {}  is: {}", resource.getName(), status);
    ResourceStatus resourceStatus = AzureStackStatus.mapResourceStatus(status);
    CloudResourceStatus armResourceStatus = null;
    if (ResourceStatus.FAILED.equals(resourceStatus)) {
        LOGGER.debug("Cloud resource status: {}", resourceStatus);
        try {
            // TODO: discuss with Doktorics why this is needed
            DeploymentOperations templateDeploymentOperations = access.getTemplateDeploymentOperations(stackName, stackName);
            for (DeploymentOperation deploymentOperation : templateDeploymentOperations.list()) {
                if ("Failed".equals(deploymentOperation.provisioningState())) {
                    String statusMessage = (String) deploymentOperation.statusMessage();
                    armResourceStatus = new CloudResourceStatus(resource, AzureStackStatus.mapResourceStatus(status), statusMessage);
                    break;
                }
            }
        } catch (RuntimeException e) {
            armResourceStatus = new CloudResourceStatus(resource, AzureStackStatus.mapResourceStatus(status), e.getMessage());
        }
    } else {
        LOGGER.debug("Cloud resource status: {}", resourceStatus);
        armResourceStatus = new CloudResourceStatus(resource, AzureStackStatus.mapResourceStatus(status));
    }
    return armResourceStatus;
}
Also used : CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) ResourceStatus(com.sequenceiq.cloudbreak.cloud.model.ResourceStatus) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) DeploymentOperation(com.microsoft.azure.management.resources.DeploymentOperation) DeploymentOperations(com.microsoft.azure.management.resources.DeploymentOperations)

Aggregations

DeploymentOperation (com.microsoft.azure.management.resources.DeploymentOperation)1 DeploymentOperations (com.microsoft.azure.management.resources.DeploymentOperations)1 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)1 ResourceStatus (com.sequenceiq.cloudbreak.cloud.model.ResourceStatus)1