#!/usr/bin/env python

from credentials import *
from novabackup import nova_client, utc_to_local

if __name__ == '__main__':
    nc = nova_client()

    nc_images_list = nc.images.list()

    for vm in nc.servers.findall():
        backup_name = 'CVL_BACKUP_' + vm.name
        # print backup_name
        images = sorted([(utc_to_local(i.updated), i.id) for i in nc_images_list if i.name == backup_name and hasattr(i, 'server') and i.server['id'] == vm.id])

        if images == []:
            print 'NONE', vm.name
        else:
            print images[-1][0].strftime('%Y-%m-%d %H:%M:%S'), images[-1][1], vm.name
示例#2
0
from novabackup import BackupVM
from novabackup import nova_client
import sys
import time

DAY_START = 4
DAY_END = 10

if time.localtime().tm_hour in range(DAY_START, DAY_END + 1):
    print "Error: not starting backups, current time is between %.2d and %.2d hours" % (DAY_START, DAY_END)
    sys.exit(1)

for vm in nova_client().servers.list():
    job = BackupVM.apply_async(args=[vm.name], kwargs={}, queue="novabackup")
    print job, vm.name