def dump_actions(self): """ This method writes all actions on the current step to database """ data_storage.put(self.key, json.dumps(self.data)) self.new_step() self.iteration += 1
def make(filter_folder, images_date): delete_relations() check_filter_folder(filter_folder) LOG.info("started creating filter files and all needed resources") cursor = 0 while True: step = data_storage.get("%s_source" % cursor) if step is None: break cursor += 1 ids = [] for migrate in json.loads(step)['migrate']: vm_id = migrate[0] ids.append(vm_id) data_storage.put(MIGRATE_VM_PREFIX + vm_id, migrate[1]) vm_filter = {'images': {'date': images_date}, 'instances': {'id': ids}} with file("%s/filter_%s.yaml" % (filter_folder, cursor), 'w') as \ filter_file: filter_file.write(yaml.safe_dump(vm_filter)) LOG.info("Creating filter files done. %s filters was created." % cursor)