Search in sources :

Example 1 with Status

use of org.openstack4j.model.storage.block.Volume.Status in project cloudbreak by hortonworks.

the class OpenStackAttachedDiskResourceBuilder method checkStatus.

@Override
protected boolean checkStatus(OpenStackContext context, AuthenticatedContext auth, CloudResource resource) {
    CloudContext cloudContext = auth.getCloudContext();
    OSClient<?> osClient = createOSClient(auth);
    Volume osVolume = osClient.blockStorage().volumes().get(resource.getReference());
    if (osVolume != null && context.isBuild()) {
        Status volumeStatus = osVolume.getStatus();
        if (Status.ERROR == volumeStatus || Status.ERROR_DELETING == volumeStatus || Status.ERROR_RESTORING == osVolume.getStatus()) {
            throw new OpenStackResourceException("Volume in failed state", resource.getType(), resource.getName(), cloudContext.getId(), volumeStatus.name());
        }
        return volumeStatus == Status.AVAILABLE;
    } else {
        return osVolume == null && !context.isBuild();
    }
}
Also used : Status(org.openstack4j.model.storage.block.Volume.Status) Volume(org.openstack4j.model.storage.block.Volume) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) OpenStackResourceException(com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException)

Aggregations

CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 OpenStackResourceException (com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException)1 Volume (org.openstack4j.model.storage.block.Volume)1 Status (org.openstack4j.model.storage.block.Volume.Status)1