use of com.att.cdp.exceptions.InvalidRequestException in project AJSC by att.
the class ConnectedServer method assignIpAddressFromPool.
/**
* @see com.att.cdp.zones.model.Server#assignIpAddressFromPool()
*/
@Override
public String assignIpAddressFromPool() throws ZoneException {
Context context = getContext();
List<String> pools = context.getNetworkService().getFloatingIpPools();
if (pools == null || pools.isEmpty()) {
throw new InvalidRequestException(EELFResourceManager.format(Msg.NO_FLOATING_IP_POOL));
}
return assignIpAddressFromPool(pools.get(0));
}
use of com.att.cdp.exceptions.InvalidRequestException in project AJSC by att.
the class OpenStackComputeService method attachVolume.
/**
* Attach a volume to a specified server. The volume is then attached to the
* server for it to use when the server is started.
*
* @param server
* The server we are manipulating
* @param volume
* The volume we wish to attach to the server
* @param deviceName
* the name of the device presented to the server
* @throws ZoneException
* If the volume cannot be attached for some reason
* @see com.att.cdp.zones.ComputeService#attachVolume(com.att.cdp.zones.model.Server,
* com.att.cdp.zones.model.Volume, java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void attachVolume(Server server, Volume volume, String deviceName) throws ZoneException {
checkArg(server, "server");
checkArg(volume, "volume");
checkArg(deviceName, "deviceName");
if (!checkDeviceName(deviceName)) {
throw new InvalidRequestException(EELFResourceManager.format(OSMsg.PAL_OS_INVALID_DEVICE_NAME, deviceName));
}
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVER, server);
RequestState.put(RequestState.VOLUME, volume.getId());
RequestState.put(RequestState.DEVICE, volume.getId());
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
/*
* Get the list of existing attachments and check to see if the device
* name is already used
*/
Map<String, String> attachments = getAttachments(server);
if (attachments.containsKey(deviceName)) {
throw new InvalidRequestException(EELFResourceManager.format(OSMsg.PAL_OS_INVALID_DEVICE_NAME, deviceName));
}
/*
* Check the server status to see if it is correct for attempting the
* attachment
*/
server.refreshStatus();
Server.Status status = server.getStatus();
RequestState.put(RequestState.STATUS, status.toString());
if (status.equals(Server.Status.RUNNING) || status.equals(Server.Status.READY)) {
try {
nova.getClient().servers().attachVolume(server.getId(), volume.getId(), deviceName).execute();
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
} else {
throw new ZoneException(EELFResourceManager.format(OSMsg.PAL_OS_INVALID_SERVER_STATE, server.getName(), server.getId().toString(), status.toString(), EELFResourceManager.asList(Server.Status.READY.toString(), Server.Status.RUNNING.toString())));
}
}
Aggregations