use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackVolumeService method getSnapshot.
/**
* Returns information about the snapshot with the indicated id, if it exists.
*
* @param id
* The id of the snapshot that we want to find information about
* @return The snapshot if it exists
* @throws ZoneException
* - If the snapshot cannot be listed, or the snapshot does not exist
* @see com.att.cdp.zones.VolumeService#getSnapshot(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public Snapshot getSnapshot(String id) throws ZoneException {
checkArg(id, "id");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SNAPSHOT, id);
RequestState.put(RequestState.SERVICE, "Volume");
RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
try {
com.woorea.openstack.cinder.model.Snapshot snapshot = cinder.getClient().snapshots().show(id).execute();
if (snapshot == null) {
throw new ResourceNotFoundException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_NOT_FOUND, "Snapshot", id, context.getProvider().getName()));
}
return new OpenStackSnapshot(context, snapshot);
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
// for the compiler
return null;
}
use of com.att.cdp.zones.Context 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, "Volume");
RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
try {
com.woorea.openstack.cinder.model.Volume volume = cinder.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.att.cdp.zones.Context 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, "Volume");
RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
try {
cinder.getClient().snapshots().delete(id).execute();
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackVolumeService method connect.
/**
* This is a helper method used to construct the Nova service object and setup the environment to access the
* OpenStack compute service (Nova).
*
* @throws NotLoggedInException
* If the user is not logged in
* @throws ContextClosedException
* If the user attempts an operation after the context is closed
*/
private void connect() throws NotLoggedInException, ContextClosedException {
checkLogin();
checkOpen();
Context context = getContext();
OpenStackContext osContext = (OpenStackContext) context;
cinder = osContext.getCinderConnector();
((OpenStackContext) context).refreshIfStale(cinder);
}
use of com.att.cdp.zones.Context 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, "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) {
list.add(new OpenStackVolume(context, volume));
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return list;
}
Aggregations