mirror of https://github.com/apache/jclouds.git
Added support for RunInstances parameter PrivateIpAddress on EC2
This commit is contained in:
parent
483f904be5
commit
c47816d124
|
@ -85,6 +85,8 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
||||||
eTo.spotPrice(getSpotPrice());
|
eTo.spotPrice(getSpotPrice());
|
||||||
if (getSpotOptions() != null)
|
if (getSpotOptions() != null)
|
||||||
eTo.spotOptions(getSpotOptions());
|
eTo.spotOptions(getSpotOptions());
|
||||||
|
if (getPrivateIpAddress() != null)
|
||||||
|
eTo.privateIpAddress(getPrivateIpAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +99,7 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
||||||
private Set<String> groupIds = ImmutableSet.of();
|
private Set<String> groupIds = ImmutableSet.of();
|
||||||
private String iamInstanceProfileArn;
|
private String iamInstanceProfileArn;
|
||||||
private String iamInstanceProfileName;
|
private String iamInstanceProfileName;
|
||||||
|
private String privateIpAddress;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
|
@ -110,13 +113,14 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
||||||
&& equal(this.noPlacementGroup, that.noPlacementGroup) && equal(this.subnetId, that.subnetId)
|
&& equal(this.noPlacementGroup, that.noPlacementGroup) && equal(this.subnetId, that.subnetId)
|
||||||
&& equal(this.spotPrice, that.spotPrice) && equal(this.spotOptions, that.spotOptions)
|
&& equal(this.spotPrice, that.spotPrice) && equal(this.spotOptions, that.spotOptions)
|
||||||
&& equal(this.groupIds, that.groupIds) && equal(this.iamInstanceProfileArn, that.iamInstanceProfileArn)
|
&& equal(this.groupIds, that.groupIds) && equal(this.iamInstanceProfileArn, that.iamInstanceProfileArn)
|
||||||
&& equal(this.iamInstanceProfileName, that.iamInstanceProfileName);
|
&& equal(this.iamInstanceProfileName, that.iamInstanceProfileName)
|
||||||
|
&& equal(this.privateIpAddress, that.privateIpAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(super.hashCode(), monitoringEnabled, placementGroup, noPlacementGroup, subnetId,
|
return Objects.hashCode(super.hashCode(), monitoringEnabled, placementGroup, noPlacementGroup, subnetId,
|
||||||
spotPrice, spotOptions, groupIds, iamInstanceProfileArn, iamInstanceProfileName);
|
spotPrice, spotOptions, groupIds, iamInstanceProfileArn, iamInstanceProfileName, privateIpAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,6 +139,7 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
||||||
toString.add("groupIds", groupIds);
|
toString.add("groupIds", groupIds);
|
||||||
toString.add("iamInstanceProfileArn", iamInstanceProfileArn);
|
toString.add("iamInstanceProfileArn", iamInstanceProfileArn);
|
||||||
toString.add("iamInstanceProfileName", iamInstanceProfileName);
|
toString.add("iamInstanceProfileName", iamInstanceProfileName);
|
||||||
|
toString.add("privateIpAddress", privateIpAddress);
|
||||||
return toString;
|
return toString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +200,11 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AWSEC2TemplateOptions privateIpAddress(String address) {
|
||||||
|
this.privateIpAddress = checkNotNull(emptyToNull(address), "address must be defined");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the maximum spot price to use
|
* Specifies the maximum spot price to use
|
||||||
*/
|
*/
|
||||||
|
@ -442,6 +452,11 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
||||||
return options.iamInstanceProfileName(name);
|
return options.iamInstanceProfileName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AWSEC2TemplateOptions privateIpAddress(String address) {
|
||||||
|
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||||
|
return options.privateIpAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AWSEC2TemplateOptions#spotPrice
|
* @see AWSEC2TemplateOptions#spotPrice
|
||||||
*/
|
*/
|
||||||
|
@ -788,4 +803,8 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
||||||
public String getIAMInstanceProfileName() {
|
public String getIAMInstanceProfileName() {
|
||||||
return iamInstanceProfileName;
|
return iamInstanceProfileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPrivateIpAddress() {
|
||||||
|
return privateIpAddress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,8 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions
|
||||||
instanceOptions.withIAMInstanceProfileArn(awsTemplateOptions.getIAMInstanceProfileArn());
|
instanceOptions.withIAMInstanceProfileArn(awsTemplateOptions.getIAMInstanceProfileArn());
|
||||||
if (awsTemplateOptions.getIAMInstanceProfileName() != null)
|
if (awsTemplateOptions.getIAMInstanceProfileName() != null)
|
||||||
instanceOptions.withIAMInstanceProfileName(awsTemplateOptions.getIAMInstanceProfileName());
|
instanceOptions.withIAMInstanceProfileName(awsTemplateOptions.getIAMInstanceProfileName());
|
||||||
|
if (awsTemplateOptions.getPrivateIpAddress() != null)
|
||||||
|
instanceOptions.withPrivateIpAddress(awsTemplateOptions.getPrivateIpAddress());
|
||||||
|
|
||||||
return instanceOptions;
|
return instanceOptions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,16 @@ public class AWSRunInstancesOptions extends RunInstancesOptions {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary IP address for VPC instance. You must specify a value from the IP address range of the subnet.
|
||||||
|
*
|
||||||
|
* @see org.jclouds.aws.ec2.domain.AWSRunningInstance#getPrivateIpAddress()
|
||||||
|
*/
|
||||||
|
public AWSRunInstancesOptions withPrivateIpAddress(String address) {
|
||||||
|
formParameters.put("PrivateIpAddress", checkNotNull(address, "address"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder extends RunInstancesOptions.Builder {
|
public static class Builder extends RunInstancesOptions.Builder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,6 +230,14 @@ public class AWSRunInstancesOptions extends RunInstancesOptions {
|
||||||
return options.withBlockDeviceMappings(mappings);
|
return options.withBlockDeviceMappings(mappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AWSRunInstancesOptions#withPrivateIpAddress(String)
|
||||||
|
*/
|
||||||
|
public static AWSRunInstancesOptions withPrivateIpAdress(String address) {
|
||||||
|
AWSRunInstancesOptions options = new AWSRunInstancesOptions();
|
||||||
|
return options.withPrivateIpAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,6 +25,7 @@ import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.inboundP
|
||||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.installPrivateKey;
|
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.installPrivateKey;
|
||||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.keyPair;
|
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.keyPair;
|
||||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.noKeyPair;
|
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.noKeyPair;
|
||||||
|
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.privateIpAddress;
|
||||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.securityGroupIds;
|
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.securityGroupIds;
|
||||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.securityGroups;
|
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.securityGroups;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -413,4 +414,15 @@ public class AWSEC2TemplateOptionsTest {
|
||||||
public void testIAMInstanceProfileNameNPE() {
|
public void testIAMInstanceProfileNameNPE() {
|
||||||
iamInstanceProfileName(null);
|
iamInstanceProfileName(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPrivateIpAddressStatic() {
|
||||||
|
AWSEC2TemplateOptions options = privateIpAddress("10.0.0.1");
|
||||||
|
assertEquals(options.getPrivateIpAddress(), "10.0.0.1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
|
public void testPrivateIpAddressNPE() {
|
||||||
|
privateIpAddress(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withIAM
|
||||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withIAMInstanceProfileName;
|
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withIAMInstanceProfileName;
|
||||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withKernelId;
|
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withKernelId;
|
||||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withKeyName;
|
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withKeyName;
|
||||||
|
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withPrivateIpAdress;
|
||||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withRamdisk;
|
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withRamdisk;
|
||||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSecurityGroup;
|
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSecurityGroup;
|
||||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSecurityGroupId;
|
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSecurityGroupId;
|
||||||
|
@ -371,4 +372,15 @@ public class AWSRunInstancesOptionsTest {
|
||||||
withBlockDeviceMappings(null);
|
withBlockDeviceMappings(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWithPrivateIpAddressStatic() {
|
||||||
|
AWSRunInstancesOptions options = withPrivateIpAdress("10.0.0.1");
|
||||||
|
assertEquals(options.buildFormParameters().get("PrivateIpAddress"), ImmutableList.of("10.0.0.1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
|
public void testWithPrivateIpAddressStaticNPE() {
|
||||||
|
withPrivateIpAdress(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue