use of com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException in project cloudbreak by hortonworks.
the class OpenStackRouterResourceBuilder method delete.
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource, Network network) {
try {
OSClient<?> osClient = createOSClient(auth);
NeutronNetworkView networkView = new NeutronNetworkView(network);
if (!networkView.isExistingSubnet()) {
String subnetId = context.getStringParameter(OpenStackConstants.SUBNET_ID);
osClient.networking().router().detachInterface(resource.getReference(), subnetId, null);
}
if (!networkView.isExistingNetwork()) {
ActionResponse response = osClient.networking().router().delete(resource.getReference());
return checkDeleteResponse(response, resourceType(), auth, resource, "Router deletion failed");
}
return null;
} catch (OS4JException ex) {
throw new OpenStackResourceException("Router deletion failed", resourceType(), resource.getName(), ex);
}
}
use of com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException in project cloudbreak by hortonworks.
the class OpenStackSubnetResourceBuilder method build.
@Override
public CloudResource build(OpenStackContext context, AuthenticatedContext auth, Network network, Security security, CloudResource resource) {
try {
NeutronNetworkView neutronView = new NeutronNetworkView(network);
String subnetId = neutronView.isExistingSubnet() ? neutronView.getCustomSubnetId() : context.getParameter(SUBNET_ID, String.class);
if (!neutronView.isExistingSubnet()) {
OSClient<?> osClient = createOSClient(auth);
NeutronNetworkView networkView = new NeutronNetworkView(network);
Subnet subnet = Builders.subnet().name(resource.getName()).networkId(context.getParameter(OpenStackConstants.NETWORK_ID, String.class)).tenantId(context.getStringParameter(OpenStackConstants.TENANT_ID)).ipVersion(IPVersionType.V4).cidr(networkView.getSubnetCIDR()).enableDHCP(true).build();
subnetId = osClient.networking().subnet().create(subnet).getId();
}
context.putParameter(SUBNET_ID, subnetId);
return createPersistedResource(resource, subnetId);
} catch (OS4JException ex) {
throw new OpenStackResourceException("Subnet creation failed", resourceType(), resource.getName(), ex);
}
}
use of com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException in project cloudbreak by hortonworks.
the class OpenStackSubnetResourceBuilder method delete.
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource, Network network) {
try {
NeutronNetworkView neutronView = new NeutronNetworkView(network);
if (!neutronView.isExistingSubnet()) {
OSClient<?> osClient = createOSClient(auth);
ActionResponse response = osClient.networking().subnet().delete(resource.getReference());
return checkDeleteResponse(response, resourceType(), auth, resource, "Subnet deletion failed");
}
return null;
} catch (OS4JException ex) {
throw new OpenStackResourceException("Subnet deletion failed", resourceType(), resource.getName(), ex);
}
}
use of com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException in project cloudbreak by hortonworks.
the class OpenStackAttachedDiskResourceBuilder method delete.
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource) {
try {
OSClient<?> osClient = createOSClient(auth);
ActionResponse response = osClient.blockStorage().volumes().delete(resource.getReference());
return checkDeleteResponse(response, resourceType(), auth, resource, "Volume deletion failed");
} catch (OS4JException ex) {
throw new OpenStackResourceException("Volume deletion failed", resourceType(), resource.getName(), ex);
}
}
use of com.sequenceiq.cloudbreak.cloud.openstack.nativ.OpenStackResourceException in project cloudbreak by hortonworks.
the class OpenStackInstanceBuilder method delete.
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource) {
try {
OSClient<?> osClient = createOSClient(auth);
ActionResponse response = osClient.compute().servers().delete(resource.getReference());
return checkDeleteResponse(response, resourceType(), auth, resource, "Instance deletion failed");
} catch (OS4JException ex) {
throw new OpenStackResourceException("Instance deletion failed", resourceType(), resource.getName(), ex);
}
}
Aggregations