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

Unified Diff: third_party/boto/boto/ec2/networkinterface.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/boto/boto/ec2/instancetype.py ('k') | third_party/boto/boto/ec2/regioninfo.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/boto/boto/ec2/networkinterface.py
===================================================================
--- third_party/boto/boto/ec2/networkinterface.py (revision 33376)
+++ third_party/boto/boto/ec2/networkinterface.py (working copy)
@@ -167,6 +167,70 @@
else:
setattr(self, name, value)
+ def _update(self, updated):
+ self.__dict__.update(updated.__dict__)
+
+ def update(self, validate=False, dry_run=False):
+ """
+ Update the data associated with this ENI by querying EC2.
+
+ :type validate: bool
+ :param validate: By default, if EC2 returns no data about the
+ ENI the update method returns quietly. If
+ the validate param is True, however, it will
+ raise a ValueError exception if no data is
+ returned from EC2.
+ """
+ rs = self.connection.get_all_network_interfaces(
+ [self.id],
+ dry_run=dry_run
+ )
+ if len(rs) > 0:
+ self._update(rs[0])
+ elif validate:
+ raise ValueError('%s is not a valid ENI ID' % self.id)
+ return self.status
+
+ def attach(self, instance_id, device_index, dry_run=False):
+ """
+ Attach this ENI to an EC2 instance.
+
+ :type instance_id: str
+ :param instance_id: The ID of the EC2 instance to which it will
+ be attached.
+
+ :type device_index: int
+ :param device_index: The interface nunber, N, on the instance (eg. ethN)
+
+ :rtype: bool
+ :return: True if successful
+ """
+ return self.connection.attach_network_interface(
+ self.id,
+ instance_id,
+ device_index,
+ dry_run=dry_run
+ )
+
+ def detach(self, force=False, dry_run=False):
+ """
+ Detach this ENI from an EC2 instance.
+
+ :type force: bool
+ :param force: Forces detachment if the previous detachment
+ attempt did not occur cleanly.
+
+ :rtype: bool
+ :return: True if successful
+ """
+ attachment_id = getattr(self.attachment, 'id', None)
+
+ return self.connection.detach_network_interface(
+ attachment_id,
+ force,
+ dry_run=dry_run
+ )
+
def delete(self, dry_run=False):
return self.connection.delete_network_interface(
self.id,
« no previous file with comments | « third_party/boto/boto/ec2/instancetype.py ('k') | third_party/boto/boto/ec2/regioninfo.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698