use of com.att.cdp.zones.model.Volume 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());
}
use of com.att.cdp.zones.model.Volume in project AJSC by att.
the class OpenStackVolumeService method getVolumes.
/**
* Returns a list of volumes that match the supplied name
*
* @param name
* The name pattern of the volumes to be located. The name is a regular expression that is suitable for
* use in the Java String.matches() method.
* @return A list (potentially empty) of all volumes that match the specified name pattern
* @throws ZoneException
* - If the volume service cannot be accessed.
* @see java.lang.String#matches(String)
* @see com.att.cdp.zones.VolumeService#getVolumes(java.lang.String)
*/
@Override
public List<Volume> getVolumes(String name) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.VOLUME, name);
RequestState.put(RequestState.SERVICE, "Volume");
RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
ArrayList<Volume> list = new ArrayList<>();
try {
com.woorea.openstack.cinder.model.Volumes volumes = cinder.getClient().volumes().list(true).execute();
for (com.woorea.openstack.cinder.model.Volume volume : volumes) {
if (name != null) {
if (volume.getName() != null && volume.getName().matches(name)) {
list.add(new OpenStackVolume(context, volume));
}
} else {
list.add(new OpenStackVolume(context, volume));
}
}
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return list;
}
use of com.att.cdp.zones.model.Volume in project AJSC by att.
the class TestVolumeService method listVolume.
@Test
@Ignore
public void listVolume() throws ZoneException {
Context context = connect();
VolumeService service = context.getVolumeService();
String id = "15afc83f-557c-42d6-8a23-f357bf767f61";
Volume volumes = service.getVolume(id);
assertNotNull(volumes);
System.out.println("::DONE::");
}
Aggregations