use of com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException in project cloudbreak by hortonworks.
the class OpenStackNetworkResourceBuilder method delete.
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource, Network network) {
try {
OSClient<?> osClient = createOSClient(auth);
deAllocateFloatingIps(context, osClient);
NeutronNetworkView neutronView = new NeutronNetworkView(network);
if (!neutronView.isExistingNetwork()) {
ActionResponse response = osClient.networking().network().delete(resource.getReference());
return checkDeleteResponse(response, resourceType(), auth, resource, "Network deletion failed");
}
return null;
} catch (OS4JException ex) {
throw new OpenStackResourceException("Network deletion failed", resourceType(), resource.getName(), ex);
}
}
use of com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException in project cloudbreak by hortonworks.
the class OpenStackRouterResourceBuilder method checkStatus.
@Override
protected boolean checkStatus(OpenStackContext context, AuthenticatedContext auth, CloudResource resource) {
CloudContext cloudContext = auth.getCloudContext();
OSClient<?> osClient = createOSClient(auth);
Router osRouter = osClient.networking().router().get(resource.getReference());
if (osRouter != null && context.isBuild()) {
State routerStatus = osRouter.getStatus();
if (State.ERROR == routerStatus) {
throw new OpenStackResourceException("Router in failed state", resource.getType(), utils.getStackName(auth), cloudContext.getId(), resource.getName());
}
return routerStatus == State.ACTIVE;
} else {
return osRouter == null && !context.isBuild();
}
}
use of com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException 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();
}
}
Aggregations