diff options
author | Daniel G. Taylor <danielgtaylor@gmail.com> | 2014-09-22 10:46:00 -0700 |
---|---|---|
committer | Daniel G. Taylor <danielgtaylor@gmail.com> | 2014-09-22 10:46:00 -0700 |
commit | fb4aeec5ef11142c4a0550056b989bf655282adf (patch) | |
tree | 97cef1a3508ce259bd3ce26f95970a6011259533 | |
parent | 1de6b41201fff9031dad0f189d9d291e00895461 (diff) | |
parent | 523cf41bc9e8b167856d1949fd32dd83b1b49ab4 (diff) | |
download | boto-fb4aeec5ef11142c4a0550056b989bf655282adf.tar.gz |
Merge branch 'nishigori-b64encode-launch-config-user-data' into develop
Fix an error in Python 3 when creating launch configs. Enables AutoScaling
unit tests to run by default. Fixes #2591.
-rw-r--r-- | boto/ec2/autoscale/__init__.py | 5 | ||||
-rw-r--r--[-rwxr-xr-x] | tests/unit/ec2/autoscale/test_group.py | 10 |
2 files changed, 6 insertions, 9 deletions
diff --git a/boto/ec2/autoscale/__init__.py b/boto/ec2/autoscale/__init__.py index 96c42848..5a58748d 100644 --- a/boto/ec2/autoscale/__init__.py +++ b/boto/ec2/autoscale/__init__.py @@ -222,7 +222,10 @@ class AutoScaleConnection(AWSQueryConnection): if launch_config.key_name: params['KeyName'] = launch_config.key_name if launch_config.user_data: - params['UserData'] = base64.b64encode(launch_config.user_data).decode('utf-8') + user_data = launch_config.user_data + if isinstance(user_data, six.text_type): + user_data = user_data.encode('utf-8') + params['UserData'] = base64.b64encode(user_data).decode('utf-8') if launch_config.kernel_id: params['KernelId'] = launch_config.kernel_id if launch_config.ramdisk_id: diff --git a/tests/unit/ec2/autoscale/test_group.py b/tests/unit/ec2/autoscale/test_group.py index 19e2c7ca..5c5b4dcd 100755..100644 --- a/tests/unit/ec2/autoscale/test_group.py +++ b/tests/unit/ec2/autoscale/test_group.py @@ -351,11 +351,9 @@ class TestLaunchConfiguration(AWSMockServiceTestCase): # This unit test is based on #753 and #1343 self.set_http_response(status_code=200) dev_sdf = EBSBlockDeviceType(snapshot_id='snap-12345') - dev_sdg = EBSBlockDeviceType(snapshot_id='snap-12346') bdm = BlockDeviceMapping() bdm['/dev/sdf'] = dev_sdf - bdm['/dev/sdg'] = dev_sdg lc = launchconfig.LaunchConfiguration( connection=self.service_connection, @@ -363,7 +361,7 @@ class TestLaunchConfiguration(AWSMockServiceTestCase): image_id='123456', instance_type='m1.large', user_data='#!/bin/bash', - security_groups=['group1', 'group2'], + security_groups=['group1'], spot_price='price', block_device_mappings=[bdm], associate_public_ip_address=True, @@ -379,17 +377,13 @@ class TestLaunchConfiguration(AWSMockServiceTestCase): 'BlockDeviceMappings.member.1.DeviceName': '/dev/sdf', 'BlockDeviceMappings.member.1.Ebs.DeleteOnTermination': 'false', 'BlockDeviceMappings.member.1.Ebs.SnapshotId': 'snap-12345', - 'BlockDeviceMappings.member.2.DeviceName': '/dev/sdg', - 'BlockDeviceMappings.member.2.Ebs.DeleteOnTermination': 'false', - 'BlockDeviceMappings.member.2.Ebs.SnapshotId': 'snap-12346', 'EbsOptimized': 'false', 'LaunchConfigurationName': 'launch_config', 'ImageId': '123456', - 'UserData': base64.b64encode('#!/bin/bash').decode('utf-8'), + 'UserData': base64.b64encode(b'#!/bin/bash').decode('utf-8'), 'InstanceMonitoring.Enabled': 'false', 'InstanceType': 'm1.large', 'SecurityGroups.member.1': 'group1', - 'SecurityGroups.member.2': 'group2', 'SpotPrice': 'price', 'AssociatePublicIpAddress': 'true', 'VolumeType': 'atype', |