@Override public boolean apply(VirtualGuest server) { return contains(ids, server.getId()); } });
@Override public boolean apply(VirtualGuest server) { return contains(ids, server.getId()); } });
@Override public boolean apply(VirtualGuest server) { return contains(ids, server.getId()); } });
public boolean apply(VirtualGuest guest) { guest = getNode(guest.getId() + ""); return guest.getActiveTransactionCount() == 0; } }, activeTransactionsDelay).apply(guest), "%s still has active transactions!", guest);
public Hardware getHardware(VirtualGuest guest) { // 'bad' orders have no start cpu's and cause the order lookup to fail. if (guest.getStartCpus() < 1) return null; ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId()); if (order == null) return null; Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item()); return productItemsToHardware.apply(items); } }
public Hardware getHardware(VirtualGuest guest) { // 'bad' orders have no start cpu's and cause the order lookup to fail. if (guest.getStartCpus() < 1) return null; ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId()); if (order == null) return null; Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item()); return productItemsToHardware.apply(items); } }
@Test public void testListVirtualGuests() throws Exception { Set<VirtualGuest> response = api().listVirtualGuests(); assert null != response; assertTrue(response.size() >= 0); for (VirtualGuest vg : response) { VirtualGuest newDetails = api().getVirtualGuest(vg.getId()); assertEquals(vg.getId(), newDetails.getId()); checkVirtualGuest(vg); } }
@Test(dependsOnMethods = "testCreateVirtualGuest") public void testGetVirtualGuest() throws Exception { VirtualGuest found = virtualGuestApi.getVirtualGuest(virtualGuest.getId()); assertEquals(found, virtualGuest); assertNull(found.getPrimaryBackendNetworkComponent(), "backendNetworkComponent should be null"); }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest newGuest = client.getVirtualGuestClient().getVirtualGuest(guest.getId()); boolean hasBackendIp = newGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = newGuest.getPrimaryIpAddress() != null; boolean hasPasswords = newGuest.getOperatingSystem() != null && newGuest.getOperatingSystem().getPasswords().size() > 0; return hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest newGuest = client.getVirtualGuestApi().getObject(guest.getId()); boolean hasBackendIp = newGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = newGuest.getPrimaryIpAddress() != null; boolean hasPasswords = newGuest.getOperatingSystem() != null && newGuest.getOperatingSystem().getPasswords().size() > 0; return hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest newGuest = client.getVirtualGuestClient().getVirtualGuest(guest.getId()); boolean hasBackendIp = newGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = newGuest.getPrimaryIpAddress() != null; boolean hasPasswords = newGuest.getOperatingSystem() != null && newGuest.getOperatingSystem().getPasswords().size() > 0; return hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Test(dependsOnMethods = "testSetTagsOnVirtualGuest") public void testSetNotesOnVirtualGuest() throws Exception { // Test with maximum allowed notes length - 1000 characters. String notes = Strings.padStart("", 1000, 'x'); assertTrue(virtualGuestApi.setNotes(virtualGuest.getId(), notes)); VirtualGuest found = virtualGuestApi.getNotes(virtualGuest.getId()); assertEquals(found.getNotes(), notes); }
public Image getImage(VirtualGuest guest) { // 'bad' orders have no start cpu's and cause the order lookup to fail. if (guest.getStartCpus() < 1) return null; ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId()); if (order == null) return null; Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item()); ProductItem os = Iterables.find(items, ProductItemPredicates.categoryCode("os")); return new ProductItemToImage().apply(os); } }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest virtualGuest = client.getVirtualGuestApi().getVirtualGuest(guest.getId()); boolean hasBackendIp = virtualGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = virtualGuest.getPrimaryIpAddress() != null; boolean hasPasswords = virtualGuest.getOperatingSystem() != null && !virtualGuest.getOperatingSystem().getPasswords().isEmpty(); return virtualGuest.isPrivateNetworkOnly() ? hasBackendIp && hasPasswords : hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Test(dependsOnMethods = "testGetVirtualGuest") public void testGetVirtualGuestFiltered() throws Exception { VirtualGuest found = virtualGuestApi.getVirtualGuestFiltered(virtualGuest.getId(), "id;primaryBackendNetworkComponent;primaryBackendNetworkComponent.networkVlan"); assertEquals(found.getId(), virtualGuest.getId()); assertNotNull(found.getPrimaryBackendNetworkComponent(), "backendNetworkComponent must be returned"); assertNotNull(found.getPrimaryBackendNetworkComponent().getNetworkVlan(), "backendNetworkComponent networkVlan must be returned"); assertTrue(found.getPrimaryBackendNetworkComponent().getNetworkVlan().getId() > 0, "backendNetworkComponent must have a valid networkVlan ID"); }
public Image getImage(VirtualGuest guest) { // 'bad' orders have no start cpu's and cause the order lookup to fail. if (guest.getStartCpus() < 1) return null; ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId()); if (order == null) return null; Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item()); ProductItem os = Iterables.find(items, ProductItemPredicates.categoryCode("os")); return new ProductItemToImage().apply(os); } }
public boolean apply(VirtualGuest guest) { guest = api().getVirtualGuest(virtualGuest.getId()); return guest.getActiveTransactionCount() == 0; } }, 5 * 60 * 1000).apply(virtualGuest), "%s still has active transactions!", virtualGuest);
public String getReferenceCodeOrId(VirtualGuest from) { String val = from.getSoftwareLicense() != null && from.getSoftwareLicense().getSoftwareDescription() != null ? from.getSoftwareLicense().getSoftwareDescription().getReferenceCode() : from.getId() + ""; return val; } }
public String getReferenceCodeOrId(VirtualGuest from) { String val = from.getSoftwareLicense() != null && from.getSoftwareLicense().getSoftwareDescription() != null ? from.getSoftwareLicense().getSoftwareDescription().getReferenceCode() : from.getId() + ""; return val; } }
public void testSetTagsOnVirtualGuest() throws Exception { MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/virtual_guest_set_tags_response.json"))); VirtualGuestApi api = api(SoftLayerApi.class, server.getUrl("/").toString()).getVirtualGuestApi(); VirtualGuest virtualGuest = createVirtualGuest(); try { assertTrue(api.setTags(virtualGuest.getId(), ImmutableSet.of("test1", "test2", "test3"))); assertSent(server, "POST", "/SoftLayer_Virtual_Guest/1301396/setTags"); } finally { server.shutdown(); } }