summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBin Qian <bin.qian@windriver.com>2018-06-07 17:58:14 -0400
committerJack Ding <jack.ding@windriver.com>2018-07-23 12:15:39 -0400
commitd31c03457bdc6cdd76edb100a695caa5b070df4f (patch)
treeb48c497dd808e2276c67acb5691257e82b0eb4fa
parenta1f2589486dca432ee7a548b6a8049fc17179218 (diff)
Add server class for ipv6 binding for sm_api
This fixes the issue of unrecoverable sm-api process failure leading to constant controller degrade in ipv6 system. Story: 2002838 Task: 22757 Change-Id: If5381e583174cce63cb2734a46e094f401d5172b Signed-off-by: Jack Ding <jack.ding@windriver.com>
Notes
Notes (review): Code-Review+2: John Kung <john.kung@windriver.com> Workflow+1: Jack Ding <Jack.Ding@windriver.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 23 Jul 2018 17:25:59 +0000 Reviewed-on: https://review.openstack.org/584959 Project: openstack/stx-ha Branch: refs/heads/master
-rw-r--r--service-mgmt-api/sm-api/sm_api/cmd/api.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/service-mgmt-api/sm-api/sm_api/cmd/api.py b/service-mgmt-api/sm-api/sm_api/cmd/api.py
index 8f581ea..b44b90a 100644
--- a/service-mgmt-api/sm-api/sm_api/cmd/api.py
+++ b/service-mgmt-api/sm-api/sm_api/cmd/api.py
@@ -53,6 +53,15 @@ def get_handler_cls():
53 return MyHandler 53 return MyHandler
54 54
55 55
56def get_ipv6_server_cls():
57 cls = simple_server.WSGIServer
58
59 class MyServerClassIPv6(cls, object):
60 address_family = socket.AF_INET6
61
62 return MyServerClassIPv6
63
64
56def main(): 65def main():
57 # Parse config file and command line options, then start logging 66 # Parse config file and command line options, then start logging
58 67
@@ -65,14 +74,24 @@ def main():
65 # Build and start the WSGI app 74 # Build and start the WSGI app
66 host = socket.gethostname() 75 host = socket.gethostname()
67 port = 7777 76 port = 7777
77
78 addrinfo_list = socket.getaddrinfo(host, port)
79 addrinfo = addrinfo_list[0]
80 socket_family = addrinfo[0]
81
82 server_cls = simple_server.WSGIServer
83 if socket.AF_INET6 == socket_family:
84 server_cls = get_ipv6_server_cls()
85
68 wsgi = simple_server.make_server(host, port, 86 wsgi = simple_server.make_server(host, port,
69 app.VersionSelectorApplication(), 87 app.VersionSelectorApplication(),
88 server_class=server_cls,
70 handler_class=get_handler_cls()) 89 handler_class=get_handler_cls())
71 90
72 LOG = log.getLogger(__name__) 91 LOG = log.getLogger(__name__)
73 LOG.info(_("Serving on http://%(host)s:%(port)s") % 92 LOG.info("Serving on http://%(host)s:%(port)s" %
74 {'host': host, 'port': port}) 93 {'host': host, 'port': port})
75 LOG.info(_("Configuration:")) 94 LOG.info("Configuration:")
76 CONF.log_opt_values(LOG, logging.INFO) 95 CONF.log_opt_values(LOG, logging.INFO)
77 96
78 try: 97 try: