From 8d8f1990378437baaa301b26fca713d0a98d832f Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Sat, 13 Oct 2018 23:58:36 +0200 Subject: [PATCH] #5 - Replace class khaganatHTTPServer by OpenNeLHTTPServer --- pymanager/certificate.py | 6 +++--- pymanager/client.py | 38 +++++++++++++++++++++++--------------- pymanager/manager.py | 34 +++++++++++++++++----------------- tests/test.cfg | 2 +- tests/test_certificate.py | 4 ++-- tests/test_http.cfg | 2 +- tests/test_manager.py | 6 +++--- 7 files changed, 50 insertions(+), 42 deletions(-) diff --git a/pymanager/certificate.py b/pymanager/certificate.py index c4406fa..0249bd7 100755 --- a/pymanager/certificate.py +++ b/pymanager/certificate.py @@ -217,7 +217,7 @@ class Certificate: 'stateOrProvinceName_default = France\n' 'localityName = Locality Name (eg, city)\n' '0.organizationName = Organization Name (eg, company)\n' - '0.organizationName_default = Khanat\n' + '0.organizationName_default = OpenNeL\n' 'organizationalUnitName = Organizational ' 'Unit Name (eg, section)\n' 'commonName = Common Name (e.g. server FQDN or YOUR name)\n' @@ -529,9 +529,9 @@ def main(arguments=sys.argv[1:]): help='stateOrProvinceName for certicate') parser.add_argument('--locality_name', default='Paris', help='localityName for certicate') - parser.add_argument('--organization_name', default='khanat', + parser.add_argument('--organization_name', default='OpenNeL', help='organizationName for certicate') - parser.add_argument('--common_name', default='khanat', + parser.add_argument('--common_name', default='OpenNeL', help='commonName for certicate') print("--") args = parser.parse_args(arguments) diff --git a/pymanager/client.py b/pymanager/client.py index 6cb5835..c20fd81 100755 --- a/pymanager/client.py +++ b/pymanager/client.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- # -# script to send command to manager khaganat process +# script to send command to manager OpenNeL process # # Copyright (C) 2017 AleaJactaEst # @@ -41,7 +41,7 @@ This script need configuration file (see below for model):: address = 127.0.0.1 -Manipulate manager khaganat +Manipulate manager OpenNeL --------------------------- We can end some command to manager. @@ -66,15 +66,15 @@ We can end some command to manager. Example :: - pyclient --command="START" --program="aes" -c /home/gameserver/cfg/khaganat.cfg --log="info" --show-log-console - pyclient --command="STATUS" --program="aes" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console - pyclient --command="STDIN" --program="aes" --stdin="help all" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console - pyclient --command="STDOUT" --program="aes" --firstline=0 -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console - pyclient --command="STOP" --program="aes" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console - pyclient --command="LIST" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console - pyclient --command="SHUTDOWN" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console - pyclient --command="STARTALL" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console - pyclient --command="STATUSALL" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console + pyclient --command="START" --program="aes" -c /home/gameserver/cfg/opennel_manager.cfg --log="info" --show-log-console + pyclient --command="STATUS" --program="aes" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console + pyclient --command="STDIN" --program="aes" --stdin="help all" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console + pyclient --command="STDOUT" --program="aes" --firstline=0 -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console + pyclient --command="STOP" --program="aes" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console + pyclient --command="LIST" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console + pyclient --command="SHUTDOWN" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console + pyclient --command="STARTALL" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console + pyclient --command="STATUSALL" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console You can use curl (to replace this script). @@ -366,6 +366,14 @@ def root(command, client.send_json({'name': program}, 'POST', "/" + command) elif command == 'STATUS': client.send_json({'name': program}, 'GET', "/" + command) + elif command == 'CONFIG': + client.send_json({'name': program}, 'GET', "/" + command) + elif command == 'INFO': + client.send_json({'name': program}, 'GET', "/" + command) + elif command == 'PLAYER': + client.send_json({'name': program}, 'GET', "/" + command) + elif command == 'ADMINCOMMAND': + client.send_json({'name': program}, 'GET', "/" + command) elif command == 'STDIN': client.send_json({'name': program, 'action': stdin}, 'POST', "/" + command) elif command == 'STDOUT': @@ -385,7 +393,7 @@ def main(args=sys.argv[1:]): :param list args: all arguments ('--help, '--version', ...) """ - parser = argparse.ArgumentParser(description='Manipulate khaganat process') + parser = argparse.ArgumentParser(description='Manipulate OpenNeL process') parser.add_argument('--version', action='version', version='%(prog)s ' + __VERSION__) parser.add_argument('--show-log-console', action='store_true', help='show message in console', default=False) @@ -393,8 +401,8 @@ def main(args=sys.argv[1:]): default=None, help='log file') parser.add_argument('--log', default='INFO', help='log level [DEBUG, INFO, WARNING, ERROR') - parser.add_argument('--command', help='command send to khganat', default='/STATUS') - parser.add_argument('--program', help='program khaganat id', default='aes') + parser.add_argument('--command', help='command send to OpenNeL', default='/STATUS') + parser.add_argument('--program', help='program OpenNeL id', default='aes') parser.add_argument('--stdin', help='action send to stdin', default='') parser.add_argument('--firstline', type=int, help='define fistline read for log command', default=0) @@ -405,7 +413,7 @@ def main(args=sys.argv[1:]): '(this option keep current color state)', default=False) parser.add_argument('-c', '--conf', type=argparse.FileType('r'), - default='khaganat.cfg', help='configuration file') + default='opennel_manager.cfg', help='configuration file') parser.add_argument('-b', '--password-comand-line', action='store_true', help='Use the password from the command line rather than prompting for it.', default=False) diff --git a/pymanager/manager.py b/pymanager/manager.py index f6b33d9..98fda5f 100755 --- a/pymanager/manager.py +++ b/pymanager/manager.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- # -# script to start/stop/status/send command/read log for khaganat process +# script to start/stop/status/send command/read log for OpenNeL process # # Copyright (C) 2017 AleaJactaEst # @@ -88,7 +88,7 @@ This script need configuration file (see below for model):: Manager ------- - Manage all process khaganat + Manage all process OpenNeL Launch this prorgam in background and use clientManager to manipulate process Design @@ -101,8 +101,8 @@ Design "Manager" -> "ManageCommand (command 2)"; "ManageCommand (command 2)" -> "read_output (thread2)"; "Manager" -> "ServerHttp"; - "ServerHttp" -> "khaganatHTTPServer"; - "khaganatHTTPServer" -> "ManageHttpRequest"; + "ServerHttp" -> "OpenNeLHTTPServer"; + "OpenNeLHTTPServer" -> "ManageHttpRequest"; "ManageHttpRequest" -> "ManageCommand (command 1)" [style=dashed]; "ManageHttpRequest" -> "ManageCommand (command 2)" [style=dashed]; } @@ -145,7 +145,7 @@ http(s) command : Example :: - nohup pymanager --log info --filelog /home/gameserver/log/manager.log -c /home/gameserver/cfg/khaganat.cfg 2>/dev/null 1>/dev/null 0/dev/null 1>/dev/null 0