Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
Missing associate public ip address (#26)
Browse files Browse the repository at this point in the history
* check if launch_config has attribute AssociatePublicIpAddress
if yes then send request with attribute, if no then do not send request with attribute

* tabs into spaces lol
  • Loading branch information
jpresky authored and shrinandj committed Mar 25, 2019
1 parent b5c051c commit e6b83ea
Showing 1 changed file with 64 additions and 31 deletions.
95 changes: 64 additions & 31 deletions cloud_provider/aws/aws_minion_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,38 @@ def are_bids_equal(self, cur_bid_info, new_bid_info):
def create_lc_with_spot(self, new_lc_name, launch_config, spot_price):
""" Creates a launch-config for using spot-instances. """
try:
response = self._ac_client.create_launch_configuration(
LaunchConfigurationName=new_lc_name,
ImageId=launch_config.ImageId,
KeyName=launch_config.KeyName,
SecurityGroups=launch_config.SecurityGroups,
ClassicLinkVPCSecurityGroups=launch_config.
ClassicLinkVPCSecurityGroups,
UserData=base64.b64decode(launch_config.UserData),
InstanceType=launch_config.InstanceType,
BlockDeviceMappings=launch_config.BlockDeviceMappings,
InstanceMonitoring=launch_config.InstanceMonitoring,
SpotPrice=spot_price,
IamInstanceProfile=launch_config.IamInstanceProfile,
EbsOptimized=launch_config.EbsOptimized,
AssociatePublicIpAddress=launch_config.
AssociatePublicIpAddress)
if hasattr(launch_config, "AssociatePublicIpAddress"):
response = self._ac_client.create_launch_configuration(
LaunchConfigurationName=new_lc_name,
ImageId=launch_config.ImageId,
KeyName=launch_config.KeyName,
SecurityGroups=launch_config.SecurityGroups,
ClassicLinkVPCSecurityGroups=launch_config.
ClassicLinkVPCSecurityGroups,
UserData=base64.b64decode(launch_config.UserData),
InstanceType=launch_config.InstanceType,
BlockDeviceMappings=launch_config.BlockDeviceMappings,
InstanceMonitoring=launch_config.InstanceMonitoring,
SpotPrice=spot_price,
IamInstanceProfile=launch_config.IamInstanceProfile,
EbsOptimized=launch_config.EbsOptimized,
AssociatePublicIpAddress=launch_config.
AssociatePublicIpAddress)
else:
response = self._ac_client.create_launch_configuration(
LaunchConfigurationName=new_lc_name,
ImageId=launch_config.ImageId,
KeyName=launch_config.KeyName,
SecurityGroups=launch_config.SecurityGroups,
ClassicLinkVPCSecurityGroups=launch_config.
ClassicLinkVPCSecurityGroups,
UserData=base64.b64decode(launch_config.UserData),
InstanceType=launch_config.InstanceType,
BlockDeviceMappings=launch_config.BlockDeviceMappings,
InstanceMonitoring=launch_config.InstanceMonitoring,
SpotPrice=spot_price,
IamInstanceProfile=launch_config.IamInstanceProfile,
EbsOptimized=launch_config.EbsOptimized)
assert response is not None, \
"Failed to create launch-config {}".format(new_lc_name)
assert response["HTTPStatusCode"] == 200, \
Expand All @@ -229,21 +245,38 @@ def create_lc_with_spot(self, new_lc_name, launch_config, spot_price):
def create_lc_on_demand(self, new_lc_name, launch_config):
""" Creates a launch-config for using on-demand instances. """
try:
response = self._ac_client.create_launch_configuration(
LaunchConfigurationName=new_lc_name,
ImageId=launch_config.ImageId,
KeyName=launch_config.KeyName,
SecurityGroups=launch_config.SecurityGroups,
ClassicLinkVPCSecurityGroups=launch_config.
ClassicLinkVPCSecurityGroups,
UserData=base64.b64decode(launch_config.UserData),
InstanceType=launch_config.InstanceType,
BlockDeviceMappings=launch_config.BlockDeviceMappings,
InstanceMonitoring=launch_config.InstanceMonitoring,
IamInstanceProfile=launch_config.IamInstanceProfile,
EbsOptimized=launch_config.EbsOptimized,
AssociatePublicIpAddress=launch_config.
AssociatePublicIpAddress)
if hasattr(launch_config, "AssociatePublicIpAddress"):
response = self._ac_client.create_launch_configuration(
LaunchConfigurationName=new_lc_name,
ImageId=launch_config.ImageId,
KeyName=launch_config.KeyName,
SecurityGroups=launch_config.SecurityGroups,
ClassicLinkVPCSecurityGroups=launch_config.
ClassicLinkVPCSecurityGroups,
UserData=base64.b64decode(launch_config.UserData),
InstanceType=launch_config.InstanceType,
BlockDeviceMappings=launch_config.BlockDeviceMappings,
InstanceMonitoring=launch_config.InstanceMonitoring,
SpotPrice=spot_price,
IamInstanceProfile=launch_config.IamInstanceProfile,
EbsOptimized=launch_config.EbsOptimized,
AssociatePublicIpAddress=launch_config.
AssociatePublicIpAddress)
else:
response = self._ac_client.create_launch_configuration(
LaunchConfigurationName=new_lc_name,
ImageId=launch_config.ImageId,
KeyName=launch_config.KeyName,
SecurityGroups=launch_config.SecurityGroups,
ClassicLinkVPCSecurityGroups=launch_config.
ClassicLinkVPCSecurityGroups,
UserData=base64.b64decode(launch_config.UserData),
InstanceType=launch_config.InstanceType,
BlockDeviceMappings=launch_config.BlockDeviceMappings,
InstanceMonitoring=launch_config.InstanceMonitoring,
SpotPrice=spot_price,
IamInstanceProfile=launch_config.IamInstanceProfile,
EbsOptimized=launch_config.EbsOptimized)
assert response is not None, \
"Failed to create launch-config {}".format(new_lc_name)
assert response["HTTPStatusCode"] == 200, \
Expand Down

0 comments on commit e6b83ea

Please sign in to comment.