use of com.att.cdp.exceptions.ResourceNotFoundException in project AJSC by att.
the class AbstractOpenStackIdentityService method getRoles.
/**
* @see com.att.cdp.zones.IdentityService#getRoles()
*/
@SuppressWarnings("nls")
@Override
public List<String> getRoles() throws ZoneException {
trackRequest();
Context context = getContext();
ArrayList<String> list = new ArrayList<>();
if (context.isLoggedIn()) {
try {
keystoneUrl = context.getProperties().getProperty(ContextFactory.PROPERTY_IDENTITY_URL);
// tenantName = context.getProperties().getProperty(ContextFactory.PROPERTY_TENANT);
Keystone keystone = new Keystone(keystoneUrl);
OpenStackRequest<Roles> request = new OpenStackRequest<>(keystone, HttpMethod.GET, "/users/" + context.getPrincipal() + "/roles", null, Roles.class);
Roles roles;
try {
roles = keystone.execute(request);
} catch (OpenStackConnectException e) {
throw new ContextConnectionException(EELFResourceManager.format(OSMsg.PAL_OS_CONNECTION_FAILED, "Identity", keystoneUrl), e);
}
for (Role role : roles.getList()) {
list.add(role.getName());
}
} catch (OpenStackResponseException e) {
if (e.getStatus() == 404) {
throw new ResourceNotFoundException("Attempt to get roles for user " + context.getPrincipal(), e);
}
throw new ZoneException("Attempt to get roles for user " + context.getPrincipal(), e);
}
}
return list;
}
use of com.att.cdp.exceptions.ResourceNotFoundException 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.exceptions.ResourceNotFoundException in project AJSC by att.
the class OpenStackSnapshotService 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.SnapshotService#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.exceptions.ResourceNotFoundException in project AJSC by att.
the class OpenStackSnapshotService 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.SnapshotService#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;
}
Aggregations