use of com.att.cdp.openstack.model.OpenStackVolume in project AJSC by att.
the class OpenStackVolumeService method getVolumes.
/**
* Retrieves the list of volumes defined for this service.
*
* @return The list of volumes for this tenant, if any. The list may be empty if there are no volumes defined.
* @see com.att.cdp.zones.VolumeService#getVolumes()
*/
@Override
public List<Volume> getVolumes() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
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) {
list.add(new OpenStackVolume(context, volume));
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return list;
}
use of com.att.cdp.openstack.model.OpenStackVolume 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, "Volume");
RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
try {
com.woorea.openstack.cinder.model.VolumeForCreate newVolume = new com.woorea.openstack.cinder.model.VolumeForCreate();
HashMap<String, String> dictionary = new HashMap<>();
dictionary.put("name", "name");
dictionary.put("description", "description");
dictionary.put("size", "size");
dictionary.put("snapshot_id", "snapshot_id");
dictionary.put("availability_zone", "availability_zone");
dictionary.put("source_volid", "source_volid");
dictionary.put("imageRef", "imageRef");
dictionary.put("volume_type", "volume_type");
dictionary.put("status", "status");
dictionary.put("user_id", "user_id");
dictionary.put("consistencygroup_id", "consistencygroup_id");
dictionary.put("source_replica", "source_replica");
ObjectMapper.map(template, newVolume, dictionary);
OpenStackVolume volume = new OpenStackVolume(context, cinder.getClient().volumes().create(newVolume).execute());
return volume;
} catch (OpenStackBaseException ex) {
ex.printStackTrace();
ExceptionMapper.mapException(ex);
}
// for the compiler
return null;
}
use of com.att.cdp.openstack.model.OpenStackVolume 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, "Volume");
RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
ArrayList<Volume> list = new ArrayList<>();
try {
com.woorea.openstack.cinder.model.Volumes volumes = cinder.getClient().volumes().list(true).execute();
for (com.woorea.openstack.cinder.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;
}
Aggregations