Package org.jclouds.softlayer.domain

Examples of org.jclouds.softlayer.domain.VirtualGuest$Builder


      HttpResponse createVirtualGuestResponse = HttpResponse.builder().statusCode(200)
              .payload(payloadFromResource("/virtual_guest_create_response.json")).build();

      VirtualGuestApi api = requestSendsResponse(createVirtualGuest, createVirtualGuestResponse).getVirtualGuestApi();
      VirtualGuest virtualGuest = createVirtualGuest();
      VirtualGuest result = api.createVirtualGuest(virtualGuest);
      assertEquals(result, new CreateVirtualGuestResponseTest().expected());
   }
View Full Code Here


              .payload(payloadFromResourceWithContentType("/virtual_guest_create.json", MediaType.APPLICATION_JSON))
              .build();

      HttpResponse createVirtualGuestResponse = HttpResponse.builder().statusCode(404).build();
      SoftLayerApi api = requestSendsResponse(createVirtualGuest, createVirtualGuestResponse);
      VirtualGuest virtualGuest = createVirtualGuest();
      assertNull(api.getVirtualGuestApi().createVirtualGuest(virtualGuest));
   }
View Full Code Here

      HttpResponse setTagsOnVirtualGuestResponse = HttpResponse.builder().statusCode(200)
              .payload(payloadFromResource("/virtual_guest_set_tags_response.json")).build();

      SoftLayerApi api = requestSendsResponse(setTagsOnVirtualGuest, setTagsOnVirtualGuestResponse);
      VirtualGuest virtualGuest = createVirtualGuest();
      assertTrue(api.getVirtualGuestApi().setTags(virtualGuest.getId(), ImmutableSet.of("test1", "test2", "test3")));
   }
View Full Code Here

              .payload(payloadFromResourceWithContentType("/virtual_guest_set_tags.json", MediaType.APPLICATION_JSON))
              .build();

      HttpResponse setTagsOnVirtualGuestResponse = HttpResponse.builder().statusCode(404).build();
      SoftLayerApi api = requestSendsResponse(setTagsOnVirtualGuest, setTagsOnVirtualGuestResponse);
      VirtualGuest virtualGuest = createVirtualGuest();
      assertFalse(api.getVirtualGuestApi().setTags(virtualGuest.getId(), ImmutableSet.of("test1", "test2", "test3")));
   }
View Full Code Here

   Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.of(location));

   @Test
   public void testVirtualGuestToNodeMetadata() {

      VirtualGuest virtualGuest = createVirtualGuest();
      NodeMetadata nodeMetadata = new VirtualGuestToNodeMetadata(locationSupplier, namingConvention,
              virtualGuestToImage, virtualGuestToHardware).apply(virtualGuest);
      assertNotNull(nodeMetadata);
      assertEquals(nodeMetadata.getName(), virtualGuest.getHostname());
      assertEquals(nodeMetadata.getHostname(), virtualGuest.getHostname() + virtualGuest.getDomain());
      assertEquals(nodeMetadata.getHardware().getRam(), virtualGuest.getMaxMemory());
      assertTrue(nodeMetadata.getHardware().getProcessors().size() == 1);
      assertEquals(Iterables.get(nodeMetadata.getHardware().getProcessors(), 0).getCores(), (double) virtualGuest.getStartCpus());
      assertEquals(nodeMetadata.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
      assertEquals(nodeMetadata.getOperatingSystem().getVersion(), "12.04");
      assertEquals(nodeMetadata.getOperatingSystem().is64Bit(), true);
   }
View Full Code Here

   }

   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(input instanceof VirtualGuest);
      VirtualGuest virtualGuest = VirtualGuest.class.cast(checkNotNull(input, "input"));
      request.setPayload(buildJson(virtualGuest));
      return request;
   }
View Full Code Here

            sshKeys.add(SecuritySshKey.builder().id(sshKeyId).build());
         }
         virtualGuestBuilder.sshKeys(sshKeys);
      }

      VirtualGuest virtualGuest = virtualGuestBuilder.build();
      logger.debug(">> creating new VirtualGuest(%s)", virtualGuest);
      VirtualGuest result = api.getVirtualGuestApi().createVirtualGuest(virtualGuest);
      logger.trace("<< VirtualGuest(%s)", result.getId());

      // tags
      if (templateOptions.getTags() != null) {
         api.getVirtualGuestApi().setTags(result.getId(), templateOptions.getTags());
      }

      logger.debug(">> awaiting login details for virtualGuest(%s)", result.getId());
      boolean orderInSystem = loginDetailsTester.apply(result);
      logger.trace("<< VirtualGuest(%s) complete(%s)", result.getId(), orderInSystem);

      if (!orderInSystem) {
         logger.warn("VirtualGuest(%s) doesn't have login details within %sms so it will be destroyed.", result,
              Long.toString(guestLoginDelay));
         api.getVirtualGuestApi().deleteVirtualGuest(result.getId());
         throw new IllegalStateException(format("VirtualGuest(%s) is being destroyed as it doesn't have login details" +
                 " after %sms. Please, try by increasing `jclouds.softlayer.virtualguest.login_details_delay` and " +
                 " try again", result, Long.toString(guestLoginDelay)));
      }
      result = api.getVirtualGuestApi().getVirtualGuest(result.getId());
      Password pwd = get(result.getOperatingSystem().getPasswords(), 0);
      return new NodeAndInitialCredentials(result, result.getId() + "",
              LoginCredentials.builder().user(pwd.getUsername()).password(pwd.getPassword()).build());
   }
View Full Code Here

      return api.getVirtualGuestApi().getVirtualGuest(serverId);
   }

   @Override
   public void destroyNode(String id) {
      VirtualGuest guest = getNode(id);
      if (guest == null) return;
      logger.debug(">> awaiting virtualGuest(%s) without active transactions", guest.getId());
      checkState(retry(new Predicate<VirtualGuest>() {
         public boolean apply(VirtualGuest guest) {
               return getNode(guest.getId() + "").getActiveTransactionCount() == 0;
         }
      }, activeTransactionsDelay).apply(guest), "%s still has active transactions!", guest);
      logger.debug(">> canceling virtualGuest with globalIdentifier(%s)", id);
      checkState(api.getVirtualGuestApi().deleteVirtualGuest(guest.getId()), "server(%s) still there after deleting!?", id);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.softlayer.domain.VirtualGuest$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.