Browse Source

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>
tags/2018.08.0
Bin Qian 11 months ago
parent
commit
d31c03457b
1 changed files with 21 additions and 2 deletions
  1. 21
    2
      service-mgmt-api/sm-api/sm_api/cmd/api.py

+ 21
- 2
service-mgmt-api/sm-api/sm_api/cmd/api.py View File

@@ -53,6 +53,15 @@ def get_handler_cls():
53 53
     return MyHandler
54 54
 
55 55
 
56
+def 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
+
56 65
 def main():
57 66
     # Parse config file and command line options, then start logging
58 67
 
@@ -65,14 +74,24 @@ def main():
65 74
     # Build and start the WSGI app
66 75
     host = socket.gethostname()
67 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 86
     wsgi = simple_server.make_server(host, port,
69 87
                                      app.VersionSelectorApplication(),
88
+                                     server_class=server_cls,
70 89
                                      handler_class=get_handler_cls())
71 90
 
72 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 93
              {'host': host, 'port': port})
75
-    LOG.info(_("Configuration:"))
94
+    LOG.info("Configuration:")
76 95
     CONF.log_opt_values(LOG, logging.INFO)
77 96
 
78 97
     try:

Loading…
Cancel
Save