Search in sources :

Example 1 with ServerBootSource

use of com.att.cdp.zones.model.ServerBootSource 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)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)1 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)1 ComputeService (com.att.cdp.zones.ComputeService)1 Context (com.att.cdp.zones.Context)1 Network (com.att.cdp.zones.model.Network)1 Server (com.att.cdp.zones.model.Server)1 ServerBootSource (com.att.cdp.zones.model.ServerBootSource)1 Volume (com.att.cdp.zones.model.Volume)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1