Search in sources :

Example 61 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackComputeService method prepareResize.

/**
 * @see com.att.cdp.zones.ComputeService#prepareResize(com.att.cdp.zones.model.Server,
 *      java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public void prepareResize(Server server, Template newTemplate) throws ZoneException {
    checkArg(server, "server");
    checkArg(server.getId(), "server id");
    checkArg(newTemplate, "template");
    checkArg(newTemplate.getId(), "template id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        nova.getClient().servers().resize(server.getId(), newTemplate.getId(), null).execute();
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

Example 62 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackComputeService method getExtensions.

/**
 * Returns the set of extensions loaded, if any
 *
 * @return The list of extensions installed, if any
 * @throws ZoneException
 *             If anything fails
 */
public List<String> getExtensions() throws ZoneException {
    connect();
    Context context = getContext();
    ArrayList<String> extensions = new ArrayList<>();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        for (Extension extension : nova.getClient().extensions().list(true).execute()) {
            extensions.add(extension.getName());
        }
    } catch (OpenStackBaseException e) {
        if (e instanceof OpenStackResponseException) {
            OpenStackResponseException osre = (OpenStackResponseException) e;
            if (osre.getStatus() != 404) {
                ExceptionMapper.mapException(e);
            }
        } else {
            ExceptionMapper.mapException(e);
        }
    }
    return extensions;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Extension(com.woorea.openstack.nova.model.Extension) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 63 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackComputeService method getAccessControlList.

/**
 * @see com.att.cdp.zones.ComputeService#getAccessControlList(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public ACL getAccessControlList(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 {
        SecurityGroup group = nova.getClient().securityGroups().showSecurityGroup(id).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) SecurityGroup(com.woorea.openstack.nova.model.SecurityGroup) OpenStackACL(com.att.cdp.openstack.model.OpenStackACL)

Example 64 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackComputeService method unpauseServer.

/**
 * @see com.att.cdp.zones.ComputeService#unpauseServer(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public void unpauseServer(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 {
        nova.getClient().servers().unpause(id).execute();
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

Example 65 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackComputeService method deleteACLRule.

/**
 * @see com.att.cdp.zones.ComputeService#deleteACLRule(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public void deleteACLRule(Rule rule) throws ZoneException {
    checkArg(rule, "rule");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        nova.getClient().securityGroups().deleteSecurityGroupRule(rule.getId()).execute();
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

Aggregations

Context (com.att.cdp.zones.Context)248 OpenStackContext (com.att.cdp.openstack.OpenStackContext)167 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)140 ArrayList (java.util.ArrayList)55 Ignore (org.junit.Ignore)50 Test (org.junit.Test)47 Quantum (com.woorea.openstack.quantum.Quantum)35 ZoneException (com.att.cdp.exceptions.ZoneException)30 NetworkService (com.att.cdp.zones.NetworkService)24 Server (com.att.cdp.zones.model.Server)22 ComputeService (com.att.cdp.zones.ComputeService)21 Network (com.att.cdp.zones.model.Network)19 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)18 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)18 Subnet (com.att.cdp.zones.model.Subnet)15 Port (com.att.cdp.zones.model.Port)14 Snapshot (com.att.cdp.zones.model.Snapshot)12 Volume (com.att.cdp.zones.model.Volume)11 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)11 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)10