Ejemplo n.º 1
0
def teardown_rds():
    logging.warn('Removing RDS instance')
    conn = RDSConnection()
    
    try:
        db_inst = conn.get_all_dbinstances(instance_id=DB_NAME)[0]
    except:
        logging.debug('There was no RDS instance with name %s' % DB_NAME)
        return
    
    conn.delete_dbinstance(db_inst.id, skip_final_snapshot=True)

    while True:
        try:
            conn.get_all_dbinstances(instance_id=DB_NAME)[0]
        except:
            break
        else:
            time.sleep(30)
            logging.debug('Waiting...') 
    
    try:
        conn.delete_dbsecurity_group(SG_NAME)
    except:
        logging.debug('No DB security group %s to delete' % SG_NAME)
Ejemplo n.º 2
0
def spawn_rds():
    logging.info('Spawning a new RDS instance, this takes at least 10min!')
    conn = RDSConnection()
    
    db = conn.create_dbinstance(DB_NAME, 5, 'db.m1.small', DB_USER, DB_PASSWORD)
    
    while True:
        try:
            db = conn.get_all_dbinstances(instance_id=DB_NAME)[0]
        except Exception, e:
            logging.debug('Unexpected exception "%s"' % e)
        else:
            if db.endpoint is not None and db.status == 'available':
                break

        time.sleep(45)
        logging.debug('Waiting...')