コード例 #1
0
ファイル: verify_inventory.py プロジェクト: nanotone/jokull
def verify_inventory(job_output, index):
    vaultname = job_output['VaultARN'].split('/')[-1]
    inventory_time = util.parse_8601(job_output['InventoryDate'])
    local_hash = {a['archive_id']: a for a in index[vaultname]}
    remote_hash = {a['ArchiveId']: a for a in job_output['ArchiveList']}
    for rec in local_hash.itervalues():
        if rec['end'] + 25200 > inventory_time:  # give it 7 hours or so?
            print "Skipping archive %s (completed %.1f hours ago)" % (rec['archive_id'], util.hours_ago(rec['end']))
            continue
        remote_rec = remote_hash.get(rec['archive_id'])
        assert remote_rec, "Index record %r is missing from inventory" % rec
        assert rec['size'] == remote_rec['Size'], "Index record %r differs in size from inventory record %r" % (rec, remote_rec)
        assert -300 < rec['end'] - util.parse_8601(remote_rec['CreationDate']) < 300, "Index record %r differs in timestamp from inventory record %r" % (rec, remote_rec)
    for remote_id in remote_hash:
        assert remote_id in local_hash, "Inventory record %r is missing from index!" % remote_hash[remote_id]
    print "OK"
コード例 #2
0
ファイル: jokull.py プロジェクト: nanotone/jokull
 def get_last_inventory_job(self):
     jobs = sorted((j for j in self.vault.list_jobs(completed=True) if j.action == 'InventoryRetrieval'),
                   key=lambda j: j.completion_date)
     if not jobs:
         raise IndexError("There are no completed jobs for inventory retrieval")
     job = jobs[-1]
     print "Using inventory job completed at %s (%.1f hours ago)" % (job.completion_date, util.hours_ago(job.completion_date))
     return job