Search in sources :

Example 21 with OpenStackContext

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

the class OpenStackNetworkService method releaseIpAddress.

/**
 * @see com.att.cdp.zones.NetworkService#releaseIpAddress(java.lang.String, java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public void releaseIpAddress(String serverId, String assignedAddress) throws ZoneException {
    checkArg(serverId, "serverId");
    checkArg(assignedAddress, "assignedAddress");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVER, serverId);
    RequestState.put(RequestState.IPADDRESS, assignedAddress);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
    ComputeService compute = context.getComputeService();
    compute.releaseIpAddress(serverId, assignedAddress);
    ((OpenStackContext) context).deallocateFloatingIP(assignedAddress);
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackContext(com.att.cdp.openstack.OpenStackContext) ComputeService(com.att.cdp.zones.ComputeService)

Example 22 with OpenStackContext

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

the class OpenStackComputeService method connect.

/**
 * This is a helper method used to construct the Nova service object and
 * setup the environment to access the OpenStack compute service (Nova).
 *
 * @throws NotLoggedInException
 *             If the user is not logged in
 * @throws ContextClosedException
 *             If the user attempts an operation after the context is closed
 */
private void connect() throws NotLoggedInException, ContextClosedException {
    checkLogin();
    checkOpen();
    OpenStackContext osContext = (OpenStackContext) getContext();
    nova = osContext.getNovaConnector();
    osContext.refreshIfStale(nova);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext)

Example 23 with OpenStackContext

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

the class TestComputeService method testOpenstackMigrate.

@Ignore
@Test
public void testOpenstackMigrate() throws ZoneException {
    // For testing the migrate functionality
    Properties properties = new Properties();
    String vmId = "75dce20c-97f9-454d-abcc-aa904a33df5a";
    properties.put(ContextFactory.PROPERTY_IDENTITY_URL, "http://135.25.246.131:5000");
    properties.put(ContextFactory.PROPERTY_TENANT, "Play");
    // String vmId = "af51c8b9-3df4-4770-846a-457666367b23";
    // properties.put(ContextFactory.PROPERTY_IDENTITY_URL, "http://135.25.69.195:5000");
    // properties.put(ContextFactory.PROPERTY_TENANT, "Trinity");
    OpenStackContext context = (OpenStackContext) ContextFactory.getContext("OpenStackProvider", properties);
    context.login("AppC", "AppC");
    ComputeService computeService = context.getComputeService();
    Server testVNF = computeService.getServer(vmId);
    long t1, t2, t3, t4;
    t1 = System.currentTimeMillis() / 1000;
    computeService.migrateServer(testVNF.getId());
    testVNF.waitForStateChange(1, 600, Status.PENDING);
    t2 = System.currentTimeMillis() / 1000;
    System.out.println("Migrate accepted and calculating prep work");
    try {
        computeService.migrateServer(testVNF.getId());
        fail("Should not be able to migrate a server that is in PENDING");
    } catch (Exception e) {
    // Good
    }
    try {
        computeService.processResize(testVNF);
        fail("Should not be able to confirm a resize on a server that is in PENDING");
    } catch (Exception e) {
    // Good
    }
    testVNF.waitForStateChange(5, 600, Status.READY);
    t3 = System.currentTimeMillis() / 1000;
    System.out.println("Migrate calculations does. Send resizeConfirm to apply");
    computeService.processResize(testVNF);
    testVNF.waitForStateChange(1, 600, Status.RUNNING);
    t4 = System.currentTimeMillis() / 1000;
// System.out.println("Migrate Complete. Time to: 1) Start checking after migrate() call, 2) Finish checking, 3) Commit migrate");
// System.out.println(String.format("1) %3ds\n2) %3ds (%03ds)\n3) %3ds (%3ds)", t2 - t1, t3 - t2, t3 - t1,
// t4 - t3, t4 - t1));
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) Server(com.att.cdp.zones.model.Server) Properties(java.util.Properties) ComputeService(com.att.cdp.zones.ComputeService) ZoneException(com.att.cdp.exceptions.ZoneException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with OpenStackContext

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

the class OpenStackSnapshotService method connect.

/**
 * This is a helper method used to construct the Cinder service object and setup the environment to access the
 * OpenStack compute service (Cinder).
 *
 * @throws NotLoggedInException
 *             If the user is not logged in
 * @throws ContextClosedException
 *             If the user attempts an operation after the context is closed
 */
private void connect() throws NotLoggedInException, ContextClosedException {
    checkLogin();
    checkOpen();
    Context context = getContext();
    OpenStackContext osContext = (OpenStackContext) context;
    cinder = osContext.getCinderConnector();
    ((OpenStackContext) context).refreshIfStale(cinder);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext)

Example 25 with OpenStackContext

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

the class AbstractTestCase method login.

/**
 * A helper method to allow test cases that need an active, actual logged in connection to a provider
 *
 * @return The context
 * @throws ZoneException
 *             If the login fails
 */
protected OpenStackContext login() throws ZoneException {
    OpenStackContext context = (OpenStackContext) ContextFactory.getContext("OpenStackProvider", getProperties());
    assertFalse(context.isLoggedIn());
    context.login(getProperties().getProperty(ContextFactory.PROPERTY_USERID), getProperties().getProperty(ContextFactory.PROPERTY_PASSWORD));
    assertTrue(context.isLoggedIn());
    return context;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext)

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