use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackStackService method getStacks.
/**
* Obtains a list (unfiltered) of all stacks that exist on the provider and returns them to the caller.
*
* @return A list of all stacks that exist. Note that the list may be empty.
* @throws ZoneException
* - If the context is closed, a login has not occurred, or an error happened trying to contact the
* provider.
* @see com.att.cdp.zones.StackService#getStacks()
*/
@Override
public List<Stack> getStacks() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Orchestration");
RequestState.put(RequestState.SERVICE_URL, connector.getEndpoint());
ArrayList<Stack> list = new ArrayList<>();
Heat heat = connector.getClient();
StackResource resource = heat.getStacks();
try {
/*
* Get a list of stacks, then call byName api for each one to get the detail for the stack.
*/
Stacks osStacks = resource.list().execute();
if (osStacks != null) {
for (com.woorea.openstack.heat.model.Stack osStack : osStacks) {
list.add(getStack(osStack.getStackName(), osStack.getId()));
}
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return list;
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackVolumeService method getVolumes.
/**
* Returns a list of volumes that match the supplied name
*
* @param name
* The name pattern of the volumes to be located. The name is a regular expression that is suitable for
* use in the Java String.matches() method.
* @return A list (potentially empty) of all volumes that match the specified name pattern
* @throws ZoneException
* - If the volume service cannot be accessed.
* @see java.lang.String#matches(String)
* @see com.att.cdp.zones.VolumeService#getVolumes(java.lang.String)
*/
@Override
public List<Volume> getVolumes(String name) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.VOLUME, name);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
ArrayList<Volume> list = new ArrayList<>();
try {
com.woorea.openstack.nova.model.Volumes volumes = nova.getClient().volumes().list(true).execute();
for (com.woorea.openstack.nova.model.Volume volume : volumes) {
if (name != null) {
if (volume.getName() != null && volume.getName().matches(name)) {
list.add(new OpenStackVolume(context, volume));
}
} else {
list.add(new OpenStackVolume(context, volume));
}
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return list;
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackVolumeService method createVolume.
/**
* This method is used to create a new volume using the Volume object (disconnected) as the model. When the method
* returns, a connected model object is returned that should be used for any model navigation desired.
*
* @param template
* The template of the volume to create. This must contain at least a name and size. Other information
* will be supplied if not present. Any ID is ignored, and the ID of the created volume is returned in
* the connected volume object returned to the caller.
* @return A Volume object that is connected to the service context and can be used to navigate the model.
* @throws ZoneException
* - If the volume cannot be created for some reason.
* @see com.att.cdp.zones.VolumeService#createVolume(com.att.cdp.zones.model.Volume)
*/
@SuppressWarnings("nls")
@Override
public Volume createVolume(Volume template) throws ZoneException {
checkArg(template, "template");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.VOLUME, template.getName());
RequestState.put(RequestState.SIZE, template.getSize());
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
try {
com.woorea.openstack.nova.model.VolumeForCreate newVolume = new com.woorea.openstack.nova.model.VolumeForCreate();
HashMap<String, String> dictionary = new HashMap<>();
dictionary.put("name", "name");
dictionary.put("description", "description");
dictionary.put("size", "size");
dictionary.put("snapshotId", "snapshotId");
dictionary.put("availabilityZone", "availabilityZone");
ObjectMapper.map(template, newVolume, dictionary);
OpenStackVolume volume = new OpenStackVolume(context, nova.getClient().volumes().create(newVolume).execute());
return volume;
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
// for the compiler
return null;
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackVolumeService method getVolume.
/**
* Returns information about the volume with the indicated id, if it exists.
*
* @param id
* The id of the volume that we want to find information about
* @return The volume if it exists
* @throws ZoneException
* - If the volume cannot be listed, or the volume does not exist
* @see com.att.cdp.zones.VolumeService#getVolume(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public Volume getVolume(String id) throws ZoneException {
checkArg(id, "id");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.VOLUME, id);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
try {
com.woorea.openstack.nova.model.Volume volume = nova.getClient().volumes().show(id).execute();
if (volume == null) {
throw new ResourceNotFoundException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_NOT_FOUND, "Volume", id, context.getProvider().getName()));
}
return new OpenStackVolume(context, volume);
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
// for the compiler
return null;
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackVolumeService method destroySnapshot.
/**
* This method can be called to destroy a snapshot.
*
* @param id
* The id of the snapshot to be destroyed.
* @throws ZoneException
* - If the snapshot cannot be destroyed.
* @see com.att.cdp.zones.VolumeService#destroySnapshot(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void destroySnapshot(String id) throws ZoneException {
checkArg(id, "id");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SNAPSHOT, id);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
try {
nova.getClient().snapshots().delete(id).execute();
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
}
Aggregations