Package org.jclouds.softlayer.domain

Examples of org.jclouds.softlayer.domain.ProductOrder


      String domainName = template.getOptions().as(SoftLayerTemplateOptions.class).getDomainName();

      VirtualGuest newGuest = VirtualGuest.builder().domain(domainName).hostname(name).build();

      ProductOrder order = ProductOrder.builder().packageId(productPackageSupplier.get().getId())
            .location(template.getLocation().getId()).quantity(1).useHourlyPricing(true).prices(getPrices(template))
            .virtualGuests(newGuest).build();

      logger.debug(">> ordering new virtualGuest domain(%s) hostname(%s)", domainName, name);
      ProductOrderReceipt productOrderReceipt = client.getVirtualGuestClient().orderVirtualGuest(order);
View Full Code Here


      prices.add(osPrice);

      VirtualGuest guest = VirtualGuest.builder().domain("jclouds.org").hostname(
               TEST_HOSTNAME_PREFIX + new Random().nextInt()).build();

      ProductOrder order = ProductOrder.builder().packageId(pkgId).quantity(1).useHourlyPricing(true).prices(
               prices.build()).virtualGuests(guest).build();

      ProductOrderReceipt receipt = api().orderVirtualGuest(order);
      ProductOrder order2 = receipt.getOrderDetails();
      VirtualGuest result = Iterables.get(order2.getVirtualGuests(), 0);

      ProductOrder order3 = api().getOrderTemplate(result.getId());

      assertEquals(order.getPrices(), order3.getPrices());
      assertNotNull(receipt);
   }
View Full Code Here

      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);
      }
View Full Code Here

      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);
      }
View Full Code Here

      VirtualGuest guest = VirtualGuest.builder().domain("jclouds.org").hostname(
               TEST_HOSTNAME_PREFIX + new Random().nextInt()).build();

      Template template = templateBuilder.build();

      ProductOrder order = ProductOrder.builder()
              .packageId(productPackage.getId())
              .quantity(1)
              .location(template.getLocation().getId())
              .useHourlyPricing(true)
              .prices(getPrices(template, productPackage))
              .virtualGuests(guest).build();

      ProductOrderReceipt receipt = api().orderVirtualGuest(order);
      ProductOrder order2 = receipt.getOrderDetails();
      assertEquals(order.getPrices(), order2.getPrices());
      assertNotNull(receipt);
   }
View Full Code Here

      String domainName = template.getOptions().as(SoftLayerTemplateOptions.class).getDomainName();

      VirtualGuest newGuest = VirtualGuest.builder().domain(domainName).hostname(name).build();

      ProductOrder order = ProductOrder.builder().packageId(productPackageSupplier.get().getId())
            .location(template.getLocation().getId()).quantity(1).useHourlyPricing(true).prices(getPrices(template))
            .virtualGuests(newGuest).build();

      logger.debug(">> ordering new virtualGuest domain(%s) hostname(%s)", domainName, name);
      ProductOrderReceipt productOrderReceipt = client.getVirtualGuestClient().orderVirtualGuest(order);
View Full Code Here

      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);
      }
View Full Code Here

      public GetImageForVirtualGuest(SoftLayerClient client) {
         this.client = client;
      }

      public Image getImage(VirtualGuest guest) {
         ProductOrder order = null;
         // 'bad' orders have no start cpu's and cause the order lookup to fail.
         if (guest.getStartCpus() < 1)
            return null;
         try {
            order = client.getVirtualGuestClient().getOrderTemplate(guest.getId());
         } catch (SoftLayerOrderItemDuplicateException e) {
            // this is a workaround because SoftLayer throws sometimes 500 internal server errors for the above method call
            logger.warn(e, "Cannot get order template for virtualGuestId(%s)", guest.getId());
         }
         if (order == null)
            return null;
         Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
         ProductItem os = Iterables.find(items, ProductItemPredicates.categoryCode("os"));
         if (os.getPrices().isEmpty())
             return null;
         return new ProductItemToImage().apply(os);
      }
View Full Code Here

      prices.add(osPrice);

      VirtualGuest guest = VirtualGuest.builder().domain("jclouds.org").hostname(
               TEST_HOSTNAME_PREFIX + new Random().nextInt()).build();

      ProductOrder order = ProductOrder.builder().packageId(pkgId).quantity(1).useHourlyPricing(true).prices(
               prices.build()).virtualGuests(guest).build();

      ProductOrderReceipt receipt = api().orderVirtualGuest(order);
      ProductOrder order2 = receipt.getOrderDetails();
      VirtualGuest result = Iterables.get(order2.getVirtualGuests(), 0);

      ProductOrder order3 = api().getOrderTemplate(result.getId());

      assertEquals(order.getPrices(), order3.getPrices());
      assertNotNull(receipt);
   }
View Full Code Here

   }

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

TOP

Related Classes of org.jclouds.softlayer.domain.ProductOrder

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.