Search in sources :

Example 1 with ComputeService

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

the class ConnectedServer method attachPort.

/**
 * @see com.att.cdp.zones.model.Server#attachPort(com.att.cdp.zones.model.Port)
 */
@Override
public void attachPort(Port nic) throws ZoneException {
    Context context = getContext();
    ComputeService service = context.getComputeService();
    service.attachPort(this, nic);
}
Also used : Context(com.att.cdp.zones.Context) ComputeService(com.att.cdp.zones.ComputeService)

Example 2 with ComputeService

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

the class OpenStackNetworkService method assignIpAddress.

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

Example 3 with ComputeService

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

the class TestOpenStackContext method testLoginLogout.

/**
 * Test that we can login and out of the provider, and access the services once logged in (so we dont have to
 * repeatedly login/out)
 *
 * @throws ZoneException
 */
@Test
@Ignore
public void testLoginLogout() throws ZoneException {
    OpenStackContext context = login();
    /*
         * make sure we can retreive all of the services
         */
    ComputeService computeService = context.getComputeService();
    assertNotNull(computeService);
    IdentityService identityService = context.getIdentityService();
    assertNotNull(identityService);
    ImageService imageService = context.getImageService();
    assertNotNull(imageService);
    NetworkService networkService = context.getNetworkService();
    assertNotNull(networkService);
    VolumeService volumeService = context.getVolumeService();
    assertNotNull(volumeService);
    SnapshotService snapshotService = context.getSnapshotService();
    assertNotNull(snapshotService);
    StackService stackService = context.getStackService();
    assertNotNull(stackService);
    /*
         * Services are locally cached by the provider context. If we get them again, we should get the same exact
         * object. Check that too.
         */
    assertTrue(computeService == context.getComputeService());
    assertTrue(identityService == context.getIdentityService());
    assertTrue(imageService == context.getImageService());
    assertTrue(networkService == context.getNetworkService());
    assertTrue(volumeService == context.getVolumeService());
    assertTrue(snapshotService == context.getSnapshotService());
    assertTrue(stackService == context.getStackService());
    /*
         * Test that we can also obtain the connectors
         */
    GlanceConnector glanceConnector = context.getGlanceConnector();
    assertNotNull(glanceConnector);
    NovaConnector novaConnector = context.getNovaConnector();
    assertNotNull(novaConnector);
    QuantumConnector quantumConnector = context.getQuantumConnector();
    assertNotNull(quantumConnector);
    /*
         * Connectors are locally cached, check that
         */
    assertTrue(glanceConnector == context.getGlanceConnector());
    assertTrue(novaConnector == context.getNovaConnector());
    assertTrue(quantumConnector == context.getQuantumConnector());
    /*
         * Now, check that we can obtain the tenant as well
         */
    Tenant tenant = context.getTenant();
    assertNotNull(tenant);
    assertEquals(tenant.getName(), context.getTenantName());
    assertEquals(tenant.getId(), context.getTenantId());
    logout(context);
}
Also used : IdentityService(com.att.cdp.zones.IdentityService) SnapshotService(com.att.cdp.zones.SnapshotService) StackService(com.att.cdp.zones.StackService) Tenant(com.att.cdp.zones.model.Tenant) GlanceConnector(com.att.cdp.openstack.connectors.GlanceConnector) VolumeService(com.att.cdp.zones.VolumeService) QuantumConnector(com.att.cdp.openstack.connectors.QuantumConnector) NetworkService(com.att.cdp.zones.NetworkService) NovaConnector(com.att.cdp.openstack.connectors.NovaConnector) OpenStackComputeService(com.att.cdp.openstack.v2.OpenStackComputeService) ComputeService(com.att.cdp.zones.ComputeService) ImageService(com.att.cdp.zones.ImageService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with ComputeService

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

the class TestComputeService method testAttachAndDetachPorts.

/**
 * Test the attach and detach of a port
 *
 * @throws ZoneException
 *             if the test fails
 */
@SuppressWarnings("nls")
@Test
@Ignore
public void testAttachAndDetachPorts() throws ZoneException {
    Context context = connect();
    ComputeService compute = context.getComputeService();
    NetworkService network = context.getNetworkService();
    /*
		 * Get a list of servers. Make sure that at least one server exists.
		 * We'll just use the first one we find.
		 */
    List<Server> servers = compute.getServers();
    assertNotNull(servers);
    assertFalse(servers.isEmpty());
    Server server = servers.get(0);
    // 
    /*
		 * Now, get the ports attached to that server. Make sure there is at
		 * least one port. We'll use the first one we find.
		 */
    List<Port> ports = server.getPorts();
    assertNotNull(ports);
    assertFalse(ports.isEmpty());
    /*
		 * Use the first port to model the creation of a new port. We'll use the
		 * same subnet.
		 */
    Port modelPort = ports.get(0);
    Subnet subnet = network.getSubnetById(modelPort.getSubnetId());
    Port newPort = network.createPort(subnet);
    assertNotNull(newPort);
    assertNotNull(newPort.getMacAddr());
    assertNotNull(newPort.getId());
    /*
		 * Save the new port's ID. We'll use that to test that it was actually
		 * attached and detached
		 */
    String id = newPort.getId();
    /*
		 * Attach the port to the server. Then list all the ports and make sure
		 * the new port is included
		 */
    server.attachPort(newPort);
    ports = server.getPorts();
    boolean found = false;
    for (Port p : ports) {
        if (p.getId().equals(id)) {
            found = true;
            break;
        }
    }
    if (!found) {
        fail("Port is not listed as attached to the server");
    }
    /*
		 * Now detach the port and make sure that it is NOT listed
		 */
    server.detachPort(newPort);
    try {
        Thread.sleep(1000L);
    } catch (InterruptedException e) {
    // ignore
    }
    ports = server.getPorts();
    found = false;
    for (Port p : ports) {
        if (p.getId().equals(id)) {
            found = true;
            break;
        }
    }
    if (found) {
        fail("Port is still listed as attached to the server");
    }
    /*
		 * Finally, delete the new port
		 */
    network.deletePort(newPort);
}
Also used : Context(com.att.cdp.zones.Context) Server(com.att.cdp.zones.model.Server) Port(com.att.cdp.zones.model.Port) NetworkService(com.att.cdp.zones.NetworkService) Subnet(com.att.cdp.zones.model.Subnet) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with ComputeService

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

the class TestComputeService method testInvalidRebootType.

@Ignore
@Test(expected = InvalidRequestException.class)
public void testInvalidRebootType() throws ZoneException {
    Context context = connect();
    ComputeService compute = context.getComputeService();
    // NetworkService network = context.getNetworkService();
    List<Server> ids = compute.getServers();
    for (Server id : ids) {
        compute.rebootServer(id, "SOFT1");
    }
}
Also used : Context(com.att.cdp.zones.Context) Server(com.att.cdp.zones.model.Server) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ComputeService (com.att.cdp.zones.ComputeService)25 Context (com.att.cdp.zones.Context)21 Ignore (org.junit.Ignore)18 Test (org.junit.Test)16 Server (com.att.cdp.zones.model.Server)12 OpenStackContext (com.att.cdp.openstack.OpenStackContext)10 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)6 Port (com.att.cdp.zones.model.Port)4 NetworkService (com.att.cdp.zones.NetworkService)3 Hypervisor (com.att.cdp.zones.model.Hypervisor)3 Volume (com.att.cdp.zones.model.Volume)3 ZoneException (com.att.cdp.exceptions.ZoneException)2 VolumeService (com.att.cdp.zones.VolumeService)2 ACL (com.att.cdp.zones.model.ACL)2 Template (com.att.cdp.zones.model.Template)2 GlanceConnector (com.att.cdp.openstack.connectors.GlanceConnector)1 NovaConnector (com.att.cdp.openstack.connectors.NovaConnector)1 QuantumConnector (com.att.cdp.openstack.connectors.QuantumConnector)1 OpenStackComputeService (com.att.cdp.openstack.v2.OpenStackComputeService)1 IdentityService (com.att.cdp.zones.IdentityService)1