magnum_920.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # -*- coding: utf-8 -*-
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software
  9. # distributed under the License is distributed on an "AS IS" BASIS,
  10. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  11. # implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """
  15. Installs and configures Magnum
  16. """
  17. from packstack.installer import basedefs
  18. from packstack.installer import processors
  19. from packstack.installer import utils
  20. from packstack.installer import validators
  21. from packstack.modules.documentation import update_params_usage
  22. # ------------- Magnum Packstack Plugin Initialization --------------
  23. PLUGIN_NAME = "OS-Magnum"
  24. PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
  25. def initConfig(controller):
  26. magnum_params = {
  27. "MAGNUM": [
  28. {"CMD_OPTION": "magnum-db-passwd",
  29. "PROMPT": "Enter the password for the Magnum DB access",
  30. "OPTION_LIST": [],
  31. "VALIDATORS": [validators.validate_not_empty],
  32. "DEFAULT_VALUE": "PW_PLACEHOLDER",
  33. "PROCESSORS": [processors.process_password],
  34. "MASK_INPUT": True,
  35. "LOOSE_VALIDATION": False,
  36. "CONF_NAME": "CONFIG_MAGNUM_DB_PW",
  37. "USE_DEFAULT": False,
  38. "NEED_CONFIRM": True,
  39. "CONDITION": False},
  40. {"CMD_OPTION": "magnum-ks-passwd",
  41. "PROMPT": "Enter the password for the Magnum Keystone access",
  42. "OPTION_LIST": [],
  43. "VALIDATORS": [validators.validate_not_empty],
  44. "DEFAULT_VALUE": "PW_PLACEHOLDER",
  45. "PROCESSORS": [processors.process_password],
  46. "MASK_INPUT": True,
  47. "LOOSE_VALIDATION": False,
  48. "CONF_NAME": "CONFIG_MAGNUM_KS_PW",
  49. "USE_DEFAULT": False,
  50. "NEED_CONFIRM": True,
  51. "CONDITION": False},
  52. ]
  53. }
  54. update_params_usage(basedefs.PACKSTACK_DOC, magnum_params)
  55. magnum_groups = [
  56. {"GROUP_NAME": "MAGNUM",
  57. "DESCRIPTION": "Magnum Options",
  58. "PRE_CONDITION": "CONFIG_MAGNUM_INSTALL",
  59. "PRE_CONDITION_MATCH": "y",
  60. "POST_CONDITION": False,
  61. "POST_CONDITION_MATCH": True},
  62. ]
  63. for group in magnum_groups:
  64. params = magnum_params[group["GROUP_NAME"]]
  65. controller.addGroup(group, params)
  66. def initSequences(controller):
  67. if controller.CONF['CONFIG_MAGNUM_INSTALL'] != 'y':
  68. return
  69. magnum_steps = [
  70. {'title': 'Adding Magnum manifest entries',
  71. 'functions': [create_all_manifest]},
  72. ]
  73. controller.addSequence("Installing OpenStack Magnum", [], [],
  74. magnum_steps)
  75. # ------------------------- helper functions -------------------------
  76. # ------------------------ Step Functions ----------------------------
  77. def create_all_manifest(config, messages):
  78. if config['CONFIG_AMQP_ENABLE_SSL'] == 'y':
  79. ssl_cert_file = config['CONFIG_MAGNUM_SSL_CERT'] = (
  80. '/etc/pki/tls/certs/ssl_amqp_magnum.crt'
  81. )
  82. ssl_key_file = config['CONFIG_MAGNUM_SSL_KEY'] = (
  83. '/etc/pki/tls/private/ssl_amqp_magnum.key'
  84. )
  85. ssl_host = config['CONFIG_CONTROLLER_HOST']
  86. service = 'magnum'
  87. generate_ssl_cert(config, ssl_host, service, ssl_key_file,
  88. ssl_cert_file)
  89. fw_details = dict()
  90. key = "magnum"
  91. fw_details.setdefault(key, {})
  92. fw_details[key]['host'] = "ALL"
  93. fw_details[key]['service_name'] = "magnum api"
  94. fw_details[key]['chain'] = "INPUT"
  95. fw_details[key]['ports'] = ['9511']
  96. fw_details[key]['proto'] = "tcp"
  97. config['FIREWALL_MAGNUM_API_RULES'] = fw_details