OLD | NEW |
1 # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ |
2 # Copyright (c) 2010, Eucalyptus Systems, Inc. | 2 # Copyright (c) 2010, Eucalyptus Systems, Inc. |
3 # | 3 # |
4 # Permission is hereby granted, free of charge, to any person obtaining a | 4 # Permission is hereby granted, free of charge, to any person obtaining a |
5 # copy of this software and associated documentation files (the | 5 # copy of this software and associated documentation files (the |
6 # "Software"), to deal in the Software without restriction, including | 6 # "Software"), to deal in the Software without restriction, including |
7 # without limitation the rights to use, copy, modify, merge, publish, dis- | 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 | 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- | 9 # persons to whom the Software is furnished to do so, subject to the fol- |
10 # lowing conditions: | 10 # lowing conditions: |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 """ | 144 """ |
145 rs = self.connection.get_all_images([self.id]) | 145 rs = self.connection.get_all_images([self.id]) |
146 if len(rs) > 0: | 146 if len(rs) > 0: |
147 img = rs[0] | 147 img = rs[0] |
148 if img.id == self.id: | 148 if img.id == self.id: |
149 self._update(img) | 149 self._update(img) |
150 elif validate: | 150 elif validate: |
151 raise ValueError('%s is not a valid Image ID' % self.id) | 151 raise ValueError('%s is not a valid Image ID' % self.id) |
152 return self.state | 152 return self.state |
153 | 153 |
154 def run(self, min_count=1, max_count=1, key_name=None, | 154 def run(self, min_count=1, max_count=1, key_name=None, |
155 security_groups=None, user_data=None, | 155 security_groups=None, user_data=None, |
156 addressing_type=None, instance_type='m1.small', placement=None, | 156 addressing_type=None, instance_type='m1.small', placement=None, |
157 kernel_id=None, ramdisk_id=None, | 157 kernel_id=None, ramdisk_id=None, |
158 monitoring_enabled=False, subnet_id=None, | 158 monitoring_enabled=False, subnet_id=None, |
159 block_device_map=None, | 159 block_device_map=None, |
160 disable_api_termination=False, | 160 disable_api_termination=False, |
161 instance_initiated_shutdown_behavior=None, | 161 instance_initiated_shutdown_behavior=None, |
162 private_ip_address=None, | 162 private_ip_address=None, |
163 placement_group=None): | 163 placement_group=None, security_group_ids=None): |
164 """ | 164 """ |
165 Runs this instance. | 165 Runs this instance. |
166 | 166 |
167 :type min_count: int | 167 :type min_count: int |
168 :param min_count: The minimum number of instances to start | 168 :param min_count: The minimum number of instances to start |
169 | 169 |
170 :type max_count: int | 170 :type max_count: int |
171 :param max_count: The maximum number of instances to start | 171 :param max_count: The maximum number of instances to start |
172 | 172 |
173 :type key_name: string | 173 :type key_name: string |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 :param block_device_map: A BlockDeviceMapping data structure | 213 :param block_device_map: A BlockDeviceMapping data structure |
214 describing the EBS volumes associated | 214 describing the EBS volumes associated |
215 with the Image. | 215 with the Image. |
216 | 216 |
217 :type disable_api_termination: bool | 217 :type disable_api_termination: bool |
218 :param disable_api_termination: If True, the instances will be locked | 218 :param disable_api_termination: If True, the instances will be locked |
219 and will not be able to be terminated | 219 and will not be able to be terminated |
220 via the API. | 220 via the API. |
221 | 221 |
222 :type instance_initiated_shutdown_behavior: string | 222 :type instance_initiated_shutdown_behavior: string |
223 :param instance_initiated_shutdown_behavior: Specifies whether the insta
nce's | 223 :param instance_initiated_shutdown_behavior: Specifies whether the insta
nce |
224 EBS volumes are stopped (i.
e. detached) | 224 stops or terminates on inst
ance-initiated |
225 or terminated (i.e. deleted
) when | 225 shutdown. Valid values are: |
226 the instance is shutdown by
the | |
227 owner. Valid values are: | |
228 stop | terminate | 226 stop | terminate |
229 | 227 |
230 :type placement_group: string | 228 :type placement_group: string |
231 :param placement_group: If specified, this is the name of the placement | 229 :param placement_group: If specified, this is the name of the placement |
232 group in which the instance(s) will be launched. | 230 group in which the instance(s) will be launched. |
233 | 231 |
234 :rtype: Reservation | 232 :rtype: Reservation |
235 :return: The :class:`boto.ec2.instance.Reservation` associated with the
request for machines | 233 :return: The :class:`boto.ec2.instance.Reservation` associated with the
request for machines |
| 234 |
| 235 :type security_group_ids: |
| 236 :param security_group_ids: |
236 """ | 237 """ |
| 238 |
237 return self.connection.run_instances(self.id, min_count, max_count, | 239 return self.connection.run_instances(self.id, min_count, max_count, |
238 key_name, security_groups, | 240 key_name, security_groups, |
239 user_data, addressing_type, | 241 user_data, addressing_type, |
240 instance_type, placement, | 242 instance_type, placement, |
241 kernel_id, ramdisk_id, | 243 kernel_id, ramdisk_id, |
242 monitoring_enabled, subnet_id, | 244 monitoring_enabled, subnet_id, |
243 block_device_map, disable_api_termi
nation, | 245 block_device_map, disable_api_termi
nation, |
244 instance_initiated_shutdown_behavio
r, | 246 instance_initiated_shutdown_behavio
r, |
245 private_ip_address, | 247 private_ip_address, placement_group
, |
246 placement_group) | 248 security_group_ids=security_group_i
ds) |
247 | 249 |
248 def deregister(self): | 250 def deregister(self, delete_snapshot=False): |
249 return self.connection.deregister_image(self.id) | 251 return self.connection.deregister_image(self.id, delete_snapshot) |
250 | 252 |
251 def get_launch_permissions(self): | 253 def get_launch_permissions(self): |
252 img_attrs = self.connection.get_image_attribute(self.id, | 254 img_attrs = self.connection.get_image_attribute(self.id, |
253 'launchPermission') | 255 'launchPermission') |
254 return img_attrs.attrs | 256 return img_attrs.attrs |
255 | 257 |
256 def set_launch_permissions(self, user_ids=None, group_names=None): | 258 def set_launch_permissions(self, user_ids=None, group_names=None): |
257 return self.connection.modify_image_attribute(self.id, | 259 return self.connection.modify_image_attribute(self.id, |
258 'launchPermission', | 260 'launchPermission', |
259 'add', | 261 'add', |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 else: | 315 else: |
314 self.attrs['product_codes'] = [value] | 316 self.attrs['product_codes'] = [value] |
315 elif name == 'imageId': | 317 elif name == 'imageId': |
316 self.image_id = value | 318 self.image_id = value |
317 elif name == 'kernel': | 319 elif name == 'kernel': |
318 self.kernel = value | 320 self.kernel = value |
319 elif name == 'ramdisk': | 321 elif name == 'ramdisk': |
320 self.ramdisk = value | 322 self.ramdisk = value |
321 else: | 323 else: |
322 setattr(self, name, value) | 324 setattr(self, name, value) |
OLD | NEW |