MCPcopy Create free account
hub / github.com/ceph/ceph / _configure

Method _configure

src/pybind/mgr/dashboard/module.py:136–220  ·  view source on GitHub ↗

Configure CherryPy and initialize self.url_prefix :returns our URI

(self)

Source from the content-addressed store, hash-verified

134
135 # pylint: disable=too-many-branches
136 def _configure(self):
137 """
138 Configure CherryPy and initialize self.url_prefix
139
140 :returns our URI
141 """
142 server_addr = self.get_localized_module_option( # type: ignore
143 'server_addr', get_default_addr())
144 use_ssl = self.get_localized_module_option('ssl', True) # type: ignore
145 if not use_ssl:
146 server_port = self.get_localized_module_option('server_port', 8080) # type: ignore
147 else:
148 server_port = self.get_localized_module_option('ssl_server_port', 8443) # type: ignore
149
150 if server_addr is None:
151 raise ServerConfigException(
152 'no server_addr configured; '
153 'try "ceph config set mgr mgr/{}/{}/server_addr <ip>"'
154 .format(self.module_name, self.get_mgr_id())) # type: ignore
155 self.log.info('server: ssl=%s host=%s port=%d', 'yes' if use_ssl else 'no', # type: ignore
156 server_addr, server_port)
157
158 # Initialize custom handlers.
159 config: Dict[str, Dict[str, Any]] = {'/': {}}
160
161 cherrypy.tools.authenticate = AuthManagerTool()
162 cherrypy.tools.plugin_hooks_filter_request = cherrypy.Tool(
163 'before_handler',
164 lambda: PLUGIN_MANAGER.hook.filter_request_before_handler(request=cherrypy.request),
165 priority=1)
166 cherrypy.tools.request_logging = RequestLoggingTool()
167 cherrypy.tools.dashboard_exception_handler = HandlerWrapperTool(dashboard_exception_handler,
168 priority=31)
169
170 ssl_info = None
171 if use_ssl:
172 # SSL initialization
173 cert = self.get_localized_store("crt") # type: ignore
174 if cert is not None:
175 self.cert_tmp = tempfile.NamedTemporaryFile()
176 self.cert_tmp.write(cert.encode('utf-8'))
177 self.cert_tmp.flush() # cert_tmp must not be gc'ed
178 cert_fname = self.cert_tmp.name
179 else:
180 cert_fname = self.get_localized_module_option('crt_file') # type: ignore
181
182 pkey = self.get_localized_store("key") # type: ignore
183 if pkey is not None:
184 self.pkey_tmp = tempfile.NamedTemporaryFile()
185 self.pkey_tmp.write(pkey.encode('utf-8'))
186 self.pkey_tmp.flush() # pkey_tmp must not be gc'ed
187 pkey_fname = self.pkey_tmp.name
188 else:
189 pkey_fname = self.get_localized_module_option('key_file') # type: ignore
190
191 verify_tls_files(cert_fname, pkey_fname)
192
193 # Create custom SSL context to disable TLS 1.0 and 1.1.

Callers 1

await_configurationMethod · 0.95

Calls 15

get_default_addrFunction · 0.90
verify_tls_filesFunction · 0.90
build_urlFunction · 0.90
AuthManagerToolClass · 0.85
RequestLoggingToolClass · 0.85
prepare_url_prefixFunction · 0.85
load_cert_chainMethod · 0.80
formatMethod · 0.45
get_mgr_idMethod · 0.45

Tested by

no test coverage detected