Skip to content

Commit

Permalink
JENKINS-17086 Undo some whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ww-mgr committed May 10, 2013
1 parent 7d01782 commit 7d8a169
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions src/main/java/hudson/plugins/ec2/SlaveTemplate.java
Expand Up @@ -81,7 +81,7 @@ public class SlaveTemplate implements Describable<SlaveTemplate> {
private final List<EC2Tag> tags;
public final boolean usePrivateDnsName;
protected transient EC2Cloud parent;


private transient /*almost final*/ Set<LabelAtom> labelSet;
private transient /*almost final*/ Set<String> securityGroupSet;
Expand Down Expand Up @@ -120,11 +120,11 @@ public SlaveTemplate(String ami, String zone, SpotConfiguration spotConfig, Stri

readResolve(); // initialize
}

public EC2Cloud getParent() {
return parent;
}

public String getBidType(){
if(spotConfig == null)
return null;
Expand Down Expand Up @@ -199,7 +199,7 @@ public List<EC2Tag> getTags() {
public String getidleTerminationMinutes() {
return idleTerminationMinutes;
}

public Set<LabelAtom> getLabelSet(){
return labelSet;
}
Expand Down Expand Up @@ -237,8 +237,8 @@ public boolean containsLabel(Label l) {
return l==null || labelSet.contains(l);
}



/**
* Provisions a new EC2 slave.
*
Expand All @@ -250,7 +250,7 @@ public EC2AbstractSlave provision(TaskListener listener) throws AmazonClientExce
}
return provisionOndemand(listener);
}

/**
* Provisions new On-demand EC2 slave.
*/
Expand All @@ -261,12 +261,12 @@ private EC2AbstractSlave provisionOndemand(TaskListener listener) throws AmazonC
try {
logger.println("Launching " + ami + " for template " + description);
KeyPair keyPair = getKeyPair(ec2);

RunInstancesRequest riRequest = new RunInstancesRequest(ami, 1, 1);

List<Filter> diFilters = new ArrayList<Filter>();
diFilters.add(new Filter("image-id").withValues(ami));

if (StringUtils.isNotBlank(getZone())) {
Placement placement = new Placement(getZone());
riRequest.setPlacement(placement);
Expand Down Expand Up @@ -309,9 +309,9 @@ private EC2AbstractSlave provisionOndemand(TaskListener listener) throws AmazonC
diFilters.add(new Filter("tag:"+t.getName()).withValues(t.getValue()));
}
}

DescribeInstancesRequest diRequest = new DescribeInstancesRequest();
diFilters.add(new Filter("instance-state-name").withValues(InstanceStateName.Stopped.toString(),
diFilters.add(new Filter("instance-state-name").withValues(InstanceStateName.Stopped.toString(),
InstanceStateName.Stopping.toString()));
diRequest.setFilters(diFilters);
logger.println("Looking for existing instances: "+diRequest);
Expand All @@ -331,7 +331,7 @@ private EC2AbstractSlave provisionOndemand(TaskListener listener) throws AmazonC
logger.println("No existing instance found - created: "+inst);
return newOndemandSlave(inst);
}

Instance inst = diResult.getReservations().get(0).getInstances().get(0);
logger.println("Found existing stopped instance: "+inst);
List<String> instances = new ArrayList<String>();
Expand All @@ -350,16 +350,16 @@ private EC2AbstractSlave provisionOndemand(TaskListener listener) throws AmazonC
return ec2Node;
}
}

// Existing slave not found
// Existing slave not found
logger.println("Creating new slave for existing instance: "+inst);
return newOndemandSlave(inst);

} catch (FormException e) {
throw new AssertionError(); // we should have discovered all configuration issues upfront
}
}

