use of com.sequenceiq.cloudbreak.cloud.model.ResourceStatus 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;
}
use of com.sequenceiq.cloudbreak.cloud.model.ResourceStatus in project cloudbreak by hortonworks.
the class AbstractOpenStackResourceBuilder method checkResources.
protected List<CloudResourceStatus> checkResources(ResourceType type, OpenStackContext context, AuthenticatedContext auth, Iterable<CloudResource> resources) {
List<CloudResourceStatus> result = new ArrayList<>();
for (CloudResource resource : resources) {
LOGGER.info("Check {} resource: {}", type, resource);
try {
boolean finished = checkStatus(context, auth, resource);
ResourceStatus successStatus = context.isBuild() ? ResourceStatus.CREATED : ResourceStatus.DELETED;
result.add(new CloudResourceStatus(resource, finished ? successStatus : ResourceStatus.IN_PROGRESS));
if (finished) {
if (successStatus == ResourceStatus.CREATED) {
LOGGER.info("Creation of {} was successful", resource);
} else {
LOGGER.info("Deletion of {} was successful", resource);
}
}
} catch (OS4JException ex) {
throw new OpenStackResourceException("Error during status check", type, resource.getName(), ex);
}
}
return result;
}
use of com.sequenceiq.cloudbreak.cloud.model.ResourceStatus in project cloudbreak by hortonworks.
the class ResourceStatusLists method aggregate.
public static CloudResourceStatus aggregate(Iterable<CloudResourceStatus> cloudResourceStatuses) {
ResourceStatus status = null;
StringBuilder statusReason = new StringBuilder();
for (CloudResourceStatus crs : cloudResourceStatuses) {
ResourceStatus currentStatus = crs.getStatus();
if (status == null) {
status = currentStatus;
}
switch(currentStatus) {
case FAILED:
status = currentStatus;
statusReason.append(crs.getStatusReason()).append('\n');
break;
default:
if (currentStatus.isTransient()) {
status = currentStatus;
}
}
}
if (status == null) {
status = ResourceStatus.FAILED;
statusReason.append("Resources does not have any state");
}
return new CloudResourceStatus(null, status, statusReason.toString());
}
use of com.sequenceiq.cloudbreak.cloud.model.ResourceStatus in project cloudbreak by hortonworks.
the class AbstractGcpResourceBuilder method checkResources.
protected List<CloudResourceStatus> checkResources(ResourceType type, GcpContext context, AuthenticatedContext auth, Iterable<CloudResource> resources) {
List<CloudResourceStatus> result = new ArrayList<>();
for (CloudResource resource : resources) {
LOGGER.info("Check {} resource: {}", type, resource);
try {
Operation operation = check(context, resource);
boolean finished = operation == null || GcpStackUtil.isOperationFinished(operation);
ResourceStatus successStatus = context.isBuild() ? ResourceStatus.CREATED : ResourceStatus.DELETED;
result.add(new CloudResourceStatus(resource, finished ? successStatus : ResourceStatus.IN_PROGRESS));
if (finished) {
if (successStatus == ResourceStatus.CREATED) {
LOGGER.info("Creation of {} was successful", resource);
} else {
LOGGER.info("Deletion of {} was successful", resource);
}
}
} catch (Exception e) {
CloudContext cloudContext = auth.getCloudContext();
throw new GcpResourceException("Error during status check", type, cloudContext.getName(), cloudContext.getId(), resource.getName(), e);
}
}
return result;
}
Aggregations