fixup typos and cleanup code a little
This commit is contained in:
parent
ecf77d64cd
commit
7afd3532c6
@ -733,32 +733,27 @@ class RDS2Backend(BaseBackend):
|
|||||||
database = self.describe_databases(db_instance_identifier)[0]
|
database = self.describe_databases(db_instance_identifier)[0]
|
||||||
return database
|
return database
|
||||||
|
|
||||||
def _check_can_stop_rds_instance_(self, database=None):
|
def stop_database(self, db_instance_identifier, db_snapshot_identifier=None):
|
||||||
|
database = self.describe_databases(db_instance_identifier)[0]
|
||||||
# todo: certain rds types not allowed to be stopped at this time.
|
# todo: certain rds types not allowed to be stopped at this time.
|
||||||
if database:
|
if database.is_replica or database.multi_az:
|
||||||
if database.is_replica or database.multi_az:
|
|
||||||
# should be 400 error
|
# should be 400 error
|
||||||
return RDSClientError('InvalidDBClusterStateFault', 'Invalid DB type, when trying to perform StopDBInstance. See AWS RDS documentation on rds.stop_db_instance')
|
return RDSClientError('InvalidDBClusterStateFault', 'Invalid DB type, when trying to perform StopDBInstance. See AWS RDS documentation on rds.stop_db_instance')
|
||||||
return True
|
|
||||||
|
|
||||||
def stop_database(self, db_instance_identifier, snapshot_name=None):
|
|
||||||
database = self.describe_databases(db_instance_identifier)[0]
|
|
||||||
self._check_can_stop_rds_instance_(database)
|
|
||||||
if database.status != 'available':
|
if database.status != 'available':
|
||||||
return RDSClientError('InvalidDBInstanceState', 'when calling the StopDBInstance operation: Instance testdb is not in available state')
|
return RDSClientError('InvalidDBInstanceState', 'when calling the StopDBInstance operation: Instance %s is not in available state' % db_instance_identifier)
|
||||||
self.create_rds_snapshot(db_instance_identifier, db_instance_identifier)
|
self.create_rds_snapshot(db_instance_identifier, db_snapshot_identifier)
|
||||||
database.status = 'shutdown'
|
database.status = 'shutdown'
|
||||||
return database
|
return database
|
||||||
|
|
||||||
def start_database(self, db_instance_identifier):
|
def start_database(self, db_instance_identifier):
|
||||||
database = self.describe_databases(db_instance_identifier)[0]
|
database = self.describe_databases(db_instance_identifier)[0]
|
||||||
if database.status != 'shutdown':
|
if database.status != 'shutdown': # should be 400 error
|
||||||
# should be 400 error
|
return RDSClientError('InvalidDBInstanceState', 'when calling the StartDBInstance operation: Instance %s is not stopped, it cannot be started.' % db_instance_identifier)
|
||||||
return RDSClientError('InvalidDBInstanceState', 'when calling the StartDBInstance operation: Instance {} is not stopped, it cannot be started.' % db_instance_identifier)
|
|
||||||
database.status = 'available'
|
database.status = 'available'
|
||||||
return
|
return
|
||||||
|
|
||||||
def create_rds_snapshot(self, db_instance_identifier, db_snapshot_identifier):
|
def create_rds_snapshot(self, db_instance_identifier, db_snapshot_identifier):
|
||||||
|
database = self.describe_databases(db_instance_identifier)[0]
|
||||||
# todo
|
# todo
|
||||||
# DBSnapshotAlreadyExists
|
# DBSnapshotAlreadyExists
|
||||||
# SnapshotQuotaExceeded
|
# SnapshotQuotaExceeded
|
||||||
|
Loading…
Reference in New Issue
Block a user