/**
* Provision a new slave for an EC2 spot instance to call back to Jenkins
*/
Expand Down Expand Up @@ -557,7 +557,7 @@ public EC2AbstractSlave attach(String instanceId, TaskListener listener) throws
protected Object readResolve() {
labelSet = Label.parse(labels);
securityGroupSet = parseSecurityGroups();

/**
* In releases of this plugin prior to 1.18, template-specific instance caps could be configured
* but were not enforced. As a result, it was possible to have the instance cap for a template
Expand Down Expand Up @@ -622,7 +622,7 @@ public FormValidation doValidateAmi(
return FormValidation.error("No such AMI, or not usable with this accessId: "+ami);
}
String ownerAlias = img.get(0).getImageOwnerAlias();
return FormValidation.ok(img.get(0).getImageLocation() +
return FormValidation.ok(img.get(0).getImageLocation() +
(ownerAlias != null ? " by " + ownerAlias : ""));
} catch (AmazonClientException e) {
return FormValidation.error(e.getMessage());
Expand All @@ -649,7 +649,7 @@ public FormValidation doCheckInstanceCapStr(@QueryParameter String value) {
} catch ( NumberFormatException nfe ) {}
return FormValidation.error("InstanceCap must be a non-negative integer (or null)");
}

public ListBoxModel doFillZoneItems( @QueryParameter String accessId,
@QueryParameter String secretKey,
@QueryParameter String region)
Expand All @@ -665,21 +665,21 @@ public FormValidation doCheckSpotMaxBidPrice( @QueryParameter String spotMaxBidP
}
return FormValidation.error("Not a correct bid price");
}

// Retrieve the availability zones for the region
private ArrayList<String> getAvailabilityZones(AmazonEC2 ec2) {
ArrayList<String> availabilityZones = new ArrayList<String>();

DescribeAvailabilityZonesResult zones = ec2.describeAvailabilityZones();
List<AvailabilityZone> zoneList = zones.getAvailabilityZones();

for (AvailabilityZone z : zoneList) {
availabilityZones.add(z.getZoneName());
}

return availabilityZones;
}

/**
* Populates the Bid Type Drop down on the slave template config.
* @return
Expand All @@ -688,17 +688,17 @@ public ListBoxModel doFillBidTypeItems() {
ListBoxModel items = new ListBoxModel();
items.add(SpotInstanceType.OneTime.toString());
items.add(SpotInstanceType.Persistent.toString());
return items;
return items;
}

/* Check the current Spot price of the selected instance type for the selected region */
public FormValidation doCurrentSpotPrice( @QueryParameter String accessId, @QueryParameter String secretKey,
@QueryParameter String region, @QueryParameter String type,
@QueryParameter String zone ) throws IOException, ServletException {

String cp = "";
String zoneStr = "";

// Connect to the EC2 cloud with the access id, secret key, and region queried from the created cloud
AmazonEC2 ec2 = EC2Cloud.connect(accessId, secretKey, AmazonEC2Cloud.getEc2EndpointUrl(region));

Expand All @@ -715,7 +715,7 @@ public FormValidation doCurrentSpotPrice( @QueryParameter String accessId, @Quer
} else {
zoneStr = region + " region";
}

/*
* Iterate through the AWS instance types to see if can find a match for the databound
* String type. This is necessary because the AWS API needs the instance type
Expand All @@ -730,7 +730,7 @@ public FormValidation doCurrentSpotPrice( @QueryParameter String accessId, @Quer
break;
}
}

/*
* If the type string cannot be matched with an instance type,
* throw a Form error
Expand All @@ -752,7 +752,7 @@ public FormValidation doCurrentSpotPrice( @QueryParameter String accessId, @Quer

cp = currentPrice.getSpotPrice();
}

} catch (AmazonClientException e) {
return FormValidation.error(e.getMessage());
}
Expand All @@ -767,7 +767,7 @@ public FormValidation doCurrentSpotPrice( @QueryParameter String accessId, @Quer
} else {
cp = cp.substring(0, cp.length() - 3);

return FormValidation.ok("The current Spot price for a " + type +
return FormValidation.ok("The current Spot price for a " + type +
" in the " + zoneStr + " is $" + cp );
}
}
Expand Down

0 comments on commit 7d8a169

Please sign in to comment.