예제 #1
0
 def test_delete_verified_database(self):
     session = mock.MagicMock()
     session.list_tags_for_resource.return_value = {
         "TagList": [{"Key": SAFETY_TAG_KEY, "Value": SAFETY_TAG_VAL}]
     }
     database = Database(
         session=session, description=self.db_instance_desc_1["DBInstances"][0]
     )
     database.session = session
     delete_verified_database(database)
예제 #2
0
 def test_delete_verified_database_incorrect_safety_tag_value(self):
     session = mock.MagicMock()
     session.list_tags_for_resource.return_value = {
         "TagList": [{"Key": SAFETY_TAG_KEY, "Value": "1"}]
     }
     database = Database(
         session=session, description=self.db_instance_desc_1["DBInstances"][0]
     )
     database.session = session
     with self.assertRaises(Exception):
         delete_verified_database(database)
예제 #3
0
def cleanup(state_doc, rds_session):
    """clean: currently tearing down the temporary RDS db instance
    and anything else we created or modified."""
    tmp_database = Database(session=rds_session, identifier=state_doc.tmp_database)
    if not tmp_database:
        # cleanup of db subnet group, tmp_password, and transition to wait.
        logger.info("cleaning %s subnet group and tmp_password", state_doc.tmp_database)
        destroy_database_subnet_group(rds_session, state_doc.tmp_database)
        # remove tmp_password, clear old states.
        state_doc.clean()
        logger.info(dbsnap_verify_datadog_output(state_doc, "OK"))
        # wait for next snapshot (which could appear tomorrow).
        state_doc.transition_state("wait")
    elif tmp_database.status == "available":
        logger.info("cleaning / destroying %s", state_doc.tmp_database)
        delete_verified_database(tmp_database)
    else:
        logger.info("still cleaning / destroying %s", state_doc.tmp_database)