%PDF- %PDF-
Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/xray/console_utils/ |
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/xray/console_utils/run_manager.py |
# -*- coding: utf-8 -*- # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT """ This module contains X Ray Manager main run function """ import sys from xray import gettext as _ from xray.console_utils.base_app import app from xray.console_utils.cmdline_parser import cmd_parser_manager, \ parse_cmd_arguments from xray.console_utils.validations import validate from xray.internal.constants import manager_log from xray.internal.user_plugin_utils import root_execution_only_check from xray.internal.utils import configure_logging, read_agent_sys_id from xray.manager import initialize_manager from xray.reconfiguration.system_id_shift import \ reconfigure as reconfigure_sys_id def run() -> None: """ Main run function """ root_execution_only_check() configure_logging(manager_log) args = parse_cmd_arguments(cmd_parser_manager()) validated_args = validate(args.__dict__) # perform reconfiguration if system_id has changed if args.system_id != read_agent_sys_id(): reconfigure_sys_id() manager_run(validated_args) @app def manager_run(args): """ X Ray Manager run function """ manager_instance = initialize_manager(args.system_id) if args.command == 'start': try: tracing_marker = 'time' count = args.time except AttributeError: tracing_marker = 'request_qty' try: count = args.request_qty except AttributeError: count = 20 result = manager_instance.start(url=args.url, client_ip=args.client_ip, tracing_by=tracing_marker, tracing_count=count) elif args.command == 'stop': result = manager_instance.stop(args.tracing_task_id) elif args.command == 'continue': result = manager_instance.continue_(args.tracing_task_id) elif args.command == 'complete': result = manager_instance.complete(args.tracing_task_id) elif args.command == 'autocomplete-tasks': result = manager_instance.autocomplete_tasks() elif args.command == 'delete': result = manager_instance.delete(args.tracing_task_id) elif args.command == 'enable-continuous': result = manager_instance.enable_continuous(args.url, args.email) elif args.command == 'disable-continuous': result = manager_instance.disable_continuous(args.url) elif args.command == 'start-continuous': result = manager_instance.start_continuous(args.url) elif args.command == 'stop-continuous': result = manager_instance.stop_continuous(args.url) elif args.command == 'continuous-tracing-list': result = manager_instance.continuous_tracing_list() elif args.command == 'tasks-list': result = manager_instance.tasks_list() elif args.command == 'requests-list': result = manager_instance.requests_list(args.tracing_task_id) elif args.command == 'request-data': result = manager_instance.request_data(args.tracing_task_id, args.request_id) elif args.command == 'enable-user-agent': result = manager_instance.enable_user_agent() elif args.command == 'disable-user-agent': result = manager_instance.disable_user_agent() elif args.command == 'user-agent-status': result = manager_instance.user_agent_status() elif args.command == 'advanced-metrics': result = manager_instance.advanced_metrics(vars(args)) elif args.command == 'enable-serverwide-mode': result = manager_instance.enable_serverwide_mode(vars(args)) elif args.command == 'disable-serverwide-mode': result = manager_instance.disable_serverwide_mode(vars(args)) else: raise SystemExit(_('Unknown action')) print(result)