Package org.jclouds.compute

Examples of org.jclouds.compute.ComputeServiceContext


      client = view.getComputeService();
   }

   @Test(enabled = true, expectedExceptions = AuthorizationException.class)
   public void testCorrectAuthException() throws Exception {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(provider + ".identity", "MOMMA");
         overrides.setProperty(provider + ".credential", "MIA");
         context = newBuilder()
               .modules(ImmutableSet.of(getLoggingModule(), credentialStoreModule))
               .overrides(overrides).build(ComputeServiceContext.class);
         context.getComputeService().listNodes();
      } catch (AuthorizationException e) {
         throw e;
      } catch (RuntimeException e) {
         e.printStackTrace();
         throw e;
      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here


      assertEquals(defaultTemplate.getOptions().getClass(), SoftLayerTemplateOptions.class);
   }

   @Test
   public void testTemplateBuilderFindsGigabitUplink() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "1000");

         context = createView(overrides, setupModules());

         // TODO add something to the template about port speed?
         context.getComputeService().templateBuilder().build();

      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      }
   }

   @Test
   public void testTemplateBuilderFindsMegabitUplink() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "100");

         context = createView(overrides, setupModules());

         // TODO add something to the template about port speed?
         context.getComputeService().templateBuilder().build();

      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      }
   }

   @Test
   public void testBiggestTemplateBuilderWhenBootIsSAN() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "SAN");

         context = createView(overrides, setupModules());

         Template template = context.getComputeService().templateBuilder().biggest().build();
         assertEquals(getCores(template.getHardware()), 16.0d);
         assertEquals(template.getHardware().getRam(), 16);
         assertEquals(getSpace(template.getHardware()), 100.0d);
         assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.SAN);
      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      }
   }

   @Test
   public void testDefaultTemplateBuilderWhenPrivateNetwork() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?");

         context = createView(overrides, setupModules());

         Template template = context.getComputeService().templateBuilder().build();
         assertEquals(getCores(template.getHardware()), 1.0d);
         assertEquals(template.getHardware().getRam(), 1);
         assertEquals(getSpace(template.getHardware()), 25.0d);
         assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL);
      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      }
   }

   @Test
   public void testBiggestTemplateBuilderWhenPrivateNetwork() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?");

         context = createView(overrides, setupModules());
        
         Template template = context.getComputeService().templateBuilder().biggest().build();
         assertEquals(getCores(template.getHardware()), 8.0d);
         assertEquals(template.getHardware().getRam(), 16);
         assertEquals(getSpace(template.getHardware()), 100.0d);
         assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL);
      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      assertEquals(microTemplate.getImage().getOperatingSystem().getArch(), "paravirtual");
   }

   @Test
   public void testTemplateBuilderWithNoOwnersParsesImageOnDemand() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         // set owners to nothing
         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "");
         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");

         context = createView(overrides, setupModules());

         assertEquals(context.getComputeService().listImages().size(), 0);

         Template template = context.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5").build();
         System.out.println(template.getHardware());
         assert (template.getImage().getProviderId().startsWith("ami-")) : template;
         assertEquals(template.getImage().getOperatingSystem().getVersion(), "5.4");
         assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
         assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
         assertEquals(template.getImage().getVersion(), "4.4.10");
         assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
         assertEquals(template.getLocation().getId(), "us-east-1");
         assertEquals(getCores(template.getHardware()), 1.0d);
         assertEquals(template.getHardware().getId(), "m1.small");

         // ensure we cache the new image for next time
         assertEquals(context.getComputeService().listImages().size(), 1);

      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      }
   }

   @Test
   public void testTemplateBuilderWithNoOwnersParsesImageOnDemandDeprecated() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         // set owners to nothing
         overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "");
         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");

         context = createView(overrides, setupModules());

         assertEquals(context.getComputeService().listImages().size(), 0);

         Template template = context.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5").build();
         System.out.println(template.getHardware());
         assert (template.getImage().getProviderId().startsWith("ami-")) : template;
         assertEquals(template.getImage().getOperatingSystem().getVersion(), "5.4");
         assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
         assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
         assertEquals(template.getImage().getVersion(), "4.4.10");
         assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
         assertEquals(template.getLocation().getId(), "us-east-1");
         assertEquals(getCores(template.getHardware()), 1.0d);
         assertEquals(template.getHardware().getId(), "m1.small");

         // ensure we cache the new image for next time
         assertEquals(context.getComputeService().listImages().size(), 1);

      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      }
   }

   @Test
   public void testTemplateBuilderWithLessRegions() throws IOException, SecurityException, NoSuchMethodException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         // set regions to only 1
         overrides.setProperty(LocationConstants.PROPERTY_REGIONS, Region.EU_WEST_1);
         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_REGIONS, "");
         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "");
         overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");

         final List<HttpCommand> commandsInvoked = Lists.newArrayList();
        
         context = createView(
               overrides,
               ImmutableSet.<Module> of(new Log4JLoggingModule(),
                     TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked)));

         assert context.getComputeService().listAssignableLocations().size() < this.view.getComputeService()
               .listAssignableLocations().size();

         assertOnlyOneRegionQueriedForAvailabilityZone(commandsInvoked);

         assert context.getComputeService().listImages().size() < this.view.getComputeService().listImages().size();

         Template template = context.getComputeService().templateBuilder().imageId("eu-west-1/ami-a33b06d7").build();
         assert (template.getImage().getProviderId().startsWith("ami-")) : template;
         assertEquals(template.getImage().getOperatingSystem().getVersion(), "2011.09.2");
         assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
         assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
         assertEquals(template.getImage().getVersion(), "2011.09.2");
         assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
         assertEquals(template.getLocation().getId(), "eu-west-1");
         assertEquals(getCores(template.getHardware()), 1.0d);
         assertEquals(template.getHardware().getId(), "m1.small");

      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

  public static ComputeServiceContext build(ClusterSpec spec) throws IOException {
    Set<AbstractModule> wiring = ImmutableSet.of(new JschSshClientModule(),
      new Log4JLoggingModule());

    ComputeServiceContext context = new ComputeServiceContextFactory()
      .createContext(spec.getProvider(), spec.getIdentity(), spec.getCredential(),
        wiring);

    return context;
  }
View Full Code Here

TOP

Related Classes of org.jclouds.compute.ComputeServiceContext

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.