Package org.jclouds.compute

Examples of org.jclouds.compute.ComputeServiceContext


      }
   }

   @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(), MAX_RAM);
         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*1024);
         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(), MAX_RAM);
         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

  @Override
  public void deleteVolume(String volumeId) {
    IaasProvider iaasInfo = getIaasProvider();

    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();
   
    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
   
    if(region == null) {
      log.fatal("Cannot delete the volume [id]: "+volumeId+" of the [region] : "+region
          +" of Iaas : "+iaasInfo);
      return;
    }
   
    ElasticBlockStoreApi blockStoreApi = context.unwrapApi(AWSEC2Api.class).getElasticBlockStoreApiForRegion(region).get();
    blockStoreApi.deleteVolumeInRegion(region, volumeId);
   
    log.info("Deletion of Volume [id]: "+volumeId+" was successful. [region] : " + region
        + " of Iaas : " + iaasInfo);
  }
View Full Code Here

   
    IaasProvider iaasInfo = getIaasProvider();

    String ec2Msg = " ec2. Region: " + region + " - Key Pair Name: ";

    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();
   
    AWSKeyPairApi keyPairApi = context.unwrapApi(AWSEC2Api.class).getKeyPairApiForRegion(region).get();

    KeyPair keyPair = keyPairApi.importKeyPairInRegion(region, keyPairName, publicKey);
   
    if (keyPair != null) {
View Full Code Here

  @Override
  public synchronized String associateAddress(NodeMetadata node) {

    IaasProvider iaasInfo = getIaasProvider();
   
    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();
   
    ElasticIPAddressApi elasticIPAddressApi = context.unwrapApi(AWSEC2Api.class).getElasticIPAddressApi().get();
    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
   
    String ip = null;

    // first try to find an unassigned IP.
View Full Code Here

  @Override
  public synchronized void releaseAddress(String ip) {

    IaasProvider iaasInfo = getIaasProvider();
   
    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();
    ElasticIPAddressApi elasticIPAddressApi = context.unwrapApi(AWSEC2Api.class).getElasticIPAddressApi().get();
    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);

    elasticIPAddressApi.disassociateAddressInRegion(
        region, ip);
    elasticIPAddressApi.releaseAddressInRegion(region,
View Full Code Here

                                 iaasInfo;
            log.error(msg);
            throw new InvalidRegionException(msg);
        }
       
        ComputeServiceContext context = iaasInfo.getComputeService().getContext();
        Set<String> regions = context.unwrapApi(AWSEC2Api.class).getConfiguredRegions();
        for (String configuredRegion : regions) {
            if (region.equalsIgnoreCase(configuredRegion)) {
                if (log.isDebugEnabled()) {
                    log.debug("Found a matching region: " + region);
                }
View Full Code Here

                         "Zone or IaaSProvider is null: zone: " + zone + " - IaaSProvider: " +
                                 iaasInfo;
            log.error(msg);
            throw new InvalidZoneException(msg);
        }
        ComputeServiceContext context = iaasInfo.getComputeService().getContext();
        AvailabilityZoneAndRegionApi zoneRegionApi = context.unwrapApi(AWSEC2Api.class).
            getAvailabilityZoneAndRegionApiForRegion(region).get();
       
        Set<AvailabilityZoneInfo> availabilityZones =
                                                      zoneRegionApi.describeAvailabilityZonesInRegion(region,
                                                              new DescribeAvailabilityZonesOptions[0]);
View Full Code Here

  @Override
  public String createVolume(int sizeGB) {
    IaasProvider iaasInfo = getIaasProvider();

    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();
   
    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
    String zone = ComputeServiceBuilderUtil.extractZone(iaasInfo);
   
    if(region == null || zone == null) {
      log.fatal("Cannot create a new volume in the [region] : "+region
          +", [zone] : "+zone+" of Iaas : "+iaasInfo);
      return null;
    }
   
    ElasticBlockStoreApi blockStoreApi = context.unwrapApi(AWSEC2Api.class).getElasticBlockStoreApiForRegion(region).get();
   
    Volume volume = blockStoreApi.createVolumeInAvailabilityZone(zone, sizeGB);
   
    if (volume == null) {
      log.fatal("Volume creation was unsuccessful. [region] : " + region
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.