Search in sources :

Example 81 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method createAccessControlList.

/**
 * @see com.att.cdp.zones.ComputeService#createAccessControlList(com.att.cdp.zones.model.ACL)
 */
@SuppressWarnings("nls")
@Override
public ACL createAccessControlList(ACL model) throws ZoneException {
    checkArg(model, "model");
    checkArg(model.getName(), "name");
    checkArg(model.getDescription(), "description");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    SecurityGroupForCreate create = new SecurityGroupForCreate();
    create.setName(model.getName());
    create.setDescription(model.getDescription());
    try {
        SecurityGroup group = nova.getClient().securityGroups().createSecurityGroup(create).execute();
        return new OpenStackACL(context, group);
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) SecurityGroupForCreate(com.woorea.openstack.nova.model.SecurityGroupForCreate) SecurityGroup(com.woorea.openstack.nova.model.SecurityGroup) OpenStackACL(com.att.cdp.openstack.model.OpenStackACL)

Example 82 with OpenStackBaseException

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(java.lang.String)
 */
@Override
public List<Hypervisor> getHypervisors(String id) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    RequestState.put(RequestState.HYPERVISOR, id);
    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()) {
            if (id != null) {
                if (h.getId().matches(id)) {
                    list.add(new OpenStackHypervisor(context, h));
                }
            } else {
                list.add(new OpenStackHypervisor(context, h));
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackHypervisor(com.att.cdp.openstack.model.OpenStackHypervisor) Hypervisor(com.att.cdp.zones.model.Hypervisor) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) OpenStackHypervisor(com.att.cdp.openstack.model.OpenStackHypervisor)

Example 83 with OpenStackBaseException

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;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer)

Example 84 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method getAccessControlLists.

/**
 * @see com.att.cdp.zones.ComputeService#getAccessControlLists()
 */
@Override
public List<ACL> getAccessControlLists() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<ACL> list = new ArrayList<>();
    try {
        for (SecurityGroup group : nova.getClient().securityGroups().listSecurityGroups().execute()) {
            list.add(new OpenStackACL(context, group));
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) OpenStackACL(com.att.cdp.openstack.model.OpenStackACL) ACL(com.att.cdp.zones.model.ACL) SecurityGroup(com.woorea.openstack.nova.model.SecurityGroup) OpenStackACL(com.att.cdp.openstack.model.OpenStackACL)

Example 85 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method rebuildServer.

/**
 * Rebuilds the server from a supplied snapshot
 *
 * @see com.att.cdp.zones.ComputeService#rebuildServer(com.att.cdp.zones.model.Server, java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public void rebuildServer(Server server, String snapshot) throws ZoneException {
    checkArg(server, "server");
    checkArg(snapshot, "snapshot");
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVER, server.getId());
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    Rebuild rebuild = new Rebuild();
    rebuild.setImageRef(snapshot);
    try {
        nova.getClient().servers().rebuild(server.getId(), rebuild).execute();
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Rebuild(com.woorea.openstack.nova.model.ServerAction.Rebuild)

Aggregations

OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)151 OpenStackContext (com.att.cdp.openstack.OpenStackContext)140 Context (com.att.cdp.zones.Context)140 ArrayList (java.util.ArrayList)54 Quantum (com.woorea.openstack.quantum.Quantum)36 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)18 ZoneException (com.att.cdp.exceptions.ZoneException)15 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)14 Server (com.att.cdp.zones.model.Server)11 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)11 HashMap (java.util.HashMap)11 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)10 Snapshot (com.att.cdp.zones.model.Snapshot)10 OpenStackACL (com.att.cdp.openstack.model.OpenStackACL)8 OpenStackImage (com.att.cdp.openstack.model.OpenStackImage)8 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)8 OpenStackVolume (com.att.cdp.openstack.model.OpenStackVolume)8 OpenStackNetwork (com.att.cdp.openstack.model.OpenStackNetwork)7 Network (com.att.cdp.zones.model.Network)7 Port (com.att.cdp.zones.model.Port)7