Browse Source

[master] Merged trac5361 (kea-shell --path)

Francis Dupont 7 years ago
parent
commit
e3296d4f19

+ 2 - 2
doc/examples/https/nginx/kea-nginx.conf

@@ -79,8 +79,8 @@ http {
 
         # For the URL https://kea.example.org forward the
         # requests to http://127.0.0.1:8000.
-        # Since kea-shell doesn't currently support URLs with paths we
-        # use location /
+        # kea-shell defaults to / but --path can be used to set another value
+        # for instance kea-shell --path kea which will matches location /kea
         location / {
             proxy_pass http://127.0.0.1:8000;
         }

+ 19 - 1
doc/guide/shell.xml

@@ -25,7 +25,7 @@
     <title>Shell Usage</title>
     <para><command>kea-shell</command> is run as follows:
 <screen>
-kea-shell [--host hostname] [--port number] [--timeout seconds] [--service service-name] [command]
+kea-shell [--host hostname] [--port number] [--path path] [--timeout seconds] [--service service-name] [command]
 </screen>
     where:
     </para>
@@ -46,6 +46,15 @@ kea-shell [--host hostname] [--port number] [--timeout seconds] [--service servi
 
       <listitem>
         <simpara>
+          <command>--path <replaceable>path</replaceable></command> specifies
+          the path in the URL to connect to. If not specified,
+          empty path is used. As CA listens at the empty path
+          this parameter is useful only with a reverse proxy.
+        </simpara>
+      </listitem>
+
+      <listitem>
+        <simpara>
           <command>--timeout <replaceable>seconds</replaceable></command> specifies the
           timeout (in seconds) for the connection. If not given, 10 seconds is used.
         </simpara>
@@ -119,6 +128,15 @@ $ <userinput>cat param.json | kea-shell --host 192.0.2.1 config-write > result.j
 </screen>
     </para>
 
+    <para>When a reverse proxy is used to de-multiplex requests to different
+    servers the default empty path in the URL is not enough so the
+    <command> --path </command> parameter should be used. For instance
+    if requests to the "/kea" path are forwarded to the CA this can be used:
+<screen>
+$ <userinput>kea-shell --host 192.0.2.1 --port 8001 --path kea ...</userinput>
+</screen>
+    </para>
+
     <para>Kea Shell requires Python to to be installed on the system. It was tested with
     Python 2.7 and various versions
     of Python 3, up to 3.5. Since not every Kea deployment uses this feature and there are

+ 4 - 0
src/bin/shell/kea-shell.in

@@ -60,6 +60,9 @@ def shell_body():
     parser.add_argument('--port', type=int, default=8000,
                         help='TCP port of the CA to connect to '
                         '(default: 8000)')
+    parser.add_argument('--path', type=str, default='',
+                        help='Path of the URL to connect to '
+                        '(default: "")')
     parser.add_argument('--timeout', type=int, default='10',
                         help='Timeout (in seconds) when attempting to '
                         'connect to CA (default: 10)')
@@ -84,6 +87,7 @@ def shell_body():
     params.service = cmd_args.service
     params.http_host = cmd_args.host
     params.http_port = cmd_args.port
+    params.path += cmd_args.path
     params.timeout = cmd_args.timeout
     params.version = VERSION
 

+ 10 - 0
src/bin/shell/kea-shell.xml

@@ -52,6 +52,7 @@
       <arg><option>-v</option></arg>
       <arg><option>--host</option></arg>
       <arg><option>--port</option></arg>
+      <arg><option>--path</option></arg>
       <arg><option>--timeout</option></arg>
       <arg><option>--service</option></arg>
       <arg><option>command</option></arg>
@@ -110,6 +111,15 @@
       </varlistentry>
 
       <varlistentry>
+        <term><option>--path</option></term>
+        <listitem><para>
+          Specifies the path in the URL to connect to. If not specified,
+          empty path is used. As Control Agent listens at the empty path
+          this parameter is useful only with a reverse proxy.
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
         <term><option>--timeout</option></term>
         <listitem><para>
           Specifies the connection timeout in seconds. If not