Coverage for nova/conf/wsgi.py: 88%

8 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-24 11:16 +0000

1# Copyright 2015 OpenStack Foundation 

2# All Rights Reserved. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); you may 

5# not use this file except in compliance with the License. You may obtain 

6# a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

13# License for the specific language governing permissions and limitations 

14# under the License. 

15 

16from oslo_config import cfg 

17 

18wsgi_group = cfg.OptGroup( 

19 'wsgi', 

20 title='WSGI Options', 

21 help=''' 

22Options under this group are used to configure WSGI (Web Server Gateway 

23Interface). WSGI is used to serve API requests. 

24''', 

25) 

26 

27ALL_OPTS = [ 

28 cfg.StrOpt( 

29 'api_paste_config', 

30 default="api-paste.ini", 

31 deprecated_group='DEFAULT', 

32 help=""" 

33This option represents a file name for the paste.deploy config for nova-api. 

34 

35Possible values: 

36 

37* A string representing file name for the paste.deploy config. 

38"""), 

39# TODO(sfinucan): It is not possible to rename this to 'log_format' 

40# yet, as doing so would cause a conflict if '[DEFAULT] log_format' 

41# were used. When 'deprecated_group' is removed after Ocata, this 

42# should be changed. 

43 cfg.StrOpt( 

44 'wsgi_log_format', 

45 default='%(client_ip)s "%(request_line)s" status: %(status_code)s' 

46 ' len: %(body_length)s time: %(wall_seconds).7f', 

47 deprecated_group='DEFAULT', 

48 deprecated_for_removal=True, 

49 deprecated_since='16.0.0', 

50 deprecated_reason=""" 

51This option only works when running nova-api under eventlet, and 

52encodes very eventlet specific pieces of information. Starting in Pike 

53the preferred model for running nova-api is under uwsgi or apache 

54mod_wsgi. 

55""", 

56 help=""" 

57It represents a python format string that is used as the template to generate 

58log lines. The following values can be formatted into it: client_ip, 

59date_time, request_line, status_code, body_length, wall_seconds. 

60 

61This option is used for building custom request loglines when running 

62nova-api under eventlet. If used under uwsgi or apache, this option 

63has no effect. 

64 

65Possible values: 

66 

67* '%(client_ip)s "%(request_line)s" status: %(status_code)s ' 

68 'len: %(body_length)s time: %(wall_seconds).7f' (default) 

69* Any formatted string formed by specific values. 

70"""), 

71 cfg.StrOpt( 

72 'secure_proxy_ssl_header', 

73 deprecated_group='DEFAULT', 

74 deprecated_for_removal=True, 

75 deprecated_since='31.0.0', 

76 deprecated_reason=""" 

77The functionality of this parameter is duplicate of the http_proxy_to_wsgi 

78middleware of oslo.middleware and will be completely replaced. 

79""", 

80 help=""" 

81This option specifies the HTTP header used to determine the protocol scheme 

82for the original request, even if it was removed by a SSL terminating proxy. 

83 

84Possible values: 

85 

86* None (default) - the request scheme is not influenced by any HTTP headers 

87* Valid HTTP header, like ``HTTP_X_FORWARDED_PROTO`` 

88 

89WARNING: Do not set this unless you know what you are doing. 

90 

91Make sure ALL of the following are true before setting this (assuming the 

92values from the example above): 

93 

94* Your API is behind a proxy. 

95* Your proxy strips the X-Forwarded-Proto header from all incoming requests. 

96 In other words, if end users include that header in their requests, the proxy 

97 will discard it. 

98* Your proxy sets the X-Forwarded-Proto header and sends it to API, but only 

99 for requests that originally come in via HTTPS. 

100 

101If any of those are not true, you should keep this setting set to None. 

102"""), 

103 cfg.StrOpt( 

104 'ssl_ca_file', 

105 deprecated_group='DEFAULT', 

106 help=""" 

107This option allows setting path to the CA certificate file that should be used 

108to verify connecting clients. 

109 

110Possible values: 

111 

112* String representing path to the CA certificate file. 

113 

114Related options: 

115 

116* enabled_ssl_apis 

117"""), 

118 cfg.StrOpt( 

119 'ssl_cert_file', 

120 deprecated_group='DEFAULT', 

121 help=""" 

122This option allows setting path to the SSL certificate of API server. 

123 

124Possible values: 

125 

126* String representing path to the SSL certificate. 

127 

128Related options: 

129 

130* enabled_ssl_apis 

131"""), 

132 cfg.StrOpt( 

133 'ssl_key_file', 

134 deprecated_group='DEFAULT', 

135 help=""" 

136This option specifies the path to the file where SSL private key of API 

137server is stored when SSL is in effect. 

138 

139Possible values: 

140 

141* String representing path to the SSL private key. 

142 

143Related options: 

144 

145* enabled_ssl_apis 

146"""), 

147 cfg.IntOpt( 

148 'tcp_keepidle', 

149 min=0, 

150 default=600, 

151 deprecated_group='DEFAULT', 

152 help=""" 

153This option sets the value of TCP_KEEPIDLE in seconds for each server socket. 

154It specifies the duration of time to keep connection active. TCP generates a 

155KEEPALIVE transmission for an application that requests to keep connection 

156active. Not supported on OS X. 

157 

158Related options: 

159 

160* keep_alive 

161"""), 

162 cfg.IntOpt( 

163 'default_pool_size', 

164 min=0, 

165 default=1000, 

166 deprecated_group='DEFAULT', 

167 deprecated_name='wsgi_default_pool_size', 

168 help=""" 

169This option specifies the size of the pool of greenthreads used by wsgi. 

170It is possible to limit the number of concurrent connections using this 

171option. 

172"""), 

173 cfg.IntOpt( 

174 'max_header_line', 

175 min=0, 

176 default=16384, 

177 deprecated_group='DEFAULT', 

178 help=""" 

179This option specifies the maximum line size of message headers to be accepted. 

180max_header_line may need to be increased when using large tokens (typically 

181those generated by the Keystone v3 API with big service catalogs). 

182 

183Since TCP is a stream based protocol, in order to reuse a connection, the HTTP 

184has to have a way to indicate the end of the previous response and beginning 

185of the next. Hence, in a keep_alive case, all messages must have a 

186self-defined message length. 

187"""), 

188 cfg.BoolOpt( 

189 'keep_alive', 

190 default=True, 

191 deprecated_group='DEFAULT', 

192 deprecated_name='wsgi_keep_alive', 

193 help=""" 

194This option allows using the same TCP connection to send and receive multiple 

195HTTP requests/responses, as opposed to opening a new one for every single 

196request/response pair. HTTP keep-alive indicates HTTP connection reuse. 

197 

198Possible values: 

199 

200* True : reuse HTTP connection. 

201* False : closes the client socket connection explicitly. 

202 

203Related options: 

204 

205* tcp_keepidle 

206"""), 

207 cfg.IntOpt( 

208 'client_socket_timeout', 

209 min=0, 

210 default=900, 

211 deprecated_group='DEFAULT', 

212 help=""" 

213This option specifies the timeout for client connections' socket operations. 

214If an incoming connection is idle for this number of seconds it will be 

215closed. It indicates timeout on individual read/writes on the socket 

216connection. To wait forever set to 0. 

217"""), 

218] 

219 

220 

221def register_opts(conf): 

222 conf.register_group(wsgi_group) 

223 conf.register_opts(ALL_OPTS, group=wsgi_group) 

224 

225 

226def list_opts(): 

227 return {wsgi_group: ALL_OPTS}