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

Side by Side Diff: third_party/gsutil/boto/ec2/networkinterface.py

Issue 12042069: Scripts to download files from google storage based on sha1 sums (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Removed gsutil/tests and gsutil/docs Created 7 years, 10 months 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
OLDNEW
(Empty)
1 # Copyright (c) 2011 Mitch Garnaat http://garnaat.org/
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including
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
8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions:
10 #
11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software.
13 #
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-
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,
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
20 # IN THE SOFTWARE.
21
22 """
23 Represents an EC2 Elastic Network Interface
24 """
25 from boto.ec2.ec2object import TaggedEC2Object
26 from boto.resultset import ResultSet
27 from boto.ec2.group import Group
28
29 class Attachment(object):
30 """
31 :ivar id: The ID of the attachment.
32 :ivar instance_id: The ID of the instance.
33 :ivar device_index: The index of this device.
34 :ivar status: The status of the device.
35 :ivar attach_time: The time the device was attached.
36 :ivar delete_on_termination: Whether the device will be deleted
37 when the instance is terminated.
38 """
39
40 def __init__(self):
41 self.id = None
42 self.instance_id = None
43 self.instance_owner_id = None
44 self.device_index = 0
45 self.status = None
46 self.attach_time = None
47 self.delete_on_termination = False
48
49 def __repr__(self):
50 return 'Attachment:%s' % self.id
51
52 def startElement(self, name, attrs, connection):
53 return None
54
55 def endElement(self, name, value, connection):
56 if name == 'attachmentId':
57 self.id = value
58 elif name == 'instanceId':
59 self.instance_id = value
60 elif name == 'instanceOwnerId':
61 self.instance_owner_id = value
62 elif name == 'status':
63 self.status = value
64 elif name == 'attachTime':
65 self.attach_time = value
66 elif name == 'deleteOnTermination':
67 if value.lower() == 'true':
68 self.delete_on_termination = True
69 else:
70 self.delete_on_termination = False
71 else:
72 setattr(self, name, value)
73
74 class NetworkInterface(TaggedEC2Object):
75 """
76 An Elastic Network Interface.
77
78 :ivar id: The ID of the ENI.
79 :ivar subnet_id: The ID of the VPC subnet.
80 :ivar vpc_id: The ID of the VPC.
81 :ivar description: The description.
82 :ivar owner_id: The ID of the owner of the ENI.
83 :ivar requester_managed:
84 :ivar status: The interface's status (available|in-use).
85 :ivar mac_address: The MAC address of the interface.
86 :ivar private_ip_address: The IP address of the interface within
87 the subnet.
88 :ivar source_dest_check: Flag to indicate whether to validate
89 network traffic to or from this network interface.
90 :ivar groups: List of security groups associated with the interface.
91 :ivar attachment: The attachment object.
92 """
93
94 def __init__(self, connection=None):
95 TaggedEC2Object.__init__(self, connection)
96 self.id = None
97 self.subnet_id = None
98 self.vpc_id = None
99 self.availability_zone = None
100 self.description = None
101 self.owner_id = None
102 self.requester_managed = False
103 self.status = None
104 self.mac_address = None
105 self.private_ip_address = None
106 self.source_dest_check = None
107 self.groups = []
108 self.attachment = None
109
110 def __repr__(self):
111 return 'NetworkInterface:%s' % self.id
112
113 def startElement(self, name, attrs, connection):
114 retval = TaggedEC2Object.startElement(self, name, attrs, connection)
115 if retval is not None:
116 return retval
117 if name == 'groupSet':
118 self.groups = ResultSet([('item', Group)])
119 return self.groups
120 elif name == 'attachment':
121 self.attachment = Attachment()
122 return self.attachment
123 else:
124 return None
125
126 def endElement(self, name, value, connection):
127 if name == 'networkInterfaceId':
128 self.id = value
129 elif name == 'subnetId':
130 self.subnet_id = value
131 elif name == 'vpcId':
132 self.vpc_id = value
133 elif name == 'availabilityZone':
134 self.availability_zone = value
135 elif name == 'description':
136 self.description = value
137 elif name == 'ownerId':
138 self.owner_id = value
139 elif name == 'requesterManaged':
140 if value.lower() == 'true':
141 self.requester_managed = True
142 else:
143 self.requester_managed = False
144 elif name == 'status':
145 self.status = value
146 elif name == 'macAddress':
147 self.mac_address = value
148 elif name == 'privateIpAddress':
149 self.private_ip_address = value
150 elif name == 'sourceDestCheck':
151 if value.lower() == 'true':
152 self.source_dest_check = True
153 else:
154 self.source_dest_check = False
155 else:
156 setattr(self, name, value)
157
158 def delete(self):
159 return self.connection.delete_network_interface(self.id)
160
161
162
163
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698