We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
LaunchConfiguration does not retrieve AssociatePublicIpAddress properly
Pull request #1799 added support to `AssociatePublicIpAddress`, but it added only support for sending that parameter. Retrieval is not fully supported yet.

A simple fix would be grabbing what pull request #1832 implemented: https://github.com/boto/boto/pull/1832/files#diff-8c9af36969b22e4d4bb34924adc35399R105

My launch configuration object:

```
>>> launch_config.AssociatePublicIpAddress
u'true'

>>> launch_config.__class__
<class 'boto.ec2.autoscale.launchconfig.LaunchConfiguration'>
>>> pprint(dir(launch_config))
['AssociatePublicIpAddress',
 '__class__',
 '__delattr__',
 '__dict__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__module__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 'associate_public_ip_address',
 'block_device_mappings',
 'connection',
 'created_time',
 'delete',
 'delete_on_termination',
 'ebs_optimized',
 'endElement',
 'image_id',
 'instance_monitoring',
 'instance_profile_name',
 'instance_type',
 'iops',
 'kernel_id',
 'key_name',
 'launch_configuration_arn',
 'member',
 'name',
 'ramdisk_id',
 'security_groups',
 'spot_price',
 'startElement',
 'user_data',
 'volume_type']
```

I am using boto version 2.23.0.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `boto/ec2/autoscale/launchconfig.py`
Content:
```
1 # Copyright (c) 2009 Reza Lotun http://reza.lotun.name/
2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates.  All Rights Reserved
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, dis-
8 # tribute, sublicense, and/or sell copies of the Software, and to permit
9 # persons to whom the Software is furnished to do so, subject to the fol-
10 # lowing conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 # IN THE SOFTWARE.
22 
23 from datetime import datetime
24 from boto.resultset import ResultSet
25 from boto.ec2.elb.listelement import ListElement
26 import boto.utils
27 import base64
28 
29 # this should use the corresponding object from boto.ec2
30 
31 
32 class Ebs(object):
33     def __init__(self, connection=None, snapshot_id=None, volume_size=None):
34         self.connection = connection
35         self.snapshot_id = snapshot_id
36         self.volume_size = volume_size
37 
38     def __repr__(self):
39         return 'Ebs(%s, %s)' % (self.snapshot_id, self.volume_size)
40 
41     def startElement(self, name, attrs, connection):
42         pass
43 
44     def endElement(self, name, value, connection):
45         if name == 'SnapshotId':
46             self.snapshot_id = value
47         elif name == 'VolumeSize':
48             self.volume_size = value
49 
50 
51 class InstanceMonitoring(object):
52     def __init__(self, connection=None, enabled='false'):
53         self.connection = connection
54         self.enabled = enabled
55 
56     def __repr__(self):
57         return 'InstanceMonitoring(%s)' % self.enabled
58 
59     def startElement(self, name, attrs, connection):
60         pass
61 
62     def endElement(self, name, value, connection):
63         if name == 'Enabled':
64             self.enabled = value
65 
66 
67 # this should use the BlockDeviceMapping from boto.ec2.blockdevicemapping
68 class BlockDeviceMapping(object):
69     def __init__(self, connection=None, device_name=None, virtual_name=None,
70                  ebs=None, no_device=None):
71         self.connection = connection
72         self.device_name = device_name
73         self.virtual_name = virtual_name
74         self.ebs = ebs
75         self.no_device = no_device
76 
77     def __repr__(self):
78         return 'BlockDeviceMapping(%s, %s)' % (self.device_name,
79                                                self.virtual_name)
80 
81     def startElement(self, name, attrs, connection):
82         if name == 'Ebs':
83             self.ebs = Ebs(self)
84             return self.ebs
85 
86     def endElement(self, name, value, connection):
87         if name == 'DeviceName':
88             self.device_name = value
89         elif name == 'VirtualName':
90             self.virtual_name = value
91         elif name == 'NoDevice':
92             self.no_device = bool(value)
93 
94 
95 class LaunchConfiguration(object):
96     def __init__(self, connection=None, name=None, image_id=None,
97                  key_name=None, security_groups=None, user_data=None,
98                  instance_type='m1.small', kernel_id=None,
99                  ramdisk_id=None, block_device_mappings=None,
100                  instance_monitoring=False, spot_price=None,
101                  instance_profile_name=None, ebs_optimized=False,
102                  associate_public_ip_address=None, volume_type=None,
103                  delete_on_termination=True, iops=None):
104         """
105         A launch configuration.
106 
107         :type name: str
108         :param name: Name of the launch configuration to create.
109 
110         :type image_id: str
111         :param image_id: Unique ID of the Amazon Machine Image (AMI) which was
112             assigned during registration.
113 
114         :type key_name: str
115         :param key_name: The name of the EC2 key pair.
116 
117         :type security_groups: list
118         :param security_groups: Names or security group id's of the security
119             groups with which to associate the EC2 instances or VPC instances,
120             respectively.
121 
122         :type user_data: str
123         :param user_data: The user data available to launched EC2 instances.
124 
125         :type instance_type: str
126         :param instance_type: The instance type
127 
128         :type kern_id: str
129         :param kern_id: Kernel id for instance
130 
131         :type ramdisk_id: str
132         :param ramdisk_id: RAM disk id for instance
133 
134         :type block_device_mappings: list
135         :param block_device_mappings: Specifies how block devices are exposed
136             for instances
137 
138         :type instance_monitoring: bool
139         :param instance_monitoring: Whether instances in group are launched
140             with detailed monitoring.
141 
142         :type spot_price: float
143         :param spot_price: The spot price you are bidding.  Only applies
144             if you are building an autoscaling group with spot instances.
145 
146         :type instance_profile_name: string
147         :param instance_profile_name: The name or the Amazon Resource
148             Name (ARN) of the instance profile associated with the IAM
149             role for the instance.
150 
151         :type ebs_optimized: bool
152         :param ebs_optimized: Specifies whether the instance is optimized
153             for EBS I/O (true) or not (false).
154 
155         :type associate_public_ip_address: bool
156         :param associate_public_ip_address: Used for Auto Scaling groups that launch instances into an Amazon Virtual Private Cloud.
157             Specifies whether to assign a public IP address to each instance launched in a Amazon VPC.
158         """
159         self.connection = connection
160         self.name = name
161         self.instance_type = instance_type
162         self.block_device_mappings = block_device_mappings
163         self.key_name = key_name
164         sec_groups = security_groups or []
165         self.security_groups = ListElement(sec_groups)
166         self.image_id = image_id
167         self.ramdisk_id = ramdisk_id
168         self.created_time = None
169         self.kernel_id = kernel_id
170         self.user_data = user_data
171         self.created_time = None
172         self.instance_monitoring = instance_monitoring
173         self.spot_price = spot_price
174         self.instance_profile_name = instance_profile_name
175         self.launch_configuration_arn = None
176         self.ebs_optimized = ebs_optimized
177         self.associate_public_ip_address = associate_public_ip_address
178         self.volume_type = volume_type
179         self.delete_on_termination = delete_on_termination
180         self.iops = iops
181 
182     def __repr__(self):
183         return 'LaunchConfiguration:%s' % self.name
184 
185     def startElement(self, name, attrs, connection):
186         if name == 'SecurityGroups':
187             return self.security_groups
188         elif name == 'BlockDeviceMappings':
189             self.block_device_mappings = ResultSet([('member',
190                                                      BlockDeviceMapping)])
191             return self.block_device_mappings
192         elif name == 'InstanceMonitoring':
193             self.instance_monitoring = InstanceMonitoring(self)
194             return self.instance_monitoring
195 
196     def endElement(self, name, value, connection):
197         if name == 'InstanceType':
198             self.instance_type = value
199         elif name == 'LaunchConfigurationName':
200             self.name = value
201         elif name == 'KeyName':
202             self.key_name = value
203         elif name == 'ImageId':
204             self.image_id = value
205         elif name == 'CreatedTime':
206             self.created_time = boto.utils.parse_ts(value)
207         elif name == 'KernelId':
208             self.kernel_id = value
209         elif name == 'RamdiskId':
210             self.ramdisk_id = value
211         elif name == 'UserData':
212             try:
213                 self.user_data = base64.b64decode(value)
214             except TypeError:
215                 self.user_data = value
216         elif name == 'LaunchConfigurationARN':
217             self.launch_configuration_arn = value
218         elif name == 'InstanceMonitoring':
219             self.instance_monitoring = value
220         elif name == 'SpotPrice':
221             self.spot_price = float(value)
222         elif name == 'IamInstanceProfile':
223             self.instance_profile_name = value
224         elif name == 'EbsOptimized':
225             self.ebs_optimized = True if value.lower() == 'true' else False
226         elif name == 'VolumeType':
227             self.volume_type = value
228         elif name == 'DeleteOnTermination':
229             if value.lower() == 'true':
230                 self.delete_on_termination = True
231             else:
232                 self.delete_on_termination = False
233         elif name == 'Iops':
234             self.iops = int(value)
235         else:
236             setattr(self, name, value)
237 
238     def delete(self):
239         """ Delete this launch configuration. """
240         return self.connection.delete_launch_configuration(self.name)
241
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/boto/ec2/autoscale/launchconfig.py b/boto/ec2/autoscale/launchconfig.py
--- a/boto/ec2/autoscale/launchconfig.py
+++ b/boto/ec2/autoscale/launchconfig.py
@@ -223,6 +223,8 @@
             self.instance_profile_name = value
         elif name == 'EbsOptimized':
             self.ebs_optimized = True if value.lower() == 'true' else False
+        elif name == 'AssociatePublicIpAddress':
+            self.associate_public_ip_address = True if value.lower() == 'true' else False
         elif name == 'VolumeType':
             self.volume_type = value
         elif name == 'DeleteOnTermination':

{"golden_diff": "diff --git a/boto/ec2/autoscale/launchconfig.py b/boto/ec2/autoscale/launchconfig.py\n--- a/boto/ec2/autoscale/launchconfig.py\n+++ b/boto/ec2/autoscale/launchconfig.py\n@@ -223,6 +223,8 @@\n             self.instance_profile_name = value\n         elif name == 'EbsOptimized':\n             self.ebs_optimized = True if value.lower() == 'true' else False\n+        elif name == 'AssociatePublicIpAddress':\n+            self.associate_public_ip_address = True if value.lower() == 'true' else False\n         elif name == 'VolumeType':\n             self.volume_type = value\n         elif name == 'DeleteOnTermination':\n", "issue": "LaunchConfiguration does not retrieve AssociatePublicIpAddress properly\nPull request #1799 added support to `AssociatePublicIpAddress`, but it added only support for sending that parameter. Retrieval is not fully supported yet.\n\nA simple fix would be grabbing what pull request #1832 implemented: https://github.com/boto/boto/pull/1832/files#diff-8c9af36969b22e4d4bb34924adc35399R105\n\nMy launch configuration object:\n\n```\n>>> launch_config.AssociatePublicIpAddress\nu'true'\n\n>>> launch_config.__class__\n<class 'boto.ec2.autoscale.launchconfig.LaunchConfiguration'>\n>>> pprint(dir(launch_config))\n['AssociatePublicIpAddress',\n '__class__',\n '__delattr__',\n '__dict__',\n '__doc__',\n '__format__',\n '__getattribute__',\n '__hash__',\n '__init__',\n '__module__',\n '__new__',\n '__reduce__',\n '__reduce_ex__',\n '__repr__',\n '__setattr__',\n '__sizeof__',\n '__str__',\n '__subclasshook__',\n '__weakref__',\n 'associate_public_ip_address',\n 'block_device_mappings',\n 'connection',\n 'created_time',\n 'delete',\n 'delete_on_termination',\n 'ebs_optimized',\n 'endElement',\n 'image_id',\n 'instance_monitoring',\n 'instance_profile_name',\n 'instance_type',\n 'iops',\n 'kernel_id',\n 'key_name',\n 'launch_configuration_arn',\n 'member',\n 'name',\n 'ramdisk_id',\n 'security_groups',\n 'spot_price',\n 'startElement',\n 'user_data',\n 'volume_type']\n```\n\nI am using boto version 2.23.0.\n\n", "before_files": [{"content": "# Copyright (c) 2009 Reza Lotun http://reza.lotun.name/\n# Copyright (c) 2012 Amazon.com, Inc. or its affiliates.  All Rights Reserved\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish, dis-\n# tribute, sublicense, and/or sell copies of the Software, and to permit\n# persons to whom the Software is furnished to do so, subject to the fol-\n# lowing conditions:\n#\n# The above copyright notice and this permission notice shall be included\n# in all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-\n# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\n# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n# IN THE SOFTWARE.\n\nfrom datetime import datetime\nfrom boto.resultset import ResultSet\nfrom boto.ec2.elb.listelement import ListElement\nimport boto.utils\nimport base64\n\n# this should use the corresponding object from boto.ec2\n\n\nclass Ebs(object):\n    def __init__(self, connection=None, snapshot_id=None, volume_size=None):\n        self.connection = connection\n        self.snapshot_id = snapshot_id\n        self.volume_size = volume_size\n\n    def __repr__(self):\n        return 'Ebs(%s, %s)' % (self.snapshot_id, self.volume_size)\n\n    def startElement(self, name, attrs, connection):\n        pass\n\n    def endElement(self, name, value, connection):\n        if name == 'SnapshotId':\n            self.snapshot_id = value\n        elif name == 'VolumeSize':\n            self.volume_size = value\n\n\nclass InstanceMonitoring(object):\n    def __init__(self, connection=None, enabled='false'):\n        self.connection = connection\n        self.enabled = enabled\n\n    def __repr__(self):\n        return 'InstanceMonitoring(%s)' % self.enabled\n\n    def startElement(self, name, attrs, connection):\n        pass\n\n    def endElement(self, name, value, connection):\n        if name == 'Enabled':\n            self.enabled = value\n\n\n# this should use the BlockDeviceMapping from boto.ec2.blockdevicemapping\nclass BlockDeviceMapping(object):\n    def __init__(self, connection=None, device_name=None, virtual_name=None,\n                 ebs=None, no_device=None):\n        self.connection = connection\n        self.device_name = device_name\n        self.virtual_name = virtual_name\n        self.ebs = ebs\n        self.no_device = no_device\n\n    def __repr__(self):\n        return 'BlockDeviceMapping(%s, %s)' % (self.device_name,\n                                               self.virtual_name)\n\n    def startElement(self, name, attrs, connection):\n        if name == 'Ebs':\n            self.ebs = Ebs(self)\n            return self.ebs\n\n    def endElement(self, name, value, connection):\n        if name == 'DeviceName':\n            self.device_name = value\n        elif name == 'VirtualName':\n            self.virtual_name = value\n        elif name == 'NoDevice':\n            self.no_device = bool(value)\n\n\nclass LaunchConfiguration(object):\n    def __init__(self, connection=None, name=None, image_id=None,\n                 key_name=None, security_groups=None, user_data=None,\n                 instance_type='m1.small', kernel_id=None,\n                 ramdisk_id=None, block_device_mappings=None,\n                 instance_monitoring=False, spot_price=None,\n                 instance_profile_name=None, ebs_optimized=False,\n                 associate_public_ip_address=None, volume_type=None,\n                 delete_on_termination=True, iops=None):\n        \"\"\"\n        A launch configuration.\n\n        :type name: str\n        :param name: Name of the launch configuration to create.\n\n        :type image_id: str\n        :param image_id: Unique ID of the Amazon Machine Image (AMI) which was\n            assigned during registration.\n\n        :type key_name: str\n        :param key_name: The name of the EC2 key pair.\n\n        :type security_groups: list\n        :param security_groups: Names or security group id's of the security\n            groups with which to associate the EC2 instances or VPC instances,\n            respectively.\n\n        :type user_data: str\n        :param user_data: The user data available to launched EC2 instances.\n\n        :type instance_type: str\n        :param instance_type: The instance type\n\n        :type kern_id: str\n        :param kern_id: Kernel id for instance\n\n        :type ramdisk_id: str\n        :param ramdisk_id: RAM disk id for instance\n\n        :type block_device_mappings: list\n        :param block_device_mappings: Specifies how block devices are exposed\n            for instances\n\n        :type instance_monitoring: bool\n        :param instance_monitoring: Whether instances in group are launched\n            with detailed monitoring.\n\n        :type spot_price: float\n        :param spot_price: The spot price you are bidding.  Only applies\n            if you are building an autoscaling group with spot instances.\n\n        :type instance_profile_name: string\n        :param instance_profile_name: The name or the Amazon Resource\n            Name (ARN) of the instance profile associated with the IAM\n            role for the instance.\n\n        :type ebs_optimized: bool\n        :param ebs_optimized: Specifies whether the instance is optimized\n            for EBS I/O (true) or not (false).\n\n        :type associate_public_ip_address: bool\n        :param associate_public_ip_address: Used for Auto Scaling groups that launch instances into an Amazon Virtual Private Cloud.\n            Specifies whether to assign a public IP address to each instance launched in a Amazon VPC.\n        \"\"\"\n        self.connection = connection\n        self.name = name\n        self.instance_type = instance_type\n        self.block_device_mappings = block_device_mappings\n        self.key_name = key_name\n        sec_groups = security_groups or []\n        self.security_groups = ListElement(sec_groups)\n        self.image_id = image_id\n        self.ramdisk_id = ramdisk_id\n        self.created_time = None\n        self.kernel_id = kernel_id\n        self.user_data = user_data\n        self.created_time = None\n        self.instance_monitoring = instance_monitoring\n        self.spot_price = spot_price\n        self.instance_profile_name = instance_profile_name\n        self.launch_configuration_arn = None\n        self.ebs_optimized = ebs_optimized\n        self.associate_public_ip_address = associate_public_ip_address\n        self.volume_type = volume_type\n        self.delete_on_termination = delete_on_termination\n        self.iops = iops\n\n    def __repr__(self):\n        return 'LaunchConfiguration:%s' % self.name\n\n    def startElement(self, name, attrs, connection):\n        if name == 'SecurityGroups':\n            return self.security_groups\n        elif name == 'BlockDeviceMappings':\n            self.block_device_mappings = ResultSet([('member',\n                                                     BlockDeviceMapping)])\n            return self.block_device_mappings\n        elif name == 'InstanceMonitoring':\n            self.instance_monitoring = InstanceMonitoring(self)\n            return self.instance_monitoring\n\n    def endElement(self, name, value, connection):\n        if name == 'InstanceType':\n            self.instance_type = value\n        elif name == 'LaunchConfigurationName':\n            self.name = value\n        elif name == 'KeyName':\n            self.key_name = value\n        elif name == 'ImageId':\n            self.image_id = value\n        elif name == 'CreatedTime':\n            self.created_time = boto.utils.parse_ts(value)\n        elif name == 'KernelId':\n            self.kernel_id = value\n        elif name == 'RamdiskId':\n            self.ramdisk_id = value\n        elif name == 'UserData':\n            try:\n                self.user_data = base64.b64decode(value)\n            except TypeError:\n                self.user_data = value\n        elif name == 'LaunchConfigurationARN':\n            self.launch_configuration_arn = value\n        elif name == 'InstanceMonitoring':\n            self.instance_monitoring = value\n        elif name == 'SpotPrice':\n            self.spot_price = float(value)\n        elif name == 'IamInstanceProfile':\n            self.instance_profile_name = value\n        elif name == 'EbsOptimized':\n            self.ebs_optimized = True if value.lower() == 'true' else False\n        elif name == 'VolumeType':\n            self.volume_type = value\n        elif name == 'DeleteOnTermination':\n            if value.lower() == 'true':\n                self.delete_on_termination = True\n            else:\n                self.delete_on_termination = False\n        elif name == 'Iops':\n            self.iops = int(value)\n        else:\n            setattr(self, name, value)\n\n    def delete(self):\n        \"\"\" Delete this launch configuration. \"\"\"\n        return self.connection.delete_launch_configuration(self.name)\n", "path": "boto/ec2/autoscale/launchconfig.py"}], "after_files": [{"content": "# Copyright (c) 2009 Reza Lotun http://reza.lotun.name/\n# Copyright (c) 2012 Amazon.com, Inc. or its affiliates.  All Rights Reserved\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish, dis-\n# tribute, sublicense, and/or sell copies of the Software, and to permit\n# persons to whom the Software is furnished to do so, subject to the fol-\n# lowing conditions:\n#\n# The above copyright notice and this permission notice shall be included\n# in all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-\n# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\n# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n# IN THE SOFTWARE.\n\nfrom datetime import datetime\nfrom boto.resultset import ResultSet\nfrom boto.ec2.elb.listelement import ListElement\nimport boto.utils\nimport base64\n\n# this should use the corresponding object from boto.ec2\n\n\nclass Ebs(object):\n    def __init__(self, connection=None, snapshot_id=None, volume_size=None):\n        self.connection = connection\n        self.snapshot_id = snapshot_id\n        self.volume_size = volume_size\n\n    def __repr__(self):\n        return 'Ebs(%s, %s)' % (self.snapshot_id, self.volume_size)\n\n    def startElement(self, name, attrs, connection):\n        pass\n\n    def endElement(self, name, value, connection):\n        if name == 'SnapshotId':\n            self.snapshot_id = value\n        elif name == 'VolumeSize':\n            self.volume_size = value\n\n\nclass InstanceMonitoring(object):\n    def __init__(self, connection=None, enabled='false'):\n        self.connection = connection\n        self.enabled = enabled\n\n    def __repr__(self):\n        return 'InstanceMonitoring(%s)' % self.enabled\n\n    def startElement(self, name, attrs, connection):\n        pass\n\n    def endElement(self, name, value, connection):\n        if name == 'Enabled':\n            self.enabled = value\n\n\n# this should use the BlockDeviceMapping from boto.ec2.blockdevicemapping\nclass BlockDeviceMapping(object):\n    def __init__(self, connection=None, device_name=None, virtual_name=None,\n                 ebs=None, no_device=None):\n        self.connection = connection\n        self.device_name = device_name\n        self.virtual_name = virtual_name\n        self.ebs = ebs\n        self.no_device = no_device\n\n    def __repr__(self):\n        return 'BlockDeviceMapping(%s, %s)' % (self.device_name,\n                                               self.virtual_name)\n\n    def startElement(self, name, attrs, connection):\n        if name == 'Ebs':\n            self.ebs = Ebs(self)\n            return self.ebs\n\n    def endElement(self, name, value, connection):\n        if name == 'DeviceName':\n            self.device_name = value\n        elif name == 'VirtualName':\n            self.virtual_name = value\n        elif name == 'NoDevice':\n            self.no_device = bool(value)\n\n\nclass LaunchConfiguration(object):\n    def __init__(self, connection=None, name=None, image_id=None,\n                 key_name=None, security_groups=None, user_data=None,\n                 instance_type='m1.small', kernel_id=None,\n                 ramdisk_id=None, block_device_mappings=None,\n                 instance_monitoring=False, spot_price=None,\n                 instance_profile_name=None, ebs_optimized=False,\n                 associate_public_ip_address=None, volume_type=None,\n                 delete_on_termination=True, iops=None):\n        \"\"\"\n        A launch configuration.\n\n        :type name: str\n        :param name: Name of the launch configuration to create.\n\n        :type image_id: str\n        :param image_id: Unique ID of the Amazon Machine Image (AMI) which was\n            assigned during registration.\n\n        :type key_name: str\n        :param key_name: The name of the EC2 key pair.\n\n        :type security_groups: list\n        :param security_groups: Names or security group id's of the security\n            groups with which to associate the EC2 instances or VPC instances,\n            respectively.\n\n        :type user_data: str\n        :param user_data: The user data available to launched EC2 instances.\n\n        :type instance_type: str\n        :param instance_type: The instance type\n\n        :type kern_id: str\n        :param kern_id: Kernel id for instance\n\n        :type ramdisk_id: str\n        :param ramdisk_id: RAM disk id for instance\n\n        :type block_device_mappings: list\n        :param block_device_mappings: Specifies how block devices are exposed\n            for instances\n\n        :type instance_monitoring: bool\n        :param instance_monitoring: Whether instances in group are launched\n            with detailed monitoring.\n\n        :type spot_price: float\n        :param spot_price: The spot price you are bidding.  Only applies\n            if you are building an autoscaling group with spot instances.\n\n        :type instance_profile_name: string\n        :param instance_profile_name: The name or the Amazon Resource\n            Name (ARN) of the instance profile associated with the IAM\n            role for the instance.\n\n        :type ebs_optimized: bool\n        :param ebs_optimized: Specifies whether the instance is optimized\n            for EBS I/O (true) or not (false).\n\n        :type associate_public_ip_address: bool\n        :param associate_public_ip_address: Used for Auto Scaling groups that launch instances into an Amazon Virtual Private Cloud.\n            Specifies whether to assign a public IP address to each instance launched in a Amazon VPC.\n        \"\"\"\n        self.connection = connection\n        self.name = name\n        self.instance_type = instance_type\n        self.block_device_mappings = block_device_mappings\n        self.key_name = key_name\n        sec_groups = security_groups or []\n        self.security_groups = ListElement(sec_groups)\n        self.image_id = image_id\n        self.ramdisk_id = ramdisk_id\n        self.created_time = None\n        self.kernel_id = kernel_id\n        self.user_data = user_data\n        self.created_time = None\n        self.instance_monitoring = instance_monitoring\n        self.spot_price = spot_price\n        self.instance_profile_name = instance_profile_name\n        self.launch_configuration_arn = None\n        self.ebs_optimized = ebs_optimized\n        self.associate_public_ip_address = associate_public_ip_address\n        self.volume_type = volume_type\n        self.delete_on_termination = delete_on_termination\n        self.iops = iops\n\n    def __repr__(self):\n        return 'LaunchConfiguration:%s' % self.name\n\n    def startElement(self, name, attrs, connection):\n        if name == 'SecurityGroups':\n            return self.security_groups\n        elif name == 'BlockDeviceMappings':\n            self.block_device_mappings = ResultSet([('member',\n                                                     BlockDeviceMapping)])\n            return self.block_device_mappings\n        elif name == 'InstanceMonitoring':\n            self.instance_monitoring = InstanceMonitoring(self)\n            return self.instance_monitoring\n\n    def endElement(self, name, value, connection):\n        if name == 'InstanceType':\n            self.instance_type = value\n        elif name == 'LaunchConfigurationName':\n            self.name = value\n        elif name == 'KeyName':\n            self.key_name = value\n        elif name == 'ImageId':\n            self.image_id = value\n        elif name == 'CreatedTime':\n            self.created_time = boto.utils.parse_ts(value)\n        elif name == 'KernelId':\n            self.kernel_id = value\n        elif name == 'RamdiskId':\n            self.ramdisk_id = value\n        elif name == 'UserData':\n            try:\n                self.user_data = base64.b64decode(value)\n            except TypeError:\n                self.user_data = value\n        elif name == 'LaunchConfigurationARN':\n            self.launch_configuration_arn = value\n        elif name == 'InstanceMonitoring':\n            self.instance_monitoring = value\n        elif name == 'SpotPrice':\n            self.spot_price = float(value)\n        elif name == 'IamInstanceProfile':\n            self.instance_profile_name = value\n        elif name == 'EbsOptimized':\n            self.ebs_optimized = True if value.lower() == 'true' else False\n        elif name == 'AssociatePublicIpAddress':\n            self.associate_public_ip_address = True if value.lower() == 'true' else False\n        elif name == 'VolumeType':\n            self.volume_type = value\n        elif name == 'DeleteOnTermination':\n            if value.lower() == 'true':\n                self.delete_on_termination = True\n            else:\n                self.delete_on_termination = False\n        elif name == 'Iops':\n            self.iops = int(value)\n        else:\n            setattr(self, name, value)\n\n    def delete(self):\n        \"\"\" Delete this launch configuration. \"\"\"\n        return self.connection.delete_launch_configuration(self.name)\n", "path": "boto/ec2/autoscale/launchconfig.py"}]}