Search in sources :

Example 11 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class AbstractOpenStackIdentityService method createKeyPair.

/**
 * @see com.att.cdp.zones.IdentityService#createKeyPair(com.att.cdp.zones.model.KeyPair)
 */
@SuppressWarnings("nls")
@Override
public KeyPair createKeyPair(KeyPair keyPair) throws ZoneException {
    trackRequest();
    RequestState.put(RequestState.KEYPAIR, keyPair.getName());
    Context context = getContext();
    if (context.isLoggedIn()) {
        NovaConnector connector = ((OpenStackContext) context).getNovaConnector();
        com.woorea.openstack.nova.model.KeyPair pair;
        try {
            pair = connector.getClient().keyPairs().create(keyPair.getName()).execute();
        } catch (OpenStackConnectException e) {
            throw new ContextConnectionException(EELFResourceManager.format(OSMsg.PAL_OS_CONNECTION_FAILED, "Compute", connector.getEndpoint()), e);
        } catch (OpenStackResponseException e) {
            String reason = null;
            if (e.getResponse() != null && e.getResponse().getInputStream() != null) {
                try {
                    reason = IOUtils.toString(e.getResponse().getInputStream(), "UTF-8");
                } catch (IOException e1) {
                }
                throw new ZoneException(EELFResourceManager.format(OSMsg.PAL_OS_REQUEST_FAILURE, "create key-pair " + keyPair.getName() + " " + reason), e);
            }
            throw new ZoneException(EELFResourceManager.format(OSMsg.PAL_OS_REQUEST_FAILURE, "create key-pair " + keyPair.getName()), e);
        }
        return new OpenStackKeyPair(context, pair);
    }
    throw new ZoneException("Unable to create key-pairs when the context has not been logged in and authenticated");
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) IOException(java.io.IOException) OpenStackContext(com.att.cdp.openstack.OpenStackContext) ContextConnectionException(com.att.cdp.exceptions.ContextConnectionException) ZoneException(com.att.cdp.exceptions.ZoneException) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) OpenStackKeyPair(com.att.cdp.openstack.model.OpenStackKeyPair) NovaConnector(com.att.cdp.openstack.connectors.NovaConnector) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException)

Example 12 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class AbstractOpenStackIdentityService method deleteKeyPair.

/**
 * @see com.att.cdp.zones.IdentityService#deleteKeyPair(com.att.cdp.zones.model.KeyPair)
 */
@SuppressWarnings("nls")
@Override
public void deleteKeyPair(KeyPair keyPair) throws ZoneException {
    trackRequest();
    RequestState.put(RequestState.KEYPAIR, keyPair.getName());
    Context context = getContext();
    if (context.isLoggedIn()) {
        NovaConnector connector = ((OpenStackContext) context).getNovaConnector();
        try {
            connector.getClient().keyPairs().delete(keyPair.getName()).execute();
        } catch (OpenStackConnectException e) {
            throw new ContextConnectionException(EELFResourceManager.format(OSMsg.PAL_OS_CONNECTION_FAILED, "Compute", connector.getEndpoint()), e);
        } catch (OpenStackResponseException e) {
            throw new ZoneException(EELFResourceManager.format(OSMsg.PAL_OS_REQUEST_FAILURE, "delete key-pair " + keyPair.getName()), e);
        }
        return;
    }
    throw new ZoneException("Unable to delete key-pairs when the context has not been logged in and authenticated");
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) ContextConnectionException(com.att.cdp.exceptions.ContextConnectionException) ZoneException(com.att.cdp.exceptions.ZoneException) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) NovaConnector(com.att.cdp.openstack.connectors.NovaConnector) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException)

Example 13 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class TestCinderConnector method testCinderConnector.

@Test
@Ignore
public void testCinderConnector() throws ZoneException {
    OpenStackContext context = login();
    CinderConnector connector = context.getCinderConnector();
    assertNotNull(connector);
    Access access = connector.getAccess();
    assertNotNull(access);
    Cinder client = connector.getClient();
    assertNotNull(client);
    logout(context);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Cinder(com.woorea.openstack.cinder.Cinder) Access(com.woorea.openstack.keystone.model.Access) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class TestGlanceConnector method testGlanceConnector.

@Test
@Ignore
public void testGlanceConnector() throws ZoneException {
    OpenStackContext context = login();
    GlanceConnector connector = context.getGlanceConnector();
    assertNotNull(connector);
    Access access = connector.getAccess();
    assertNotNull(access);
    Glance client = connector.getClient();
    assertNotNull(client);
    logout(context);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Glance(com.woorea.openstack.glance.Glance) Access(com.woorea.openstack.keystone.model.Access) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class TestHeatConnector method testGlanceConnector.

@Test
@Ignore
public void testGlanceConnector() throws ZoneException {
    OpenStackContext context = login();
    HeatConnector connector = context.getHeatConnector();
    assertNotNull(connector);
    Access access = connector.getAccess();
    assertNotNull(access);
    Heat client = connector.getClient();
    assertNotNull(client);
    logout(context);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Heat(com.woorea.openstack.heat.Heat) Access(com.woorea.openstack.keystone.model.Access) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)28 Context (com.att.cdp.zones.Context)17 ContextConnectionException (com.att.cdp.exceptions.ContextConnectionException)7 ZoneException (com.att.cdp.exceptions.ZoneException)7 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)7 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)7 Ignore (org.junit.Ignore)7 Test (org.junit.Test)7 Access (com.woorea.openstack.keystone.model.Access)5 NovaConnector (com.att.cdp.openstack.connectors.NovaConnector)4 OpenStackKeyPair (com.att.cdp.openstack.model.OpenStackKeyPair)3 OpenStackTenant (com.att.cdp.openstack.model.OpenStackTenant)3 Keystone (com.woorea.openstack.keystone.Keystone)3 Tenants (com.woorea.openstack.keystone.model.Tenants)3 ComputeService (com.att.cdp.zones.ComputeService)2 Nova (com.woorea.openstack.nova.Nova)2 KeyPairs (com.woorea.openstack.nova.model.KeyPairs)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2