Search in sources :

Example 1 with KeyPair

use of com.att.cdp.zones.model.KeyPair in project AJSC by att.

the class TestKeyPairs method testCreateAndDeleteKeypair.

/**
 * Test the creation and deletion of a key pair
 *
 * @throws ZoneException
 *             If the connection to the provider fails
 */
@Test
@Ignore
public void testCreateAndDeleteKeypair() throws ZoneException {
    Context context = connect();
    IdentityService service = context.getIdentityService();
    KeyPair model = new KeyPair(KEYPAIR_NAME, null);
    KeyPair actual = service.createKeyPair(model);
    assertNotNull(actual);
    assertEquals(model.getName(), actual.getName());
    assertNotNull(actual.getFingerprint());
    assertNotNull(actual.getPrivateKey());
    assertNotNull(actual.getPublicKey());
    service.deleteKeyPair(actual);
    context.logout();
}
Also used : Context(com.att.cdp.zones.Context) IdentityService(com.att.cdp.zones.IdentityService) KeyPair(com.att.cdp.zones.model.KeyPair) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with KeyPair

use of com.att.cdp.zones.model.KeyPair in project AJSC by att.

the class TestKeyPairs method listKeyPairs.

/**
 * @throws ZoneException
 */
@Test
@Ignore
public void listKeyPairs() throws ZoneException {
    Context context = connect();
    IdentityService service = context.getIdentityService();
    List<KeyPair> kps = service.getKeyPairs();
    assertNotNull(kps);
    for (KeyPair kp : kps) {
        if (kp.getName().equals(KEYPAIR_NAME)) {
            fail("KeyPair should not have existed");
        }
    }
    context.logout();
}
Also used : Context(com.att.cdp.zones.Context) IdentityService(com.att.cdp.zones.IdentityService) KeyPair(com.att.cdp.zones.model.KeyPair) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with KeyPair

use of com.att.cdp.zones.model.KeyPair in project AJSC by att.

the class AbstractOpenStackIdentityService method getKeyPairs.

/**
 * @see com.att.cdp.zones.IdentityService#getKeyPairs()
 */
@SuppressWarnings("nls")
@Override
public List<KeyPair> getKeyPairs() throws ZoneException {
    trackRequest();
    Context context = getContext();
    if (context.isLoggedIn()) {
        NovaConnector connector = ((OpenStackContext) context).getNovaConnector();
        KeyPairs pairs = null;
        try {
            pairs = connector.getClient().keyPairs().list().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, "get key-pair list"), e);
        }
        ArrayList<KeyPair> list = new ArrayList<>();
        for (com.woorea.openstack.nova.model.KeyPair pair : pairs.getList()) {
            OpenStackKeyPair kp = new OpenStackKeyPair(context, pair);
            list.add(kp);
        }
        return list;
    }
    throw new ZoneException("Unable to retrieve 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) KeyPair(com.att.cdp.zones.model.KeyPair) OpenStackKeyPair(com.att.cdp.openstack.model.OpenStackKeyPair) KeyPairs(com.woorea.openstack.nova.model.KeyPairs) ArrayList(java.util.ArrayList) 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)

Aggregations

Context (com.att.cdp.zones.Context)3 KeyPair (com.att.cdp.zones.model.KeyPair)3 IdentityService (com.att.cdp.zones.IdentityService)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 ContextConnectionException (com.att.cdp.exceptions.ContextConnectionException)1 ZoneException (com.att.cdp.exceptions.ZoneException)1 OpenStackContext (com.att.cdp.openstack.OpenStackContext)1 NovaConnector (com.att.cdp.openstack.connectors.NovaConnector)1 OpenStackKeyPair (com.att.cdp.openstack.model.OpenStackKeyPair)1 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)1 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)1 KeyPairs (com.woorea.openstack.nova.model.KeyPairs)1 ArrayList (java.util.ArrayList)1