From 9eba5f599a2aebd2baa4d5f80c790d813325d83a Mon Sep 17 00:00:00 2001 From: liusheng Date: Tue, 14 Mar 2017 14:56:55 +0800 Subject: [PATCH] Add service entry for shellinabox console proxy Change-Id: I358bb501e772a10281e35825b7f048abd9b73797 Partially-Implements: bp console-support --- mogan/cmd/shellinaboxproxy.py | 34 +++++++++++++++++++++++++ mogan/conf/shellinabox.py | 48 +++++++++++++++++++++++++++++++++++ setup.cfg | 1 + 3 files changed, 83 insertions(+) create mode 100644 mogan/cmd/shellinaboxproxy.py diff --git a/mogan/cmd/shellinaboxproxy.py b/mogan/cmd/shellinaboxproxy.py new file mode 100644 index 00000000..97c0a961 --- /dev/null +++ b/mogan/cmd/shellinaboxproxy.py @@ -0,0 +1,34 @@ +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import sys + +from mogan.common import service as mogan_service +from mogan.conf import CONF +from mogan.conf import shellinabox +from mogan.console import shellinabox as shellinabox_console + +shellinabox.register_cli_opts(CONF) + + +def main(): + mogan_service.prepare_service(sys.argv) + + server_address = (CONF.shellinabox_console.shellinaboxproxy_host, + CONF.shellinabox_console.shellinaboxproxy_port) + + httpd = shellinabox_console.ThreadingHTTPServer( + server_address, + shellinabox_console.ProxyHandler) + httpd.service_start() diff --git a/mogan/conf/shellinabox.py b/mogan/conf/shellinabox.py index 9e289855..e5a68335 100644 --- a/mogan/conf/shellinabox.py +++ b/mogan/conf/shellinabox.py @@ -22,6 +22,54 @@ The shellinabox console feature allows you to connect to a guest in case a graphical console like VNC, RDP or SPICE is not available. This is only currently supported for the Ironic driver.""") +shellinaboxproxy_host_opt = cfg.IPOpt('shellinaboxproxy_host', + default='0.0.0.0', + help=""" +The IP address which is used by the ``mogan-shellinaboxproxy`` service to +listen for incoming requests. + +The ``mogan-shellinaboxproxy`` service listens on this IP address for incoming +connection requests to instances which expose shellinabox serial console. + +Possible values: + +* An IP address + +Services which consume this: + +* ``mogan-shellinaboxproxy`` + +Interdependencies to other options: + +* Ensure that this is the same IP address which is defined in the option + ``shellinabox_base_url`` of this section or use ``0.0.0.0`` to listen on + all addresses. +""") + +shellinaboxproxy_port_opt = cfg.PortOpt('shellinaboxproxy_port', + default=8866, + min=1, + max=65535, + help=""" +The port number which is used by the ``mogan-shellinaboxproxy`` service to +listen for incoming requests. + +The ``mogan-shellinaboxproxy`` service listens on this port number for incoming +connection requests to instances which expose shellinabox serial console. + +Possible values: + +* A port number + +Services which consume this: + +* ``mogan-shellinaboxproxy`` + +Interdependencies to other options: + +* Ensure that this is the same port number which is defined in the option + ``shellinabox_base_url`` of this section. +""") shellinabox_base_url_opt = cfg.URIOpt('shellinabox_base_url', default='http://127.0.0.1:8866/', diff --git a/setup.cfg b/setup.cfg index e4bff683..984b4490 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,7 @@ console_scripts = mogan-engine = mogan.cmd.engine:main mogan-scheduler = mogan.cmd.scheduler:main mogan-consoleauth = mogan.cmd.consoleauth:main + mogan-shellinaboxproxy = mogan.cmd.shellinaboxproxy:main mogan.database.migration_backend = sqlalchemy = mogan.db.sqlalchemy.migration