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;
}
Aggregations