Workflow Service for OpenStack.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

830 lignes
28KB

  1. # Copyright 2013 - Mirantis, Inc.
  2. # Copyright 2016 - Brocade Communications Systems, Inc.
  3. # Copyright 2018 - Extreme Networks, Inc.
  4. # Copyright 2019 - Nokia Networks
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. """
  18. Configuration options registration and useful routines.
  19. """
  20. import itertools
  21. import json
  22. import os
  23. from keystoneauth1 import loading
  24. from oslo_config import cfg
  25. from oslo_log import log
  26. from oslo_middleware import cors
  27. from osprofiler import opts as profiler
  28. from mistral import version
  29. from mistral._i18n import _
  30. from mistral.workflow import states
  31. # Options under default group.
  32. launch_opt = cfg.ListOpt(
  33. 'server',
  34. default=['all'],
  35. help=_('Specifies which mistral server to start by the launch script. '
  36. 'Valid options are all or any combination of '
  37. 'api, engine, and executor.')
  38. )
  39. wf_trace_log_name_opt = cfg.StrOpt(
  40. 'workflow_trace_log_name',
  41. default='workflow_trace',
  42. help=_('Logger name for pretty workflow trace output.')
  43. )
  44. use_debugger_opt = cfg.BoolOpt(
  45. 'use-debugger',
  46. default=False,
  47. help=_('Enables debugger. Note that using this option changes how the '
  48. 'eventlet library is used to support async IO. This could result '
  49. 'in failures that do not occur under normal operation. '
  50. 'Use at your own risk.')
  51. )
  52. auth_type_opt = cfg.StrOpt(
  53. 'auth_type',
  54. default='keystone',
  55. help=_('Authentication type (valid options: keystone, keycloak-oidc)')
  56. )
  57. api_opts = [
  58. cfg.HostAddressOpt(
  59. 'host',
  60. default='0.0.0.0',
  61. help='Mistral API server host'
  62. ),
  63. cfg.PortOpt('port', default=8989, help='Mistral API server port'),
  64. cfg.BoolOpt(
  65. 'allow_action_execution_deletion',
  66. default=False,
  67. help=_('Enables the ability to delete action_execution which '
  68. 'has no relationship with workflows.')
  69. ),
  70. cfg.BoolOpt(
  71. 'enable_ssl_api',
  72. default=False,
  73. help=_('Enable the integrated stand-alone API to service requests '
  74. 'via HTTPS instead of HTTP.')
  75. ),
  76. cfg.IntOpt(
  77. 'api_workers',
  78. help=_('Number of workers for Mistral API service '
  79. 'default is equal to the number of CPUs available if that can '
  80. 'be determined, else a default worker count of 1 is returned.')
  81. ),
  82. cfg.StrOpt(
  83. 'validation_mode',
  84. default='mandatory',
  85. choices=['enabled', 'mandatory', 'disabled'],
  86. help=_("Defines in what cases Mistral will be validating the syntax "
  87. "of workflow YAML definitions. If 'enabled' is set the service "
  88. "will be validating the syntax but only if it's not explicitly "
  89. "turned off in the API request. 'disabled' disables validation "
  90. "for all API requests. 'mandatory' enables validation for all "
  91. "API requests.")
  92. )
  93. ]
  94. js_impl_opt = cfg.StrOpt(
  95. 'js_implementation',
  96. default='pyv8',
  97. choices=['pyv8', 'v8eval', 'py_mini_racer'],
  98. help=_('The JavaScript implementation to be used by the std.javascript '
  99. 'action to evaluate scripts.')
  100. )
  101. rpc_impl_opt = cfg.StrOpt(
  102. 'rpc_implementation',
  103. default='oslo',
  104. choices=['oslo', 'kombu'],
  105. help=_('Specifies RPC implementation for RPC client and server. '
  106. 'Support of kombu driver is experimental.')
  107. )
  108. # TODO(ddeja): This config option is a part of oslo RPCClient
  109. # It would be the best to not register it twice, rather use RPCClient somehow
  110. rpc_response_timeout_opt = cfg.IntOpt(
  111. 'rpc_response_timeout',
  112. default=60,
  113. help=_('Seconds to wait for a response from a call.')
  114. )
  115. oslo_rpc_executor = cfg.StrOpt(
  116. 'oslo_rpc_executor',
  117. default='eventlet',
  118. choices=['eventlet', 'blocking', 'threading'],
  119. help=_('Executor type used by Oslo Messaging framework. Defines how '
  120. 'Oslo Messaging based RPC subsystem processes incoming calls.')
  121. )
  122. expiration_token_duration = cfg.IntOpt(
  123. 'expiration_token_duration',
  124. default=30,
  125. help=_('Window of seconds to determine whether the given token is about'
  126. ' to expire.')
  127. )
  128. pecan_opts = [
  129. cfg.StrOpt(
  130. 'root',
  131. default='mistral.api.controllers.root.RootController',
  132. help=_('Pecan root controller')
  133. ),
  134. cfg.ListOpt(
  135. 'modules',
  136. default=["mistral.api"],
  137. help=_('A list of modules where pecan will search for applications.')
  138. ),
  139. cfg.BoolOpt(
  140. 'debug',
  141. default=False,
  142. help=_('Enables the ability to display tracebacks in the browser and'
  143. ' interactively debug during development.')
  144. ),
  145. cfg.BoolOpt(
  146. 'auth_enable',
  147. default=True,
  148. help=_('Enables user authentication in pecan.')
  149. )
  150. ]
  151. engine_opts = [
  152. cfg.StrOpt('engine', default='default', help='Mistral engine plugin'),
  153. cfg.HostAddressOpt(
  154. 'host',
  155. default='0.0.0.0',
  156. help=_('Name of the engine node. This can be an opaque '
  157. 'identifier. It is not necessarily a hostname, '
  158. 'FQDN, or IP address.')
  159. ),
  160. cfg.StrOpt(
  161. 'topic',
  162. default='mistral_engine',
  163. help=_('The message topic that the engine listens on.')
  164. ),
  165. cfg.StrOpt('version', default='1.0', help='The version of the engine.'),
  166. cfg.IntOpt(
  167. 'execution_field_size_limit_kb',
  168. default=1024,
  169. help=_('The default maximum size in KB of large text fields '
  170. 'of runtime execution objects. Use -1 for no limit.')
  171. ),
  172. cfg.IntOpt(
  173. 'execution_integrity_check_delay',
  174. default=20,
  175. help=_('A number of seconds since the last update of a task'
  176. ' execution in RUNNING state after which Mistral will'
  177. ' start checking its integrity, meaning that if all'
  178. ' associated actions/workflows are finished its state'
  179. ' will be restored automatically. If this property is'
  180. ' set to a negative value Mistral will never be doing '
  181. ' this check.')
  182. ),
  183. cfg.IntOpt(
  184. 'execution_integrity_check_batch_size',
  185. default=5,
  186. min=1,
  187. help=_('A number of task executions in RUNNING state that the'
  188. ' execution integrity checker can process in a single'
  189. ' iteration.')
  190. ),
  191. cfg.IntOpt(
  192. 'action_definition_cache_time',
  193. default=60,
  194. help=_('A number of seconds that indicates how long action '
  195. 'definitions should be stored in the local cache.')
  196. ),
  197. cfg.BoolOpt(
  198. 'start_subworkflows_via_rpc',
  199. default=False,
  200. help=(
  201. 'Enables starting subworkflows via RPC. Use "False" to start '
  202. 'subworkflow within the same engine instance. Use "True" '
  203. 'to start subworkflow via RPC to improve load balancing '
  204. 'in case of several engine instances.'
  205. )
  206. )
  207. ]
  208. executor_opts = [
  209. cfg.StrOpt(
  210. 'type',
  211. choices=['local', 'remote'],
  212. default='remote',
  213. help=(
  214. 'Type of executor. Use local to run the executor within the '
  215. 'engine server. Use remote if the executor is launched as '
  216. 'a separate server to run action executions.'
  217. )
  218. ),
  219. cfg.HostAddressOpt(
  220. 'host',
  221. default='0.0.0.0',
  222. help=_('Name of the executor node. This can be an any string '
  223. 'name/identifier. It is not necessarily a hostname, '
  224. 'FQDN, or IP address. It is also related to the "target" '
  225. 'attribute of tasks defined in a workflow text. If "target" '
  226. 'is defined for a task then the action of the task will be '
  227. 'sent to one of the executors that have the same value in the '
  228. '"host" property.')
  229. ),
  230. cfg.StrOpt(
  231. 'topic',
  232. default='mistral_executor',
  233. help=_('The message topic that the executor listens on.')
  234. ),
  235. cfg.StrOpt(
  236. 'version',
  237. default='1.0',
  238. help=_('The version of the executor.')
  239. )
  240. ]
  241. scheduler_type_opt = cfg.StrOpt(
  242. 'scheduler_type',
  243. default='legacy',
  244. choices=['legacy', 'default'],
  245. help=_('The name of the scheduler implementation used in the system.')
  246. )
  247. scheduler_opts = [
  248. cfg.FloatOpt(
  249. 'fixed_delay',
  250. default=1,
  251. min=0.1,
  252. help=(
  253. 'Fixed part of the delay between scheduler iterations, '
  254. 'in seconds. '
  255. 'Full delay is defined as a sum of "fixed_delay" and a random '
  256. 'delay limited by "random_delay".'
  257. )
  258. ),
  259. cfg.FloatOpt(
  260. 'random_delay',
  261. default=0,
  262. min=0,
  263. help=(
  264. 'Max value of the random part of the delay between scheduler '
  265. 'iterations, in seconds. '
  266. 'Full delay is defined as a sum of "fixed_delay" and a random '
  267. 'delay limited by this property.'
  268. )
  269. ),
  270. cfg.IntOpt(
  271. 'batch_size',
  272. default=None,
  273. min=1,
  274. help=(
  275. 'The max number of delayed calls will be selected during '
  276. 'a scheduler iteration. '
  277. 'If this property equals None then there is no '
  278. 'restriction on selection.'
  279. )
  280. ),
  281. cfg.FloatOpt(
  282. 'captured_job_timeout',
  283. default=30,
  284. min=1,
  285. help=(
  286. 'Defines how soon (in seconds) a scheduled job captured for '
  287. 'processing becomes eligible for capturing by other schedulers '
  288. 'again. This option is needed to prevent situations when a '
  289. 'scheduler instance captured a job and failed while processing '
  290. 'and so this job can never be processed again because it is '
  291. 'marked as captured.'
  292. )
  293. ),
  294. cfg.FloatOpt(
  295. 'pickup_job_after',
  296. default=60,
  297. min=1,
  298. help='Time period given to a scheduler to process a scheduled job '
  299. 'locally before it becomes eligible for processing by other '
  300. 'scheduler instances.'
  301. 'For example, a job needs to run at 12:00:00. When a scheduler '
  302. 'starts processing it has 60 seconds (or other configured '
  303. 'value) to complete the job. If the scheduler did not complete '
  304. 'the job within this period it most likely means that the '
  305. 'scheduler process crashed. In this case another scheduler '
  306. 'instance will pick it up from the Job Store, but not earlier '
  307. 'than 12:01:00 and try to process it.'
  308. )
  309. ]
  310. cron_trigger_opts = [
  311. cfg.BoolOpt(
  312. 'enabled',
  313. default=True,
  314. help=(
  315. 'If this value is set to False then the subsystem of cron triggers'
  316. ' is disabled. Disabling cron triggers increases system'
  317. ' performance.'
  318. )
  319. ),
  320. cfg.IntOpt(
  321. 'execution_interval',
  322. default=1,
  323. min=1,
  324. help=(
  325. 'This setting defines how frequently Mistral checks for cron '
  326. 'triggers that need execution. By default this is every second '
  327. 'which can lead to high system load. Increasing the number will '
  328. 'reduce the load but also limit the minimum freqency. For '
  329. 'example, a cron trigger can be configured to run every second '
  330. 'but if the execution_interval is set to 60, it will only run '
  331. 'once per minute.'
  332. )
  333. )
  334. ]
  335. event_engine_opts = [
  336. cfg.HostAddressOpt(
  337. 'host',
  338. default='0.0.0.0',
  339. help=_('Name of the event engine node. This can be an opaque '
  340. 'identifier. It is not necessarily a hostname, '
  341. 'FQDN, or IP address.')
  342. ),
  343. cfg.HostAddressOpt(
  344. 'listener_pool_name',
  345. default='events',
  346. help=_('Name of the event engine\'s listener pool. This can be an'
  347. ' opaque identifier. It is used for identifying the group'
  348. ' of event engine listeners in oslo.messaging.')
  349. ),
  350. cfg.StrOpt(
  351. 'topic',
  352. default='mistral_event_engine',
  353. help=_('The message topic that the event engine listens on.')
  354. ),
  355. cfg.StrOpt(
  356. 'event_definitions_cfg_file',
  357. default='/etc/mistral/event_definitions.yaml',
  358. help=_('Configuration file for event definitions.')
  359. ),
  360. ]
  361. notifier_opts = [
  362. cfg.StrOpt(
  363. 'type',
  364. choices=['local', 'remote'],
  365. default='remote',
  366. help=(
  367. 'Type of notifier. Use local to run the notifier within the '
  368. 'engine server. Use remote if the notifier is launched as '
  369. 'a separate server to process events.'
  370. )
  371. ),
  372. cfg.StrOpt(
  373. 'host',
  374. default='0.0.0.0',
  375. help=_('Name of the notifier node. This can be an opaque '
  376. 'identifier. It is not necessarily a hostname, '
  377. 'FQDN, or IP address.')
  378. ),
  379. cfg.StrOpt(
  380. 'topic',
  381. default='mistral_notifier',
  382. help=_('The message topic that the notifier server listens on.')
  383. ),
  384. cfg.ListOpt(
  385. 'notify',
  386. item_type=json.loads,
  387. bounds=True,
  388. help=_('List of publishers to publish notification.')
  389. )
  390. ]
  391. execution_expiration_policy_opts = [
  392. cfg.IntOpt(
  393. 'evaluation_interval',
  394. help=_('How often will the executions be evaluated '
  395. '(in minutes). For example for value 120 the interval '
  396. 'will be 2 hours (every 2 hours). '
  397. 'Note that only final state executions will be removed: '
  398. '( SUCCESS / ERROR / CANCELLED ).')
  399. ),
  400. cfg.IntOpt(
  401. 'older_than',
  402. help=_('Evaluate from which time remove executions in minutes. '
  403. 'For example when older_than = 60, remove all executions '
  404. 'that finished a 60 minutes ago or more. '
  405. 'Minimum value is 1.')
  406. ),
  407. cfg.IntOpt(
  408. 'max_finished_executions',
  409. default=0,
  410. help=_('The maximum number of finished workflow executions '
  411. 'to be stored. For example when max_finished_executions = 100, '
  412. 'only the 100 latest finished executions will be preserved. '
  413. 'This means that even unexpired executions are eligible '
  414. 'for deletion, to decrease the number of executions in the '
  415. 'database. The default value is 0. If it is set to 0, '
  416. 'this constraint won\'t be applied.')
  417. ),
  418. cfg.IntOpt(
  419. 'batch_size',
  420. default=0,
  421. help=_('Size of batch of expired executions to be deleted.'
  422. 'The default value is 0. If it is set to 0, '
  423. 'size of batch is total number of expired executions '
  424. 'that is going to be deleted.')
  425. ),
  426. cfg.ListOpt(
  427. 'ignored_states',
  428. default=[],
  429. help='The states that the expiration policy will filter '
  430. 'out and will not delete.'
  431. 'Valid values are, [{}]'.format(states.TERMINAL_STATES)
  432. )
  433. ]
  434. action_heartbeat_opts = [
  435. cfg.IntOpt(
  436. 'max_missed_heartbeats',
  437. min=0,
  438. default=15,
  439. help=_('The maximum amount of missed heartbeats to be allowed. '
  440. 'If set to 0 then this feature is disabled. '
  441. 'See check_interval for more details.')
  442. ),
  443. cfg.IntOpt(
  444. 'check_interval',
  445. min=0,
  446. default=20,
  447. help=_('How often (in seconds) action executions are checked. '
  448. 'For example when check_interval is 10, check action '
  449. 'executions every 10 seconds. When the checker runs it will '
  450. 'transit all running action executions to error if the last '
  451. 'heartbeat received is older than 10 * max_missed_heartbeats '
  452. 'seconds. If set to 0 then this feature is disabled.')
  453. ),
  454. cfg.IntOpt(
  455. 'batch_size',
  456. min=0,
  457. default=10,
  458. help=_('The maximum number of action executions processed during '
  459. 'one iteration of action execution heartbeat checker. If set '
  460. 'to 0 then there is no limit.')
  461. ),
  462. cfg.IntOpt(
  463. 'first_heartbeat_timeout',
  464. min=0,
  465. default=3600,
  466. help=_('The first heartbeat is handled differently, to provide a '
  467. 'grace period in case there is no available executor to handle '
  468. 'the action execution. For example when '
  469. 'first_heartbeat_timeout = 3600, wait 3600 seconds before '
  470. 'closing the action executions that never received a heartbeat.'
  471. )
  472. )
  473. ]
  474. coordination_opts = [
  475. cfg.StrOpt(
  476. 'backend_url',
  477. help=_('The backend URL to be used for coordination')
  478. ),
  479. cfg.FloatOpt(
  480. 'heartbeat_interval',
  481. default=5.0,
  482. help=_('Number of seconds between heartbeats for coordination.')
  483. )
  484. ]
  485. profiler_opts = profiler.list_opts()[0][1]
  486. profiler_opts.append(
  487. cfg.StrOpt(
  488. 'profiler_log_name',
  489. default='profiler_trace',
  490. help=_('Logger name for the osprofiler trace output.')
  491. )
  492. )
  493. keycloak_oidc_opts = [
  494. cfg.StrOpt(
  495. 'auth_url',
  496. help=_('Keycloak base url (e.g. https://my.keycloak:8443/auth)')
  497. ),
  498. cfg.StrOpt(
  499. 'certfile',
  500. help=_('Required if identity server requires client certificate')
  501. ),
  502. cfg.StrOpt(
  503. 'keyfile',
  504. help=_('Required if identity server requires client certificate')
  505. ),
  506. cfg.StrOpt(
  507. 'cafile',
  508. help=_('A PEM encoded Certificate Authority to use when verifying '
  509. 'HTTPs connections. Defaults to system CAs.')
  510. ),
  511. cfg.BoolOpt(
  512. 'insecure',
  513. default=False,
  514. help=_('If True, SSL/TLS certificate verification is disabled')
  515. ),
  516. cfg.StrOpt(
  517. 'user_info_endpoint_url',
  518. default='/realms/%s/protocol/openid-connect/userinfo',
  519. help='Endpoint against which authorization will be performed'
  520. ),
  521. cfg.StrOpt(
  522. 'public_cert_url',
  523. default="/realms/%s/protocol/openid-connect/certs",
  524. help="URL to get the public key for a particular realm"
  525. ),
  526. cfg.StrOpt(
  527. 'keycloak_iss',
  528. help="Keycloak issuer(iss) url. "
  529. "Example: https://ip_add:port/auth/realms/%s"
  530. )
  531. ]
  532. openstack_actions_opts = [
  533. cfg.StrOpt(
  534. 'os-actions-endpoint-type',
  535. default=os.environ.get('OS_ACTIONS_ENDPOINT_TYPE', 'public'),
  536. choices=['public', 'admin', 'internal'],
  537. deprecated_group='DEFAULT',
  538. help=_('Type of endpoint in identity service catalog to use for'
  539. ' communication with OpenStack services.')
  540. ),
  541. cfg.ListOpt(
  542. 'modules-support-region',
  543. default=['nova', 'glance', 'heat', 'neutron', 'cinder',
  544. 'trove', 'ironic', 'designate', 'murano', 'tacker', 'senlin',
  545. 'aodh', 'gnocchi'],
  546. help=_('List of module names that support region in actions.')
  547. ),
  548. cfg.StrOpt(
  549. 'default_region',
  550. help=_('Default region name for openstack actions supporting region.')
  551. ),
  552. ]
  553. # note: this command line option is used only from sync_db and
  554. # mistral-db-manage
  555. os_actions_mapping_path = cfg.StrOpt(
  556. 'openstack_actions_mapping_path',
  557. short='m',
  558. metavar='MAPPING_PATH',
  559. default='actions/openstack/mapping.json',
  560. help='Path to openstack action mapping json file.'
  561. 'It could be relative to mistral package '
  562. 'directory or absolute.'
  563. )
  564. yaql_opts = [
  565. cfg.IntOpt(
  566. 'limit_iterators',
  567. default=-1,
  568. min=-1,
  569. help=_('Limit iterators by the given number of elements. When set, '
  570. 'each time any function declares its parameter to be iterator, '
  571. 'that iterator is modified to not produce more than a given '
  572. 'number of items. If not set (or set to -1) the result data is '
  573. 'allowed to contain endless iterators that would cause errors '
  574. 'if the result where to be serialized.')
  575. ),
  576. cfg.IntOpt(
  577. 'memory_quota',
  578. default=-1,
  579. min=-1,
  580. help=_('The memory usage quota (in bytes) for all data produced by '
  581. 'the expression (or any part of it). -1 means no limitation.')
  582. ),
  583. cfg.BoolOpt(
  584. 'convert_input_data',
  585. default=True,
  586. help=_('Enables input data conversion for YAQL expressions. If set '
  587. 'to True, YAQL will convert mutable data structures '
  588. '(lists, dicts, sets) into their immutable versions. That '
  589. 'will allow them to work with some constructs that require '
  590. 'hashable types even if elements are not hashable. For '
  591. 'example, it will be possible to put dicts into a set. '
  592. 'Although it conflicts with the base principles of such '
  593. 'collections (e.g. we cannot put a non-hashable type into '
  594. 'a set just because otherwise it will not work correctly) the '
  595. 'YAQL library itself allows this. '
  596. 'Disabling input data conversion may give significant '
  597. 'performance boost if the input data for an expression is '
  598. 'large.')
  599. ),
  600. cfg.BoolOpt(
  601. 'convert_output_data',
  602. default=True,
  603. help=_('Enables output data conversion for YAQL expressions.'
  604. 'If set to False, it is possible that YAQL will generate '
  605. 'an output that will be not JSON-serializable. For example, '
  606. 'if an expression has ".toSet()" in the end to convert a list '
  607. 'into a set. It does not mean though that such functions '
  608. 'cannot be used, they can still be used in expressions but '
  609. 'user has to keep in mind of what type a result will be, '
  610. 'whereas if the value of ths property is True YAQL will '
  611. 'convert the result to a JSON-compatible type.')
  612. ),
  613. cfg.BoolOpt(
  614. 'convert_tuples_to_lists',
  615. default=True,
  616. help=_('When set to True, yaql converts all tuples in the expression '
  617. 'result to lists. It works only if "convert_output_data" is '
  618. 'set to True.')
  619. ),
  620. cfg.BoolOpt(
  621. 'convert_sets_to_lists',
  622. default=False,
  623. help=_('When set to True, yaql converts all sets in the expression '
  624. 'result to lists. Otherwise the produced result may contain '
  625. 'sets that are not JSON-serializable. It works only if '
  626. '"convert_output_data" is set to True.')
  627. ),
  628. cfg.BoolOpt(
  629. 'iterable_dicts',
  630. default=False,
  631. help=_('When set to True, dictionaries are considered to be iterable '
  632. 'and iteration over dictionaries produces their keys (as in '
  633. 'Python and yaql 0.2).')
  634. ),
  635. cfg.StrOpt(
  636. 'keyword_operator',
  637. default='=>',
  638. help=_('Allows one to configure keyword/mapping symbol. '
  639. 'Ability to pass named arguments can be disabled altogether '
  640. 'if empty string is provided.')
  641. ),
  642. cfg.BoolOpt(
  643. 'allow_delegates',
  644. default=False,
  645. help=_('Enables or disables delegate expression parsing.')
  646. )
  647. ]
  648. CONF = cfg.CONF
  649. API_GROUP = 'api'
  650. ENGINE_GROUP = 'engine'
  651. EXECUTOR_GROUP = 'executor'
  652. SCHEDULER_GROUP = 'scheduler'
  653. CRON_TRIGGER_GROUP = 'cron_trigger'
  654. EVENT_ENGINE_GROUP = 'event_engine'
  655. NOTIFIER_GROUP = 'notifier'
  656. PECAN_GROUP = 'pecan'
  657. COORDINATION_GROUP = 'coordination'
  658. EXECUTION_EXPIRATION_POLICY_GROUP = 'execution_expiration_policy'
  659. ACTION_HEARTBEAT_GROUP = 'action_heartbeat'
  660. PROFILER_GROUP = profiler.list_opts()[0][0]
  661. KEYCLOAK_OIDC_GROUP = "keycloak_oidc"
  662. OPENSTACK_ACTIONS_GROUP = 'openstack_actions'
  663. YAQL_GROUP = "yaql"
  664. KEYSTONE_GROUP = "keystone"
  665. CONF.register_opt(wf_trace_log_name_opt)
  666. CONF.register_opt(auth_type_opt)
  667. CONF.register_opt(scheduler_type_opt)
  668. CONF.register_opt(js_impl_opt)
  669. CONF.register_opt(rpc_impl_opt)
  670. CONF.register_opt(rpc_response_timeout_opt)
  671. CONF.register_opt(oslo_rpc_executor)
  672. CONF.register_opt(expiration_token_duration)
  673. CONF.register_opts(api_opts, group=API_GROUP)
  674. CONF.register_opts(engine_opts, group=ENGINE_GROUP)
  675. CONF.register_opts(executor_opts, group=EXECUTOR_GROUP)
  676. CONF.register_opts(scheduler_opts, group=SCHEDULER_GROUP)
  677. CONF.register_opts(cron_trigger_opts, group=CRON_TRIGGER_GROUP)
  678. CONF.register_opts(
  679. execution_expiration_policy_opts,
  680. group=EXECUTION_EXPIRATION_POLICY_GROUP
  681. )
  682. CONF.register_opts(
  683. action_heartbeat_opts,
  684. group=ACTION_HEARTBEAT_GROUP
  685. )
  686. CONF.register_opts(event_engine_opts, group=EVENT_ENGINE_GROUP)
  687. CONF.register_opts(notifier_opts, group=NOTIFIER_GROUP)
  688. CONF.register_opts(pecan_opts, group=PECAN_GROUP)
  689. CONF.register_opts(coordination_opts, group=COORDINATION_GROUP)
  690. CONF.register_opts(profiler_opts, group=PROFILER_GROUP)
  691. CONF.register_opts(keycloak_oidc_opts, group=KEYCLOAK_OIDC_GROUP)
  692. CONF.register_opts(openstack_actions_opts, group=OPENSTACK_ACTIONS_GROUP)
  693. CONF.register_opts(yaql_opts, group=YAQL_GROUP)
  694. loading.register_session_conf_options(CONF, KEYSTONE_GROUP)
  695. CLI_OPTS = [
  696. use_debugger_opt,
  697. launch_opt
  698. ]
  699. default_group_opts = itertools.chain(
  700. CLI_OPTS,
  701. [
  702. wf_trace_log_name_opt,
  703. auth_type_opt,
  704. scheduler_type_opt,
  705. js_impl_opt,
  706. rpc_impl_opt,
  707. rpc_response_timeout_opt,
  708. oslo_rpc_executor,
  709. expiration_token_duration
  710. ]
  711. )
  712. CONF.register_cli_opts(CLI_OPTS)
  713. _DEFAULT_LOG_LEVELS = [
  714. 'eventlet.wsgi.server=WARN',
  715. 'oslo_service.periodic_task=INFO',
  716. 'oslo_service.loopingcall=INFO',
  717. 'mistral.services.periodic=INFO',
  718. 'kazoo.client=WARN',
  719. 'oslo_db=WARN'
  720. ]
  721. def list_opts():
  722. return [
  723. (API_GROUP, api_opts),
  724. (ENGINE_GROUP, engine_opts),
  725. (EXECUTOR_GROUP, executor_opts),
  726. (EVENT_ENGINE_GROUP, event_engine_opts),
  727. (SCHEDULER_GROUP, scheduler_opts),
  728. (CRON_TRIGGER_GROUP, cron_trigger_opts),
  729. (NOTIFIER_GROUP, notifier_opts),
  730. (PECAN_GROUP, pecan_opts),
  731. (COORDINATION_GROUP, coordination_opts),
  732. (EXECUTION_EXPIRATION_POLICY_GROUP, execution_expiration_policy_opts),
  733. (PROFILER_GROUP, profiler_opts),
  734. (KEYCLOAK_OIDC_GROUP, keycloak_oidc_opts),
  735. (OPENSTACK_ACTIONS_GROUP, openstack_actions_opts),
  736. (YAQL_GROUP, yaql_opts),
  737. (ACTION_HEARTBEAT_GROUP, action_heartbeat_opts),
  738. (None, default_group_opts)
  739. ]
  740. def parse_args(args=None, usage=None, default_config_files=None):
  741. default_log_levels = log.get_default_log_levels()
  742. default_log_levels.extend(_DEFAULT_LOG_LEVELS)
  743. log.set_defaults(default_log_levels=default_log_levels)
  744. log.register_options(CONF)
  745. CONF(
  746. args=args,
  747. project='mistral',
  748. version=version.version_string,
  749. usage=usage,
  750. default_config_files=default_config_files
  751. )
  752. def set_config_defaults():
  753. """This method updates all configuration default values."""
  754. set_cors_middleware_defaults()
  755. def set_cors_middleware_defaults():
  756. """Update default configuration options for oslo.middleware."""
  757. cors.set_defaults(
  758. allow_headers=['X-Auth-Token',
  759. 'X-Identity-Status',
  760. 'X-Roles',
  761. 'X-Service-Catalog',
  762. 'X-User-Id',
  763. 'X-Tenant-Id',
  764. 'X-Project-Id',
  765. 'X-User-Name',
  766. 'X-Project-Name'],
  767. allow_methods=['GET',
  768. 'PUT',
  769. 'POST',
  770. 'DELETE',
  771. 'PATCH'],
  772. expose_headers=['X-Auth-Token',
  773. 'X-Subject-Token',
  774. 'X-Service-Token',
  775. 'X-Project-Id',
  776. 'X-User-Name',
  777. 'X-Project-Name']
  778. )