def list_vols(): """Helper to return volumes""" conn = ec2_connection.get_connection() volumes = conn.get_all_volumes() return volumes
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)
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
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