private void blockUntilSliceActive(int sliceId) throws InterruptedException { Slice currentDetails = null; for (currentDetails = client.getSlice(sliceId); currentDetails.getStatus() != Slice.Status.ACTIVE; currentDetails = client.getSlice(sliceId)) { System.out.printf("blocking on status active%n%s%n", currentDetails); Thread.sleep(5 * 1000); } }
public void testGetSlicesDetail() throws Exception { Set<Slice> response = client.listSlices(); assert null != response; long sliceCount = response.size(); assertTrue(sliceCount >= 0); for (Slice slice : response) { Slice newDetails = client.getSlice(slice.getId()); assertEquals(slice, newDetails); } }
@Test(enabled = true, timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateSlice") public void testSliceDetails() throws Exception { Slice slice = client.getSlice(sliceId); assertEquals(slice.getStatus(), Slice.Status.ACTIVE); assert slice.getProgress() >= 0 : "newDetails.getProgress()" + slice.getProgress(); assertEquals(new Integer(14362), slice.getImageId()); assertEquals(1, slice.getFlavorId()); assertNotNull(slice.getAddresses()); checkPassOk(slice, rootPassword); }
@Test(enabled = true) public void testCreateSlice() throws Exception { int imageId = 14362; int flavorId = 1; Slice slice = null; while (slice == null) { String sliceName = slicePrefix + "createslice" + new SecureRandom().nextInt(); try { slice = client.createSlice(sliceName, imageId, flavorId); } catch (UndeclaredThrowableException e) { HttpResponseException htpe = (HttpResponseException) e.getCause().getCause(); if (htpe.getResponse().getStatusCode() == 400) continue; throw e; } } assertNotNull(slice.getRootPassword()); sliceId = slice.getId(); rootPassword = slice.getRootPassword(); assertEquals(slice.getStatus(), Slice.Status.BUILD); blockUntilSliceActive(sliceId); }
private String getIp(Slice newDetails) { String ip = Iterables.find( newDetails.getAddresses(), new Predicate<String>() { @Override public boolean apply(String input) { return !input.startsWith("10."); } }); return ip; }