def _get_local_running_containers(): result = [] for container_id in get_local_containers_ids(): container_parameters = get_container_parameters(container_id) if container_parameters: result.append(container_parameters) return result
def main(): args = _parse_args() if not args.force and not _is_recovery_completed(): print('Recovery is not completed. Aborting saving running containers.') return saved_containers_path = args.saved_containers_path try: wait_for_consul_ready() containers_ids = get_local_containers_ids() containers_parameters_list = [] errors_count = 0 for container_id in containers_ids: try: container_parameters = get_container_parameters(container_id) if container_parameters: containers_parameters_list.append(container_parameters) except: errors_count += 1 print_err('ERROR on getting container parameters for {container_id}:'.format(**locals())) traceback.print_exc() # Don't overwrite saved containers' list if it would become empty because of errors. if containers_parameters_list or not errors_count: _save_containers_parameters_list_in_file(containers_parameters_list, saved_containers_path) print('Containers have been saved to {saved_containers_path}.'.format(**locals())) try: _save_containers_parameters_list_in_kv_store(containers_parameters_list) print('Containers have been saved to kv store.') except: traceback.print_exc() else: print('Aborted saving container because of errors.') except: traceback.print_exc() sys.exit(1)
def main(): args = _parse_args() if not args.force and not _is_recovery_completed(): get_logger().warning('Recovery is not completed. Aborting saving running containers.') return saved_containers_path = args.saved_containers_path try: wait_for_consul_ready() containers_ids = get_local_containers_ids() containers_parameters_list = [] errors_count = 0 for container_id in containers_ids: try: container_parameters = get_container_parameters(container_id) if container_parameters: containers_parameters_list.append(container_parameters) except: errors_count += 1 get_logger().error('ERROR on getting container parameters for {}:'.format(container_id)) traceback.print_exc() containers_parameters_list.sort() # Don't overwrite saved containers' list if it would become empty because of errors. if containers_parameters_list or not errors_count: _save_containers_parameters_list_in_file(containers_parameters_list, saved_containers_path) get_logger().info('Containers have been saved to {}.'.format(saved_containers_path)) try: _save_containers_parameters_list_in_kv_store(containers_parameters_list) get_logger().info('Containers have been saved to kv store.') except: traceback.print_exc() else: get_logger().info('Aborted saving container because of errors.') except: traceback.print_exc() sys.exit(1)
def _get_local_running_containers(): return [get_container_parameters(container_id) for container_id in get_local_containers_ids()]
def _get_local_running_containers(): return [ get_container_parameters(container_id) for container_id in get_local_containers_ids() ]