use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackComputeService method deleteAccessControlList.
/**
* @see com.att.cdp.zones.ComputeService#deleteAccessControlList(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void deleteAccessControlList(String id) throws ZoneException {
checkArg(id, "id");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
try {
nova.getClient().securityGroups().deleteSecurityGroup(id).execute();
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackComputeService method getServer.
/**
* Returns the indicated host using the specified identification token
*
* @param id
* The identification of the server
* @return The server
* @throws ZoneException
* - If the host cannot be found
* @see com.att.cdp.zones.ComputeService#getServer(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public Server getServer(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());
try {
com.woorea.openstack.nova.model.Server s = nova.getClient().servers().show(id).execute();
return new OpenStackServer(context, s);
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
// for the compiler
return null;
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackComputeService method getServers.
/**
* Returns the list of servers that match the name pattern supplied.
*
* @param name
* A regular expression that can be used to filter server names.
* A string that is suitable to use in the Java
* <code>String.matches()</code> method.
* @return The server
* @throws ZoneException
* If the host cannot be found
* @see java.lang.String#matches(String)
* @see com.att.cdp.zones.ComputeService#getServers(java.lang.String)
*/
@Override
public List<Server> getServers(String name) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
RequestState.put(RequestState.SERVER, name);
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()) {
if (name != null) {
if (s.getName().matches(name)) {
list.add(new OpenStackServer(context, s));
}
} else {
list.add(new OpenStackServer(context, s));
}
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return list;
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackComputeService method deleteServer.
/**
* Delete the specified server using it's id.
*
* @param serverId
* The server to be deleted.
* @throws ZoneException
* If the server does not exist or cannot be deleted for some
* reason.
* @see com.att.cdp.zones.ComputeService#deleteServer(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void deleteServer(String serverId) throws ZoneException {
checkArg(serverId, "serverId");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVER, serverId);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
try {
Server server = getServer(serverId);
Server.Status status = server.getStatus();
RequestState.put(RequestState.STATUS, status.toString());
if (status.equals(Server.Status.RUNNING) || status.equals(Server.Status.READY) || status.equals(Server.Status.ERROR)) {
List<Port> ports = server.getPorts();
for (Port port : ports) {
port.delete();
}
nova.getClient().servers().delete(serverId).execute();
} else {
throw new ZoneException(EELFResourceManager.format(OSMsg.PAL_OS_INVALID_SERVER_STATE, server.getName(), server.getId(), status.toString(), StringHelper.asList(Arrays.asList(Server.Status.READY.toString(), Server.Status.RUNNING.toString(), Server.Status.ERROR.toString()))));
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackComputeService method detachVolume.
/**
* Detaches the volume from the specified server.
*
* @param server
* The server to be manipulated
* @param deviceName
* The device to be detached
* @throws ZoneException
* If the volume cannot be detached for some reason
* @see com.att.cdp.zones.ComputeService#detachVolume(com.att.cdp.zones.model.Server,
* java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void detachVolume(Server server, String deviceName) throws ZoneException {
checkArg(server, "server");
checkArg(deviceName, "deviceName");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVER, server.getName());
RequestState.put(RequestState.DEVICE, deviceName);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
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 {
Map<String, String> attachments = getAttachments(server);
for (Map.Entry<String, String> entry : attachments.entrySet()) {
if (entry.getKey().equals(deviceName)) {
nova.getClient().servers().detachVolume(server.getId(), entry.getValue()).execute();
}
break;
}
} 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(), StringHelper.asList(Arrays.asList(Server.Status.READY.toString(), Server.Status.RUNNING.toString()))));
}
}
Aggregations