use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackVolumeService method getSnapshotsByVolume.
/**
* @see com.att.cdp.zones.VolumeService#getSnapshotsByVolume(java.lang.String)
*/
@Override
public List<Snapshot> getSnapshotsByVolume(String id) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.VOLUME, id);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
ArrayList<Snapshot> list = new ArrayList<>();
try {
com.woorea.openstack.nova.model.Snapshots snapshots = nova.getClient().snapshots().list(true).execute();
for (com.woorea.openstack.nova.model.Snapshot snap : snapshots) {
if (id != null) {
if (snap.getVolumeId() != null && snap.getVolumeId().matches(id)) {
list.add(new OpenStackSnapshot(context, snap));
}
}
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return list;
}
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;
nova = osContext.getNovaConnector();
((OpenStackContext) context).refreshIfStale(nova);
}
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, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
try {
com.woorea.openstack.nova.model.Snapshot snapshot = nova.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 OpenStackComputeService method getTemplate.
/**
* Obtains the template specified by the provided id
*
* @see com.att.cdp.zones.ComputeService#getTemplate(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public Template getTemplate(String id) throws ZoneException {
checkArg(id, "id");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
RequestState.put(RequestState.TEMPLATE, id);
try {
return new OpenStackTemplate(context, nova.getClient().flavors().show(id).execute());
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
} catch (Exception e) {
throw new ResourceNotFoundException(e);
}
// for the compiler
return null;
}
use of com.att.cdp.zones.Context in project AJSC by att.
the class OpenStackComputeService method getServers.
/**
* Obtain a list of servers from the compute service.
*
* @return The list of servers that are defined.
* @throws ZoneException
* - If any of the following conditions are true:
* <ul>
* <li>the user has not successfully logged in to the provider</li>
* <li>the context has been closed and this service is requested</li>
* <li>the current user does not have the rights to perform this operation</li>
* <li>the user and/or credentials are not valid</li>
* </ul>
* @see com.att.cdp.zones.ComputeService#getServers()
*/
@Override
public List<Server> getServers() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
ArrayList<Server> list = new ArrayList<>();
try {
com.woorea.openstack.nova.model.Servers servers = nova.getClient().servers().list(true).execute();
for (com.woorea.openstack.nova.model.Server s : servers.getList()) {
list.add(new OpenStackServer(context, s));
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return list;
}
Aggregations