Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vpc public ips #500

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class AutoScalingController {
String groupName = Relationships.buildGroupName(params)
Subnets subnets = awsEc2Service.getSubnets(userContext)
String subnetPurpose = params.subnetPurpose ?: null
String vpcId = subnets.getVpcIdForSubnetPurpose(subnetPurpose) ?: ''
String vpcId = subnets.getVpcIdForSubnetPurpose(subnetPurpose) ?: ''

// Auto Scaling Group
Integer minSize = (params.min ?: 0) as Integer
Expand Down Expand Up @@ -336,10 +336,11 @@ class AutoScalingController {
String ramdiskId = params.ramdiskId ?: null
String iamInstanceProfile = params.iamInstanceProfile ?: configService.defaultIamRole
boolean ebsOptimized = params.ebsOptimized?.toBoolean()
boolean associatePublicIpAddress = params.associatePublicIpAddress ?: false
LaunchConfiguration launchConfigTemplate = new LaunchConfiguration().withImageId(imageId).
withKernelId(kernelId).withInstanceType(instType).withKeyName(keyName).withRamdiskId(ramdiskId).
withSecurityGroups(securityGroups).withIamInstanceProfile(iamInstanceProfile).
withEbsOptimized(ebsOptimized)
withEbsOptimized(ebsOptimized).withAssociatePublicIpAddress(associatePublicIpAddress)
if (params.pricing == InstancePriceType.SPOT.name()) {
launchConfigTemplate.spotPrice = spotInstanceRequestService.recommendSpotPrice(userContext, instType)
}
Expand Down
19 changes: 15 additions & 4 deletions grails-app/controllers/com/netflix/asgard/ClusterController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ class ClusterController {
withFormat {
html {
AutoScalingGroupData lastGroup = cluster.last()
LaunchConfiguration lastLaunchConfig = awsAutoScalingService.
getLaunchConfiguration(userContext, lastGroup.launchConfigurationName, From.CACHE)
boolean associatePublicIpAddress = false
if (lastLaunchConfig) {
associatePublicIpAddress = lastLaunchConfig.isAssociatePublicIpAddress()
}
String nextGroupName = Relationships.buildNextAutoScalingGroupName(lastGroup.autoScalingGroupName)
Boolean okayToCreateGroup = cluster.size() < Relationships.CLUSTER_MAX_GROUPS
String recommendedNextStep = cluster.size() >= Relationships.CLUSTER_MAX_GROUPS ?
Expand Down Expand Up @@ -161,7 +167,9 @@ ${lastGroup.loadBalancerNames}"""
loadBalancersGroupedByVpcId: loadBalancers.groupBy { it.VPCId },
selectedLoadBalancers: selectedLoadBalancers,
spotUrl: configService.spotUrl,
pricing: params.pricing ?: attributes.pricing
associatePublicIpAddress: lastLaunchConfig.getAssociatePublicIpAddress(),
pricing: params.pricing ?: attributes.pricing,

])
attributes
}
Expand Down Expand Up @@ -430,6 +438,8 @@ ${loadBalancerNames}"""
Group: ${lastGroup.loadBalancerNames}"""
boolean ebsOptimized = params.containsKey('ebsOptimized') ? params.ebsOptimized?.toBoolean() :
lastLaunchConfig.ebsOptimized
boolean associatePublicIpAddress = params.containsKey('associatePublicIpAddress') ? params.associatePublicIpAddress?.toBoolean() :
lastLaunchConfig.associatePublicIpAddress
if (params.noOptionalDefaults != 'true') {
securityGroups = securityGroups ?: lastLaunchConfig.securityGroups
termPolicies = termPolicies ?: lastGroup.terminationPolicies
Expand All @@ -440,7 +450,7 @@ Group: ${lastGroup.loadBalancerNames}"""
log.debug """ClusterController.createNextGroup for Cluster '${cluster.name}' Load Balancers for next \
Group: ${loadBalancerNames}"""
GroupCreateOptions options = new GroupCreateOptions(
common: new CommonPushOptions(
common: new CommonPushOptions(
userContext: userContext,
checkHealth: checkHealth,
afterBootWait: convertToIntOrUseDefault(params.afterBootWait, 30),
Expand All @@ -450,7 +460,7 @@ Group: ${loadBalancerNames}"""
instanceType: instanceType,
groupName: nextGroupName,
securityGroups: securityGroups,
maxStartupRetries: convertToIntOrUseDefault(params.maxStartupRetries, 5)
maxStartupRetries: convertToIntOrUseDefault(params.maxStartupRetries, 5)
),
initialTraffic: initialTraffic,
minSize: minSize,
Expand All @@ -470,7 +480,8 @@ Group: ${loadBalancerNames}"""
scheduledActions: newScheduledActions,
vpcZoneIdentifier: vpcZoneIdentifier,
spotPrice: spotPrice,
ebsOptimized: ebsOptimized
ebsOptimized: ebsOptimized,
associatePublicIpAddress: associatePublicIpAddress
)
def operation = pushService.startGroupCreate(options)
flash.message = "${operation.task.name} has been started."
Expand Down
8 changes: 8 additions & 0 deletions grails-app/views/launchConfiguration/_launchConfigOptions.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@
</div>
</td>
</tr>
<tr class="prop advanced" title="Enables associating of public IP addresses to VPC instances.">
<td class="name">
<label for="associatePublicIPAddress">Associate Public IP's:</label>
</td>
<td>
<input type="checkbox" id="associatePublicIpAddress" name="associatePublicIpAddress" value="1" <g:if test="${associatePublicIpAddress == true}">checked</g:if> />
</td>
</tr>
<tr class="prop advanced">
<td class="name">
<label for="kernelId">Kernel ID:</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
<td class="name"><g:link controller="instanceType" action="list">Instance Type:</g:link></td>
<td class="value">${launchTemplate.instanceType}</td>
</tr>
<tr class="prop">
<td class="name">VPC Associate Public IP's:</td>
<td class="value">${launchTemplate.associatePublicIpAddress}</td>
</tr>
<g:if test="${launchTemplate.kernelId}">
<tr class="prop">
<td class="name">Kernel ID:</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ import groovy.transform.Canonical

/** @see LaunchConfiguration#ebsOptimized */
Boolean ebsOptimized

/** @see LaunchConfiguration#associatePublicIpAddress */
Boolean associatePublicIpAddress

void setSecurityGroups(Collection<String> securityGroups) {
this.securityGroups = copyNonNullToSet(securityGroups)
Expand Down Expand Up @@ -95,6 +98,7 @@ import groovy.transform.Canonical
static LaunchConfigurationBeanOptions from(LaunchConfigurationBeanOptions source) {
new LaunchConfigurationBeanOptions(
launchConfigurationName: source.launchConfigurationName,
associatePublicIpAddress: source.associatePublicIpAddress,
imageId: source.imageId,
keyName: source.keyName,
securityGroups: copyNonNullToSet(source.securityGroups),
Expand All @@ -120,6 +124,7 @@ import groovy.transform.Canonical
launchConfiguration.with {
new LaunchConfigurationBeanOptions(
launchConfigurationName: launchConfigurationName,
associatePublicIpAddress: associatePublicIpAddress,
imageId: imageId,
keyName: keyName,
securityGroups: copyNonNullToSet(securityGroups),
Expand Down Expand Up @@ -151,6 +156,7 @@ import groovy.transform.Canonical
}
new CreateLaunchConfigurationRequest(
launchConfigurationName: launchConfigurationName,
associatePublicIpAddress: associatePublicIpAddress,
imageId: imageId,
keyName: keyName,
securityGroups: copyNonNullToSet(securityGroups),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class GroupCreateOperation extends AbstractPushOperation {
withKeyName(options.keyName).withRamdiskId(options.ramdiskId).
withSecurityGroups(options.common.securityGroups).
withIamInstanceProfile(options.iamInstanceProfile).
withSpotPrice(options.spotPrice).withEbsOptimized(options.ebsOptimized)
withSpotPrice(options.spotPrice).withEbsOptimized(options.ebsOptimized).
withAssociatePublicIpAddress(options.associatePublicIpAddress)

final Collection<AutoScalingProcessType> suspendedProcesses = Sets.newHashSet()
if (options.zoneRebalancingSuspended) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import groovy.transform.Immutable
Collection<ScalingPolicyData> scalingPolicies
Collection<ScheduledUpdateGroupAction> scheduledActions
String spotPrice
boolean associatePublicIpAddress
boolean ebsOptimized

/** The number of instances to create at a time while inflating the auto scaling group. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class AwsAutoScalingServiceIntegrationSpec extends Specification {
withMaxSize(0).withMinSize(0).withDefaultCooldown(0)
final LaunchConfiguration launchConfigTemplate = new LaunchConfiguration().withImageId('ami-deadbeef').
withInstanceType('m1.small').withKeyName('keyName').withSecurityGroups([]).withUserData('').
withEbsOptimized(false)
withEbsOptimized(false).withAssociatePublicIpAddress(true)

when:
final CreateAutoScalingGroupResult result = awsAutoScalingService.createLaunchConfigAndAutoScalingGroup(
Expand All @@ -155,7 +155,7 @@ class AwsAutoScalingServiceIntegrationSpec extends Specification {
'helloworld-example' == result.autoScalingGroupName
result.launchConfigName =~ /helloworld-example-20[0-9]{12}/
!result.launchConfigDeleted
result.launchConfigCreated
result.launchConfigCreated
result.autoScalingGroupCreated
result.toString() =~ "Launch Config 'helloworld-example-20[0-9]{12}' has been created. Auto Scaling Group" +
" 'helloworld-example' has been created. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class LaunchConfigurationBeanOptionsSpec extends Specification {
instanceMonitoring: null,
instancePriceType: InstancePriceType.ON_DEMAND,
iamInstanceProfile: 'iamInstanceProfile1',
ebsOptimized: false
ebsOptimized: false,
associatePublicIpAddress: true
)

LaunchConfiguration awsLaunchConfiguration = new LaunchConfiguration(
Expand All @@ -52,7 +53,8 @@ class LaunchConfigurationBeanOptionsSpec extends Specification {
blockDeviceMappings: [new BlockDeviceMapping(deviceName: 'deviceName1', ebs: new Ebs(volumeSize: 256))],
instanceMonitoring: null,
iamInstanceProfile: 'iamInstanceProfile1',
ebsOptimized: false
ebsOptimized: false,
associatePublicIpAddress: true
)
CreateLaunchConfigurationRequest createLaunchConfigurationRequest = new CreateLaunchConfigurationRequest(
launchConfigurationName: 'launchConfigurationName1',
Expand All @@ -66,7 +68,8 @@ class LaunchConfigurationBeanOptionsSpec extends Specification {
blockDeviceMappings: [new BlockDeviceMapping(deviceName: 'deviceName1', ebs: new Ebs(volumeSize: 256))],
instanceMonitoring: null,
iamInstanceProfile: 'iamInstanceProfile1',
ebsOptimized: false
ebsOptimized: false,
associatePublicIpAddress: true
)

def 'should deep copy'() {
Expand Down