def ferrary_from_domain(self, id_domain, num_domains, start_index=0, dir_to_ferrary_disks=None, prefix=None): if dir_to_ferrary_disks is None: dir_to_ferrary_disks = CONFIG_DICT['FERRARY'][ 'DIR_TO_FERRARY_DISKS'.lower()] if prefix is None: prefix = CONFIG_DICT['FERRARY']['PREFIX'.lower()] ferrary = [] for i in range(start_index, num_domains + start_index): d = dict() d['index'] = str(i).zfill(3) d['id'] = prefix + id_domain + d['index'] d['dict_domain'], d['cmd'] = self.domain_from_template( id_template=id_domain, id_new=d['id'], only_cmds=True, path_to_disk_dir=dir_to_ferrary_disks) ferrary.append(d) cmds = [] cmds.append(ferrary[0]['cmd'][0]) cmds = cmds + list(itertools.chain([d['cmd'][1] for d in ferrary])) before = time.time() cmds_result = exec_remote_list_of_cmds(VDESKTOP_DISK_OPERATINOS, cmds) after = time.time() duration = after - before log.debug( 'FERRARY: {} disks created in {} with name in {} seconds'.format( num_domains, dir_to_ferrary_disks, prefix + id_domain + 'XXX', duration)) for dict_domain_new in [d['dict_domain'] for d in ferrary]: insert_domain(dict_domain_new) return ferrary
def delete_ferrary(self, ferrary): cmds = ['rm -f ' + f['dict_domain']['hardware']['disks'][0]['file'] for f in ferrary] before = time.time() cmds_result = exec_remote_list_of_cmds(VDESKTOP_DISK_OPERATINOS, cmds) after = time.time() duration = after - before ids = [f['id'] for f in ferrary] for id in ids: delete_domain(id) first_disk = ferrary[0]['dict_domain']['hardware']['disks'][0]['file'] last_disk = ferrary[-1]['dict_domain']['hardware']['disks'][0]['file'] log.debug('FERRARY: {} disks deleted from {} to {} in {} seconds'.format(len(cmds), first_disk, last_disk, duration)) return cmds_result
def ferrary_from_domain(self, id_domain, num_domains, start_index=0, dir_to_ferrary_disks=None, prefix=None): if dir_to_ferrary_disks is None: dir_to_ferrary_disks = CONFIG_DICT['FERRARY']['DIR_TO_FERRARY_DISKS'.lower()] if prefix is None: prefix = CONFIG_DICT['FERRARY']['PREFIX'.lower()] ferrary = [] for i in range(start_index, num_domains + start_index): d = dict() d['index'] = str(i).zfill(3) d['id'] = prefix + id_domain + d['index'] d['dict_domain'], d['cmd'] = self.domain_from_template(id_template=id_domain, id_new=d['id'], only_cmds=True, path_to_disk_dir=dir_to_ferrary_disks) ferrary.append(d) cmds = [] cmds.append(ferrary[0]['cmd'][0]) cmds = cmds + list(itertools.chain([d['cmd'][1] for d in ferrary])) before = time.time() cmds_result = exec_remote_list_of_cmds(VDESKTOP_DISK_OPERATINOS, cmds) after = time.time() duration = after - before log.debug('FERRARY: {} disks created in {} with name in {} seconds'.format(num_domains, dir_to_ferrary_disks, prefix + id_domain + 'XXX', duration)) for dict_domain_new in [d['dict_domain'] for d in ferrary]: insert_domain(dict_domain_new) return ferrary