Search in sources :

Example 16 with ComputeService

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

the class TestComputeService method testListPorts.

/**
 * Test that we can list all ports on some server
 *
 * @throws ZoneException
 *             if anything fails
 */
@Test
@Ignore
public void testListPorts() throws ZoneException {
    Context context = connect();
    ComputeService service = context.getComputeService();
    List<Server> servers = service.getServers();
    assertNotNull(servers);
    assertFalse(servers.isEmpty());
    for (Server server : servers) {
        List<Port> ports = service.getPorts(server);
        assertNotNull(ports);
        assertFalse(ports.isEmpty());
        List<Port> serverPorts = server.getPorts();
        assertNotNull(serverPorts);
        assertFalse(serverPorts.isEmpty());
        assertTrue(ports.containsAll(serverPorts));
    // System.out.printf("Server %s has %d ports\n", server.getName(),
    // ports.size());
    }
}
Also used : Context(com.att.cdp.zones.Context) Server(com.att.cdp.zones.model.Server) Port(com.att.cdp.zones.model.Port) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with ComputeService

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

the class TestComputeService method testGetServerLazy.

/**
 * @throws ZoneException
 *             If the connection fails or the server cant be found
 * @throws IllegalAccessException
 *             If the fields cant be accessed
 * @throws IllegalArgumentException
 *             If the fields cant be accessed
 */
@Ignore
@Test
public void testGetServerLazy() throws ZoneException, IllegalArgumentException, IllegalAccessException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    Server server = computeService.getServer(TEST_SERVER_UUID);
    /*
         * Make sure that we have not obtained any of the transitive dependencies yet
         */
    assertNotNull(server);
    AtomicBoolean ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    ab = (AtomicBoolean) imagesProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    ab = (AtomicBoolean) networksProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    /*
         * Now, get the network and ensure that it is correct
         */
    List<Network> networks = server.getNetworks();
    assertNotNull(networks);
    assertFalse(networks.isEmpty());
    boolean found = false;
    for (Network network : networks) {
        if (network.getName().equals(TEST_NETWORK_NAME)) {
            found = true;
            break;
        }
    }
    assertTrue(found);
    ab = (AtomicBoolean) networksProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    ab = (AtomicBoolean) imagesProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    /*
         * Now, determine the boot source and image, this will cause the images to be processed
         */
    ServerBootSource bs = server.getBootSource();
    assertNotNull(bs);
    assertTrue(bs.equals(ServerBootSource.IMAGE) || bs.equals(ServerBootSource.SNAPSHOT));
    String image = server.getImage();
    assertNotNull(image);
    ab = (AtomicBoolean) networksProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) imagesProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    /*
         * Now, lets see if there are any volume attachments. This will load the volumes transitive relationship
         */
    Map<String, Volume> volumes = server.getVolumes();
    assertNotNull(volumes);
    ab = (AtomicBoolean) networksProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) imagesProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) Server(com.att.cdp.zones.model.Server) Volume(com.att.cdp.zones.model.Volume) Network(com.att.cdp.zones.model.Network) ServerBootSource(com.att.cdp.zones.model.ServerBootSource) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with ComputeService

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

the class TestComputeService method testComputeService.

/**
 * @throws ZoneException
 *             If something goes horribly wrong
 */
@Ignore
@Test
public void testComputeService() throws ZoneException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    List<Server> servers = computeService.getServers();
    for (Server server : servers) {
        computeService.getServers(server.getName());
        computeService.getServer(server.getId());
        computeService.getAttachments(server);
        computeService.getAttachments(server.getId());
        computeService.getConsoleOutput(server);
    }
    List<Template> templates = computeService.getTemplates();
    for (Template template : templates) {
        computeService.getTemplate(template.getId());
    }
    List<ACL> accessControlLists = computeService.getAccessControlLists();
    for (ACL acl : accessControlLists) {
        computeService.getAccessControlList(acl.getId());
    }
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) Server(com.att.cdp.zones.model.Server) ACL(com.att.cdp.zones.model.ACL) ComputeService(com.att.cdp.zones.ComputeService) Template(com.att.cdp.zones.model.Template) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with ComputeService

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

the class TestComputeService method testGetHypervisor.

/**
 * This test case is designed to simply list the details for a hypervisor.
 *
 * @throws ZoneException
 *             If something goes horribly wrong
 */
@SuppressWarnings("nls")
@Ignore
@Test
public void testGetHypervisor() throws ZoneException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    Hypervisor hypervisor = computeService.getHypervisor("1");
    System.out.println(hypervisor.toString());
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) Hypervisor(com.att.cdp.zones.model.Hypervisor) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 20 with ComputeService

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

the class TestComputeService method testRebuildServer.

/**
 * This test is designed to rebuild a specific server and test that it rebuilds correctly
 *
 * @throws ZoneException
 *             If something goes horribly wrong
 */
@SuppressWarnings("nls")
@Ignore
@Test
public void testRebuildServer() throws ZoneException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    Server testVNF = computeService.getServer(TEST_SERVER_UUID);
    testVNF.rebuild();
    testVNF.waitForStateChange(1, 600, Server.Status.RUNNING);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) 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