use of com.woorea.openstack.nova.model.VolumeAttachment in project AJSC by att.
the class OpenStackComputeService method getAttachments.
/**
* Returns a map of the volume attachments for the specified server. The key of the map is the device name for the
* volume attachment. This is the device identification which the server will "see".
*
* @param id
* The server ID for which we wish to obtain all attachments (if any).
* @return A map of the volume attachments, or an empty map if there are none. The map is keyed by the device name
* used to attach the volume. The value of the entry is the ID of the volume attached at that device.
* @throws ZoneException
* - If the attachments cannot be obtained
* @see com.att.cdp.zones.ComputeService#getAttachments(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public Map<String, String> getAttachments(String id) throws ZoneException {
checkArg(id, "id");
connect();
trackRequest();
RequestState.put(RequestState.SERVER, id);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
HashMap<String, String> map = new HashMap<>();
try {
for (VolumeAttachment attachment : nova.getClient().servers().listVolumeAttachments(id).execute()) {
RequestState.put(RequestState.VOLUME, attachment.getVolumeId());
if (attachment.getDevice() != null) {
RequestState.put(RequestState.DEVICE, attachment.getDevice());
map.put(attachment.getDevice(), attachment.getVolumeId());
} else {
System.err.println("No device found for " + attachment);
}
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
} catch (Exception e) {
throw new ZoneException("Error obtaining volume attachments.", e);
}
return map;
}
use of com.woorea.openstack.nova.model.VolumeAttachment in project AJSC by att.
the class OpenStackComputeService method getAttachments.
/**
* Returns a map of the volume attachments for the specified server. The key
* of the map is the device name for the volume attachment. This is the
* device identification which the server will "see".
*
* @param id
* The server ID for which we wish to obtain all attachments (if
* any).
* @return A map of the volume attachments, or an empty map if there are
* none. The map is keyed by the device name used to attach the
* volume. The value of the entry is the ID of the volume attached
* at that device.
* @throws ZoneException
* - If the attachments cannot be obtained
* @see com.att.cdp.zones.ComputeService#getAttachments(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public Map<String, String> getAttachments(String id) throws ZoneException {
checkArg(id, "id");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVER, id);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
HashMap<String, String> map = new HashMap<>();
try {
for (VolumeAttachment attachment : nova.getClient().servers().listVolumeAttachments(id).execute()) {
RequestState.put(RequestState.VOLUME, attachment.getVolumeId());
if (attachment.getDevice() != null) {
RequestState.put(RequestState.DEVICE, attachment.getDevice());
map.put(attachment.getDevice(), attachment.getVolumeId());
} else {
System.err.println("No device found for " + attachment);
}
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
} catch (Exception e) {
throw new ZoneException("Error obtaining volume attachments.", e);
}
return map;
}
Aggregations