Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 3/9] spp-ctl: add IP address binding
Date: Thu, 18 Oct 2018 20:25:12 +0900	[thread overview]
Message-ID: <20181018112518.77556-4-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181018112518.77556-1-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Spp-ctl accepts requests only from localhost. This update is to add
supporting IP address binding with '-b' or '--bind-addr' option.

  $ python3 src/spp-ctl/spp-ctl -b 192.168.1.10

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/spp-ctl/spp_ctl.py    | 15 +++++++++------
 src/spp-ctl/spp_webapi.py |  5 +++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/spp-ctl/spp_ctl.py b/src/spp-ctl/spp_ctl.py
index e168747..80a78b6 100644
--- a/src/spp-ctl/spp_ctl.py
+++ b/src/spp-ctl/spp_ctl.py
@@ -23,8 +23,8 @@ MSG_SIZE = 4096
 
 class Controller(object):
 
-    def __init__(self, pri_port, sec_port, api_port):
-        self.web_server = spp_webapi.WebServer(self, api_port)
+    def __init__(self, host, pri_port, sec_port, api_port):
+        self.web_server = spp_webapi.WebServer(self, host, api_port)
         self.procs = {}
         self.init_connection(pri_port, sec_port)
 
@@ -144,15 +144,18 @@ class Controller(object):
 
 def main():
     parser = argparse.ArgumentParser(description="SPP Controller")
+    parser.add_argument("-b", '--bind-addr', type=str, default='localhost',
+                        help="bind address, default=localhost")
     parser.add_argument("-p", dest='pri_port', type=int, default=5555,
-                        action='store', help="primary port")
+                        action='store', help="primary port, default=5555")
     parser.add_argument("-s", dest='sec_port', type=int, default=6666,
-                        action='store', help="secondary port")
+                        action='store', help="secondary port, default=6666")
     parser.add_argument("-a", dest='api_port', type=int, default=7777,
-                        action='store', help="web api port")
+                        action='store', help="web api port, default=7777")
     args = parser.parse_args()
 
     logging.basicConfig(level=logging.DEBUG)
 
-    controller = Controller(args.pri_port, args.sec_port, args.api_port)
+    controller = Controller(args.bind_addr, args.pri_port, args.sec_port,
+                            args.api_port)
     controller.start()
diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py
index 6768aed..b2fbe3b 100644
--- a/src/spp-ctl/spp_webapi.py
+++ b/src/spp-ctl/spp_webapi.py
@@ -118,8 +118,9 @@ class WebServer(BaseHandler):
        /primary    V1PrimaryHandler
     """
 
-    def __init__(self, controller, api_port):
+    def __init__(self, controller, host, api_port):
         super(WebServer, self).__init__(controller)
+        self.host = host
         self.api_port = api_port
 
         self.mount("/v1", V1Handler(controller))
@@ -129,7 +130,7 @@ class WebServer(BaseHandler):
         self.add_hook("after_request", self.log_response)
 
     def start(self):
-        self.run(server='eventlet', host='localhost', port=self.api_port,
+        self.run(server='eventlet', host=self.host, port=self.api_port,
                  quiet=True)
 
 
-- 
2.13.1

  parent reply	other threads:[~2018-10-18 11:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 11:25 [spp] [PATCH 0/9] Change SPP controller to use spp-ctl ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 1/9] controller: add spp-ctl client for SPP controller ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 2/9] controller: change controller to use spp-ctl ogawa.yasufumi
2018-10-18 11:25 ` ogawa.yasufumi [this message]
2018-10-18 11:25 ` [spp] [PATCH 4/9] controller: add IP address and port binding ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 5/9] controller: move pri command to SppPrimary ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 6/9] controller: move sec command to SppSecondary ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 7/9] controller: move topo command to SppTopo ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 8/9] controller: move topo_resize " ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 9/9] controller: move bye command to SppBye ogawa.yasufumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181018112518.77556-4-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).