def after(self): def fmt_date(dt): if not dt: return '' return dt.strftime('%Y-%m-%d %H:%M') def fmt_dur(d): if not d: return '' return '%0.1f' % (d / 60.0) s=Storage(self.config['storage_root']) stats=s.get_status() tab=[] for vm in self.result: stat=stats.get(vm) row=self.result[vm] if stat: row.append(fmt_date(stat['last_backup'])) row.append(fmt_dur(stat['duration'])) else: row.extend(['', '']) tab.append(row) for vm in stats: if not self.result.has_key(vm): tab.append(['', vm, '', '', '', fmt_date(stats[vm]['last_backup']), fmt_dur(stats[vm]['duration'])]) print tabulate(tab, ['Host', 'VM', 'State', 'AutoBck', 'AutoBck Batch', 'Last Backup', 'Dur. (m)'])
def test_no_compress(self): test_file_size=os.stat(TEST_FILE).st_size sr=Storage(self.dir, 2,compression_method= None) uid=gen_uuid() rack=sr.get_rack_for('test', uid) slot=rack.create_slot() write_sample_file(slot) res= rack.last_slot self.assertEqual(res._comp_method, None) self.assertEqual(test_file_size, res.size_uncompressed) self.assertEqual(test_file_size , res.size) self.assertTrue(slot._path.endswith('.xva')) self.assertTrue(res._path.endswith('.xva')) self.assertTrue(res.duration) print 'duration',res.duration self.assertTrue(res.created) print 'created', res.created st=sr.get_status() self.assertTrue(st[uid])