| OLD | NEW |
| (Empty) | |
| 1 # Copyright (c) 2006-2009 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 class DBSnapshot(object): |
| 23 """ |
| 24 Represents a RDS DB Snapshot |
| 25 |
| 26 Properties reference available from the AWS documentation at http://docs.ama
zonwebservices.com/AmazonRDS/latest/APIReference/API_DBSnapshot.html |
| 27 |
| 28 :ivar EngineVersion: Specifies the version of the database engine |
| 29 :ivar LicenseModel: License model information for the restored DB instance |
| 30 :ivar allocated_storage: Specifies the allocated storage size in gigabytes (
GB) |
| 31 :ivar availability_zone: Specifies the name of the Availability Zone the DB
Instance was located in at the time of the DB Snapshot |
| 32 :ivar connection: boto.rds.RDSConnection associated with the current object |
| 33 :ivar engine: Specifies the name of the database engine |
| 34 :ivar id: Specifies the identifier for the DB Snapshot (DBSnapshotIdentifier
) |
| 35 :ivar instance_create_time: Specifies the time (UTC) when the snapshot was t
aken |
| 36 :ivar instance_id: Specifies the the DBInstanceIdentifier of the DB Instance
this DB Snapshot was created from (DBInstanceIdentifier) |
| 37 :ivar master_username: Provides the master username for the DB Instance |
| 38 :ivar port: Specifies the port that the database engine was listening on at
the time of the snapshot |
| 39 :ivar snapshot_create_time: Provides the time (UTC) when the snapshot was ta
ken |
| 40 :ivar status: Specifies the status of this DB Snapshot. Possible values are
[ available, backing-up, creating, deleted, deleting, failed, modifying, rebooti
ng, resetting-master-credentials ] |
| 41 """ |
| 42 |
| 43 def __init__(self, connection=None, id=None): |
| 44 self.connection = connection |
| 45 self.id = id |
| 46 self.engine = None |
| 47 self.snapshot_create_time = None |
| 48 self.instance_create_time = None |
| 49 self.port = None |
| 50 self.status = None |
| 51 self.availability_zone = None |
| 52 self.master_username = None |
| 53 self.allocated_storage = None |
| 54 self.instance_id = None |
| 55 self.availability_zone = None |
| 56 |
| 57 def __repr__(self): |
| 58 return 'DBSnapshot:%s' % self.id |
| 59 |
| 60 def startElement(self, name, attrs, connection): |
| 61 pass |
| 62 |
| 63 def endElement(self, name, value, connection): |
| 64 if name == 'Engine': |
| 65 self.engine = value |
| 66 elif name == 'InstanceCreateTime': |
| 67 self.instance_create_time = value |
| 68 elif name == 'SnapshotCreateTime': |
| 69 self.snapshot_create_time = value |
| 70 elif name == 'DBInstanceIdentifier': |
| 71 self.instance_id = value |
| 72 elif name == 'DBSnapshotIdentifier': |
| 73 self.id = value |
| 74 elif name == 'Port': |
| 75 self.port = int(value) |
| 76 elif name == 'Status': |
| 77 self.status = value |
| 78 elif name == 'AvailabilityZone': |
| 79 self.availability_zone = value |
| 80 elif name == 'MasterUsername': |
| 81 self.master_username = value |
| 82 elif name == 'AllocatedStorage': |
| 83 self.allocated_storage = int(value) |
| 84 elif name == 'SnapshotTime': |
| 85 self.time = value |
| 86 else: |
| 87 setattr(self, name, value) |
| 88 |
| 89 def update(self, validate=False): |
| 90 """ |
| 91 Update the DB snapshot's status information by making a call to fetch |
| 92 the current snapshot attributes from the service. |
| 93 |
| 94 :type validate: bool |
| 95 :param validate: By default, if EC2 returns no data about the |
| 96 instance the update method returns quietly. If |
| 97 the validate param is True, however, it will |
| 98 raise a ValueError exception if no data is |
| 99 returned from EC2. |
| 100 """ |
| 101 rs = self.connection.get_all_dbsnapshots(self.id) |
| 102 if len(rs) > 0: |
| 103 for i in rs: |
| 104 if i.id == self.id: |
| 105 self.__dict__.update(i.__dict__) |
| 106 elif validate: |
| 107 raise ValueError('%s is not a valid Snapshot ID' % self.id) |
| 108 return self.status |
| OLD | NEW |