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

Missing associate public ip address #26

Merged
merged 2 commits into from
Mar 25, 2019
Merged
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
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