use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackComputeService method getTemplates.
/**
* This method returns a list of templates that are available.
* <p>
* A template represents a definition of a hardware environment that is used to create an image. This includes
* number of cpu's, amount of memory, etc.
* </p>
*
* @return A list of available templates
* @throws ZoneException
* If the templates cannot be listed
* @see com.att.cdp.zones.ComputeService#getTemplates()
*/
@Override
public List<Template> getTemplates() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
ArrayList<Template> list = new ArrayList<>();
try {
com.woorea.openstack.nova.model.Flavors flavors = nova.getClient().flavors().list(true).execute();
for (com.woorea.openstack.nova.model.Flavor f : flavors.getList()) {
Template template = new OpenStackTemplate(context, f);
list.add(template);
}
} 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 processResize.
/**
* @see com.att.cdp.zones.ComputeService#processResize(com.att.cdp.zones.model.Server)
*/
@SuppressWarnings("nls")
@Override
public void processResize(Server server) throws ZoneException {
checkArg(server, "server");
checkArg(server.getId(), "server id");
connect();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
try {
OpenStackResponse request = nova.getClient().servers().confirmResize(server.getId()).request();
if (request != null && request.getStatus() != Status.NO_CONTENT.getStatusCode()) {
throw new ZoneException(request.getEntity(String.class));
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
}
use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.
the class OpenStackComputeService method getHypervisors.
/**
* @see com.att.cdp.zones.ComputeService#getHypervisors()
*/
@Override
public List<Hypervisor> getHypervisors() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
ArrayList<Hypervisor> list = new ArrayList<>();
try {
com.woorea.openstack.nova.model.Hypervisors hypervisors = nova.getClient().hypervisors().list(true).execute();
for (com.woorea.openstack.nova.model.Hypervisor h : hypervisors.getList()) {
list.add(new OpenStackHypervisor(context, h));
}
} 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 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 {
// checkArg(name, "name");
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 findAllServersUsingKey.
/**
* @see com.att.cdp.zones.ComputeService#findAllServersUsingKey(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public List<String> findAllServersUsingKey(String keyPair) throws ZoneException {
checkArg(keyPair, "keyPair");
connect();
trackRequest();
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
RequestState.put(RequestState.KEYPAIR, keyPair);
List<String> users = new ArrayList<String>();
try {
Servers servers = nova.getClient().servers().list(false).execute();
for (com.woorea.openstack.nova.model.Server server : servers.getList()) {
if (keyPair.equals(server.getKeyName())) {
users.add(server.getId());
}
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return users;
}
Aggregations