Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: boto/ec2/autoscale/launchconfig.py

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « boto/ec2/autoscale/instance.py ('k') | boto/ec2/autoscale/policy.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009 Reza Lotun http://reza.lotun.name/ 1 # Copyright (c) 2009 Reza Lotun http://reza.lotun.name/
2 # 2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a 3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the 4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis- 6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit 7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol- 8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions: 9 # lowing conditions:
10 # 10 #
11 # The above copyright notice and this permission notice shall be included 11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software. 12 # in all copies or substantial portions of the Software.
13 # 13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE. 20 # IN THE SOFTWARE.
21 21
22 22
23 from boto.ec2.autoscale.request import Request 23 from datetime import datetime
24 import base64
25 from boto.resultset import ResultSet
24 from boto.ec2.elb.listelement import ListElement 26 from boto.ec2.elb.listelement import ListElement
25 27
28 # this should use the corresponding object from boto.ec2
29 class Ebs(object):
30 def __init__(self, connection=None, snapshot_id=None, volume_size=None):
31 self.connection = connection
32 self.snapshot_id = snapshot_id
33 self.volume_size = volume_size
34
35 def __repr__(self):
36 return 'Ebs(%s, %s)' % (self.snapshot_id, self.volume_size)
37
38 def startElement(self, name, attrs, connection):
39 pass
40
41 def endElement(self, name, value, connection):
42 if name == 'SnapshotId':
43 self.snapshot_id = value
44 elif name == 'VolumeSize':
45 self.volume_size = value
46
47
48 class InstanceMonitoring(object):
49 def __init__(self, connection=None, enabled='false'):
50 self.connection = connection
51 self.enabled = enabled
52
53 def __repr__(self):
54 return 'InstanceMonitoring(%s)' % self.enabled
55
56 def startElement(self, name, attrs, connection):
57 pass
58
59 def endElement(self, name, value, connection):
60 if name == 'Enabled':
61 self.enabled = value
62
63
64 # this should use the BlockDeviceMapping from boto.ec2.blockdevicemapping
65 class BlockDeviceMapping(object):
66 def __init__(self, connection=None, device_name=None, virtual_name=None):
67 self.connection = connection
68 self.device_name = None
69 self.virtual_name = None
70 self.ebs = None
71
72 def __repr__(self):
73 return 'BlockDeviceMapping(%s, %s)' % (self.device_name, self.virtual_na me)
74
75 def startElement(self, name, attrs, connection):
76 if name == 'Ebs':
77 self.ebs = Ebs(self)
78 return self.ebs
79
80 def endElement(self, name, value, connection):
81 if name == 'DeviceName':
82 self.device_name = value
83 elif name == 'VirtualName':
84 self.virtual_name = value
85
26 86
27 class LaunchConfiguration(object): 87 class LaunchConfiguration(object):
28 def __init__(self, connection=None, name=None, image_id=None, 88 def __init__(self, connection=None, name=None, image_id=None,
29 key_name=None, security_groups=None, user_data=None, 89 key_name=None, security_groups=None, user_data=None,
30 instance_type='m1.small', kernel_id=None, 90 instance_type='m1.small', kernel_id=None,
31 ramdisk_id=None, block_device_mappings=None): 91 ramdisk_id=None, block_device_mappings=None,
92 instance_monitoring=False):
32 """ 93 """
33 A launch configuration. 94 A launch configuration.
34 95
35 :type name: str 96 :type name: str
36 :param name: Name of the launch configuration to create. 97 :param name: Name of the launch configuration to create.
37 98
38 :type image_id: str 99 :type image_id: str
39 :param image_id: Unique ID of the Amazon Machine Image (AMI) which was 100 :param image_id: Unique ID of the Amazon Machine Image (AMI) which was
40 assigned during registration. 101 assigned during registration.
41 102
42 :type key_name: str 103 :type key_name: str
43 :param key_name: The name of the EC2 key pair. 104 :param key_name: The name of the EC2 key pair.
44 105
45 :type security_groups: list 106 :type security_groups: list
46 :param security_groups: Names of the security groups with which to 107 :param security_groups: Names of the security groups with which to
47 associate the EC2 instances. 108 associate the EC2 instances.
48 109
110 :type user_data: str
111 :param user_data: The user data available to launched EC2 instances.
112
113 :type instance_type: str
114 :param instance_type: The instance type
115
116 :type kern_id: str
117 :param kern_id: Kernel id for instance
118
119 :type ramdisk_id: str
120 :param ramdisk_id: RAM disk id for instance
121
122 :type block_device_mappings: list
123 :param block_device_mappings: Specifies how block devices are exposed
124 for instances
125
126 :type instance_monitoring: bool
127 :param instance_monitoring: Whether instances in group are launched
128 with detailed monitoring.
49 """ 129 """
50 self.connection = connection 130 self.connection = connection
51 self.name = name 131 self.name = name
52 self.instance_type = instance_type 132 self.instance_type = instance_type
53 self.block_device_mappings = block_device_mappings 133 self.block_device_mappings = block_device_mappings
54 self.key_name = key_name 134 self.key_name = key_name
55 sec_groups = security_groups or [] 135 sec_groups = security_groups or []
56 self.security_groups = ListElement(sec_groups) 136 self.security_groups = ListElement(sec_groups)
57 self.image_id = image_id 137 self.image_id = image_id
58 self.ramdisk_id = ramdisk_id 138 self.ramdisk_id = ramdisk_id
59 self.created_time = None 139 self.created_time = None
60 self.kernel_id = kernel_id 140 self.kernel_id = kernel_id
61 self.user_data = user_data 141 self.user_data = user_data
62 self.created_time = None 142 self.created_time = None
143 self.instance_monitoring = instance_monitoring
144 self.launch_configuration_arn = None
63 145
64 def __repr__(self): 146 def __repr__(self):
65 return 'LaunchConfiguration:%s' % self.name 147 return 'LaunchConfiguration:%s' % self.name
66 148
67 def startElement(self, name, attrs, connection): 149 def startElement(self, name, attrs, connection):
68 if name == 'SecurityGroups': 150 if name == 'SecurityGroups':
69 return self.security_groups 151 return self.security_groups
70 else: 152 elif name == 'BlockDeviceMappings':
71 return 153 self.block_device_mappings = ResultSet([('member', BlockDeviceMappin g)])
154 return self.block_device_mappings
155 elif name == 'InstanceMonitoring':
156 self.instance_monitoring = InstanceMonitoring(self)
157 return self.instance_monitoring
72 158
73 def endElement(self, name, value, connection): 159 def endElement(self, name, value, connection):
74 if name == 'InstanceType': 160 if name == 'InstanceType':
75 self.instance_type = value 161 self.instance_type = value
76 elif name == 'LaunchConfigurationName': 162 elif name == 'LaunchConfigurationName':
77 self.name = value 163 self.name = value
78 elif name == 'KeyName': 164 elif name == 'KeyName':
79 self.key_name = value 165 self.key_name = value
80 elif name == 'ImageId': 166 elif name == 'ImageId':
81 self.image_id = value 167 self.image_id = value
82 elif name == 'CreatedTime': 168 elif name == 'CreatedTime':
83 self.created_time = value 169 try:
170 self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S. %fZ')
171 except ValueError:
172 self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ ')
84 elif name == 'KernelId': 173 elif name == 'KernelId':
85 self.kernel_id = value 174 self.kernel_id = value
86 elif name == 'RamdiskId': 175 elif name == 'RamdiskId':
87 self.ramdisk_id = value 176 self.ramdisk_id = value
88 elif name == 'UserData': 177 elif name == 'UserData':
89 self.user_data = value 178 self.user_data = base64.b64decode(value)
179 elif name == 'LaunchConfigurationARN':
180 self.launch_configuration_arn = value
181 elif name == 'InstanceMonitoring':
182 self.instance_monitoring = value
90 else: 183 else:
91 setattr(self, name, value) 184 setattr(self, name, value)
92 185
93 def delete(self): 186 def delete(self):
94 """ Delete this launch configuration. """ 187 """ Delete this launch configuration. """
95 params = {'LaunchConfigurationName' : self.name} 188 return self.connection.delete_launch_configuration(self.name)
96 return self.connection.get_object('DeleteLaunchConfiguration', params,
97 Request)
98 189
OLDNEW
« no previous file with comments | « boto/ec2/autoscale/instance.py ('k') | boto/ec2/autoscale/policy.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698