def test_reorganize_hash_file(): nbd.init(128) logicService._g = logicService._logic_service() # for i in BitMapIter(iter(bytearray([1, 0, 0, 2, 3, 4, 5]))): # print(i) with open('/tmp/test.bitmap', 'rb') as f: _bit_map = f.read() bit_map = BitMap() bit_map.bitmap = bytearray(_bit_map) snapshots = [{ "path": "/home/mnt/nodes/ffccc08f7d5e40119e0440fd5845259c/images/c152ad459f4c4b39897bf0127c760f66/d3632a55450d4692a5d3021727975edf.qcow", "ident": 'a3a1debbbe6f4c969fb0fe630d111199' }] disk_bytes = 105066964992 hash_name = '/tmp/hash.new' # import os # os.system('echo 3 > /proc/sys/vm/drop_caches;echo 3 > /proc/sys/vm/drop_caches') ReorganizeHashFile(bit_map, snapshots, hash_name, hash_name + '.tmp', disk_bytes).work() MergeHash(disk_bytes).merge(hash_name + '.reg', [hash_name])
else: return True return False def kvm_alive(self): if self.__kvm_running and self.__kvm_running.is_active(): return True else: return False if __name__ == '__main__': import logging _logger.addHandler(logging.StreamHandler()) nbd.init(100) backup_params = dict() backup_params['aio_server_ip'] = '172.29.16.2' backup_params['ip_prefix'] = '172.29.140' backup_params['disksnapshots'] = [{ 'images': [{ 'path': '/home/mnt/nodes/b7f1e05d286d4aad933fd49ff8eeceb9/images/caafc820558645198cf01ef30a27c8cb/f39e736f6abf45ae9f8d8cc36bf2287b.qcow', 'ident': 'e26d469412ef464ea22fcc5f39a00dce' }], 'disk_bytes': 20 * 1024**3, 'nbd_type': 'gznbd' }]
def is_active(self): if self.kvm: return self.kvm.is_active() return False def join(self): return self.kvm.join() @staticmethod def add_monitor(hostname, end_handle): monitor_dict = {'hostname': hostname, 'share_logic': end_handle, 'disklist': []} return managerthread.add_host(monitor_dict) if __name__ == "__main__": nbd.init(128) smb_init() key_info = { 'username': '******', 'hostname': 'W2003R2PAR_1_2018-08-01T20-30-38.350867', 'linux_storage': '', 'userpwd': '843207', 'disklist': [{ 'disksnapshots': [{ 'ident': '49ec3adb58bb4696a6ac3ec865547077', 'path': '/home/mnt/nodes/68067f4b8a3e4eb59b3ae9fc5a851a9f/images/ff5cc0c6541446d685156e4efe34a911/ac5505da0a014ce6b2638a0b9e5e8c6b.qcow' }], 'diskdir': 'disk0', 'diskid': 0 }], 'ostype': 'windows',