Package org.jclouds.ec2.compute.functions

Examples of org.jclouds.ec2.compute.functions.EC2ImageParser


      Location location = getLocationForAvailabilityZoneOrRegion(instance);
      builder.location(location);
      builder.imageId(instance.getRegion() + "/" + instance.getImageId());

      // extract the operating system from the image
      RegionAndName regionAndName = new RegionAndName(instance.getRegion(), instance.getImageId());
      try {
         Image image = imageMap.get().getUnchecked(regionAndName);
         if (image != null)
            builder.operatingSystem(image.getOperatingSystem());
      } catch (CacheLoader.InvalidCacheLoadException e) {
View Full Code Here


      return credentials;
   }

   @VisibleForTesting
   String getPrivateKeyOrNull(RunningInstance instance) {
      KeyPair keyPair = credentialsMap.get(new RegionAndName(instance.getRegion(), instance.getKeyName()));
      return keyPair != null ? keyPair.getKeyMaterial() : null;
   }
View Full Code Here

               logger.debug("<< inUse keyPair(%s), by (%s)", keyPair.getKeyName(), instancesUsingKeyPair);
            } else {
               logger.debug(">> deleting keyPair(%s)", keyPair.getKeyName());
               client.getKeyPairServices().deleteKeyPairInRegion(region, keyPair.getKeyName());
               // TODO: test this clear happens
               credentialsMap.remove(new RegionAndName(region, keyPair.getKeyName()));
               credentialsMap.remove(new RegionAndName(region, group));
               logger.debug("<< deleted keyPair(%s)", keyPair.getKeyName());
            }
         }
      }
   }
View Full Code Here

            } catch (IllegalStateException e) {
               logger.debug("<< inUse incidentalResources(%s)", input);
               return false;
            }
         }
      }, SECONDS.toMillis(3), 50, 1000, MILLISECONDS).apply(new RegionAndName(region, group));
   }
View Full Code Here

      checkNotNull(region, "region");
      checkNotNull(name, "name");
      logger.debug(">> creating securityGroup region(%s) name(%s)", region, name);
      try {
         securityClient.createSecurityGroupInRegion(region, name, name);
         boolean created = securityGroupEventualConsistencyDelay.apply(new RegionAndName(region, name));
         if (!created)
            throw new RuntimeException(String.format("security group %s/%s is not available after creating", region,
                  name));
         logger.debug("<< created securityGroup(%s)", name);
         for (int port : ports) {
View Full Code Here

   protected void releaseAnyPublicIpForInstanceInRegion(String instanceId, String region) {
      if (!autoAllocateElasticIps)
         return;
      try {
         String ip = elasticIpCache.get(new RegionAndName(region, instanceId));
         logger.debug(">> disassociating elastic IP %s", ip);
         client.getElasticIPAddressServices().disassociateAddressInRegion(region, ip);
         logger.trace("<< disassociated elastic IP %s", ip);
         elasticIpCache.invalidate(new RegionAndName(region, instanceId));
         logger.debug(">> releasing elastic IP %s", ip);
         client.getElasticIPAddressServices().releaseAddressInRegion(region, ip);
         logger.trace("<< released elastic IP %s", ip);
      } catch (CacheLoader.InvalidCacheLoadException e) {
         // no ip was found
View Full Code Here

   private void blockUntilRunningAndAssignElasticIpsToInstancesOrPutIntoBadMap(Set<RunningInstance> input,
         Map<NodeMetadata, Exception> badNodes) {
      Map<RegionAndName, RunningInstance> instancesById = Maps.uniqueIndex(input, instanceToRegionAndName);
      for (Map.Entry<RegionAndName, RunningInstance> entry : instancesById.entrySet()) {
         RegionAndName id = entry.getKey();
         RunningInstance instance = entry.getValue();
         try {
            logger.debug("<< allocating elastic IP instance(%s)", id);
            String ip = client.getElasticIPAddressServices().allocateAddressInRegion(id.getRegion());
            // block until instance is running
            logger.debug(">> awaiting status running instance(%s)", id);
            AtomicReference<NodeMetadata> node = newReference(runningInstanceToNodeMetadata
                  .apply(instance));
            nodeRunning.apply(node);
            logger.trace("<< running instance(%s)", id);
            logger.debug(">> associating elastic IP %s to instance %s", ip, id);
            client.getElasticIPAddressServices().associateAddressInRegion(id.getRegion(), ip, id.getName());
            logger.trace("<< associated elastic IP %s to instance %s", ip, id);
            // add mapping of instance to ip into the cache
            elasticIpCache.put(id, ip);
         } catch (RuntimeException e) {
            badNodes.put(runningInstanceToNodeMetadata.apply(instancesById.get(id)), e);
View Full Code Here

         @Memoized Supplier<Set<? extends Hardware>> sizes, Location defaultLocation,
         Provider<TemplateOptions> optionsProvider, Provider<TemplateBuilder> templateBuilderProvider) {

      LoadingCache<RegionAndName, ? extends Image> imageMap;
      if (knownImage != null) {
         final RegionAndName knownRegionAndName = new RegionAndName(knownImage.getLocation().getId(), knownImage.getProviderId());

         imageMap = CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image>() {
            @Override
            public Image load(RegionAndName from) {
               return from.equals(knownRegionAndName) ? knownImage : null;
View Full Code Here

     
      if (client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, groupName).size() > 0) {
         logger.debug(">> deleting securityGroup(%s)", groupName);
         client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, groupName);
         // TODO: test this clear happens
         securityGroupMap.invalidate(new RegionNameAndIngressRules(region, groupName, null, false));
         logger.debug("<< deleted securityGroup(%s)", groupName);
      }
   }
View Full Code Here

            "securityGroupEventualConsistencyDelay");
   }

   @Override
   public String load(RegionAndName from) {
      RegionNameAndIngressRules realFrom = RegionNameAndIngressRules.class.cast(from);
      createSecurityGroupInRegion(from.getRegion(), from.getName(), realFrom.getPorts());
      return from.getName();
   }
View Full Code Here

TOP

Related Classes of org.jclouds.ec2.compute.functions.EC2ImageParser

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.