Example #1
0
def get_stats():
    """Helper for listing autosnap stats"""

    conf = get_config.get_configuration('../.config')
    conn = ec2_connection.get_connection()

    # Volumes
    volumes = conn.get_all_volumes()

    vol_count = 0

    for volume in volumes:
        vol_count = vol_count + 1

    # Snapshots
    owner_id = conf.get('owner_id')
    snapshots = conn.get_all_snapshots(filters={'owner-id': owner_id})

    snap_count = 0

    for snap in snapshots:
        snap_count = snap_count + 1

    # Region
    region = conf.get('region')

    print 'Autosnap stats\n'
    print 'Current region:    ' + '%15s' % (region)
    print 'Volumes managed:   ' + '%15s' % str(vol_count)
    print 'Snapshots managed: ' + '%15s' % str(snap_count)
Example #2
0
def get_stats():
    """Helper for listing autosnap stats"""

    conf = get_config.get_configuration('../.config')
    conn = ec2_connection.get_connection()

    # Volumes
    volumes = conn.get_all_volumes()

    vol_count = 0

    for volume in volumes:
        vol_count = vol_count + 1

    # Snapshots
    owner_id = conf.get('owner_id')
    snapshots = conn.get_all_snapshots(filters={'owner-id': owner_id})

    snap_count = 0

    for snap in snapshots:
        snap_count = snap_count + 1

    # Region
    region = conf.get('region')

    print 'Autosnap stats\n'
    print 'Current region:    ' + '%15s' % (region)
    print 'Volumes managed:   ' + '%15s' % str(vol_count)
    print 'Snapshots managed: ' + '%15s' % str(snap_count)
Example #3
0
def get_snapshots():
    """List all snapshots"""

    # List only owner snapshots
    conf = get_config.get_configuration('../.config')
    owner_id = conf.get('owner_id')

    conn = ec2_connection.get_connection()
    snapshots = conn.get_all_snapshots(filters={'owner-id': owner_id})

    return snapshots
Example #4
0
def get_snapshots():
    """List all snapshots"""

    # List only owner snapshots
    conf = get_config.get_configuration('../.config')
    owner_id = conf.get('owner_id')

    conn = ec2_connection.get_connection()
    snapshots = conn.get_all_snapshots(filters={'owner-id': owner_id})

    return snapshots
Example #5
0
def print_snapshots():
    """Print all snapshots"""

    # List only owner snapshots
    conf = get_config.get_configuration('../.config')
    owner_id = conf.get('owner_id')

    conn = ec2_connection.get_connection()
    snapshots = conn.get_all_snapshots(filters={'owner-id': owner_id})

    for snap in snapshots:
        print snap.tags

    return
Example #6
0
def print_snapshots():
    """Print all snapshots"""

    # List only owner snapshots
    conf = get_config.get_configuration('../.config')
    owner_id = conf.get('owner_id')

    conn = ec2_connection.get_connection()
    snapshots = conn.get_all_snapshots(filters={'owner-id': owner_id})

    for snap in snapshots:
        print snap.tags

    return
Example #7
0
def get_connection():
    """ Connect to AWS """

    # Read config
    config = '../.config'
    config = get_config.get_configuration(config)
    #logger.info('Connecting to AWS EC2 in {}'.format(config.get('region'))

    # Connect using supplied credentials
    conn = boto.ec2.connect_to_region(config.get('region'),
        aws_access_key_id=config.get('aws_access_key_id'),
        aws_secret_access_key=config.get('aws_secret_access_key'))

    if not conn:
        logger.error('An error occurred when connecting to EC2')
        sys.exit(1)

    return conn
Example #8
0
def get_connection():
    """ Connect to AWS """

    # Read config
    config = '../.config'
    config = get_config.get_configuration(config)
    #logger.info('Connecting to AWS EC2 in {}'.format(config.get('region'))

    # Connect using supplied credentials
    conn = boto.ec2.connect_to_region(
        config.get('region'),
        aws_access_key_id=config.get('aws_access_key_id'),
        aws_secret_access_key=config.get('aws_secret_access_key'))

    if not conn:
        logger.error('An error occurred when connecting to EC2')
        sys.exit(1)

    return conn