@Override
 public <R extends HttpRequest> R bindToRequest(R request, Object input) {
   checkArgument(
       checkNotNull(input, "input") instanceof Map,
       "This binder is only valid for Map<String,String>");
   return AWSUtils.indexMapToFormValuesWithPrefix(request, "Tag", "Key", "Value", input);
 }
 private Set<RunningInstance> createKeyPairAndSecurityGroupsAsNeededThenRunInstances(
     String group, int count, Template template) {
   String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation());
   String zone = getZoneFromLocationOrNull(template.getLocation());
   RunInstancesOptions instanceOptions =
       createKeyPairAndSecurityGroupsAsNeededAndReturncustomize.execute(region, group, template);
   return createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions);
 }
 @Override
 public org.jclouds.compute.domain.Image getImage(String id) {
   checkNotNull(id, "id");
   String[] parts = AWSUtils.parseHandle(id);
   String region = parts[0];
   String instanceId = parts[1];
   try {
     Image image = getImageInRegion(region, instanceId);
     return imageToImage.apply(image);
   } catch (NoSuchElementException e) {
     return null;
   }
 }
예제 #4
0
 protected Reservation<? extends RunningInstance> newReservation() {
   String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;
   if (region == null) region = defaultRegion.get();
   Reservation<? extends RunningInstance> info =
       new Reservation<RunningInstance>(
           region, groupNames, instances, ownerId, requesterId, reservationId);
   this.groupNames = Sets.newLinkedHashSet();
   this.instances = Sets.newLinkedHashSet();
   this.ownerId = null;
   this.requesterId = null;
   this.reservationId = null;
   return info;
 }
예제 #5
0
 @Override
 public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
   if (response.getStatusCode() == 503) {
     // Content can be null in the case of HEAD requests
     if (response.getPayload() != null) {
       closeClientButKeepContentStream(response);
       AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response);
       if (error != null) {
         return shouldRetryRequestOnError(command, response, error);
       }
     }
   }
   return false;
 }
  public void endElement(String uri, String localName, String qName) {
    // if end tag is one of below then set inXYZ to false
    if (qName.equals("ListenerDescriptions")) {
      inListenerDescriptions = false;
    } else if (qName.equals("AppCookieStickinessPolicies")) {
      inAppCookieStickinessPolicies = false;
    } else if (qName.equals("LBCookieStickinessPolicies")) {
      inLBCookieStickinessPolicies = false;
    } else if (qName.equals("LoadBalancerDescriptions")) {
      inLoadBalancerDescriptions = false;
    } else if (qName.equals("Instances")) {
      inInstances = false;
    } else if (qName.equals("AvailabilityZones")) {
      inAvailabilityZones = false;
    }

    if (qName.equals("DNSName")) {
      elb.setDnsName(currentText.toString().trim());
    } else if (qName.equals("LoadBalancerName")) {
      elb.setName(currentText.toString().trim());
    } else if (qName.equals("InstanceId")) {
      elb.getInstanceIds().add(currentText.toString().trim());
    } else if (qName.equals("member")) {

      if (inAvailabilityZones) {
        elb.getAvailabilityZones().add(currentText.toString().trim());
      } else if (!(inListenerDescriptions
          || inAppCookieStickinessPolicies
          || inInstances
          || inLBCookieStickinessPolicies
          || inAvailabilityZones)) {
        try {
          String region = AWSUtils.findRegionInArgsOrNull(getRequest());
          elb.setRegion(region);
          contents.add(elb);
        } catch (NullPointerException e) {
          logger.warn(e, "malformed load balancer: %s", localName);
        }

        this.elb = null;
      }
    }

    currentText = new StringBuilder();
  }
예제 #7
0
  protected void refineBuilderBeforeAddingInstance() {
    String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;

    // Eucalyptus
    if (builder.getIpAddress() == null
        && builder.getDnsName() != null
        && builder.getDnsName().matches(".*[0-9]$")) {
      builder.ipAddress(builder.getDnsName());
      builder.dnsName(null);
    }
    if (builder.getPrivateIpAddress() == null
        && builder.getPrivateDnsName() != null
        && builder.getPrivateDnsName().matches(".*[0-9]$")) {
      builder.privateIpAddress(builder.getPrivateDnsName());
      builder.privateDnsName(null);
    }

    builder.region((region == null) ? defaultRegion.get() : region);
    builder.groupNames(groupNames);
  }
 @Override
 public CreateVolumeResponseHandler setContext(HttpRequest request) {
   super.setContext(request);
   region = AWSUtils.findRegionInArgsOrNull(getRequest());
   if (region == null) {
     Set<String> zones = zonesSupplier.get();
     String zone = findAvailabilityZoneInArgsOrNull(getRequest(), zones);
     if (zone != null) {
       Map<String, Set<String>> regionToZones =
           Maps.transformValues(
               regionToZonesSupplier.get(), Suppliers.<Set<String>>supplierFunction());
       for (Entry<String, Set<String>> entry : regionToZones.entrySet()) {
         if (entry.getValue().contains(zone)) {
           region = entry.getKey();
           break;
         }
       }
       checkNotNull(regionToZones, String.format("zone %s not in %s", zone, regionToZones));
     } else {
       region = defaultRegion.get();
     }
   }
   return this;
 }
예제 #9
0
 protected void refineBuilderBeforeAddingInstance() {
   String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;
   builder.region((region == null) ? defaultRegion.get() : region);
 }