ironic_275.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 Ironic
  16. """
  17. from packstack.installer import basedefs
  18. from packstack.installer import utils
  19. from packstack.installer import validators
  20. from packstack.installer import processors
  21. from packstack.modules.documentation import update_params_usage
  22. from packstack.modules.ospluginutils import generate_ssl_cert
  23. # ------------------ Ironic Packstack Plugin initialization ------------------
  24. PLUGIN_NAME = "OS-Ironic"
  25. PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
  26. def initConfig(controller):
  27. ironic_params = [
  28. {"CONF_NAME": "CONFIG_IRONIC_DB_PW",
  29. "CMD_OPTION": "os-ironic-db-passwd",
  30. "PROMPT": "Enter the password for the Ironic DB user",
  31. "OPTION_LIST": [],
  32. "VALIDATORS": [validators.validate_not_empty],
  33. "DEFAULT_VALUE": "PW_PLACEHOLDER",
  34. "PROCESSORS": [processors.process_password],
  35. "MASK_INPUT": True,
  36. "LOOSE_VALIDATION": False,
  37. "USE_DEFAULT": False,
  38. "NEED_CONFIRM": True,
  39. "CONDITION": False},
  40. {"CONF_NAME": "CONFIG_IRONIC_KS_PW",
  41. "CMD_OPTION": "os-ironic-ks-passwd",
  42. "PROMPT": "Enter the password for Ironic Keystone access",
  43. "OPTION_LIST": [],
  44. "VALIDATORS": [validators.validate_not_empty],
  45. "DEFAULT_VALUE": "PW_PLACEHOLDER",
  46. "PROCESSORS": [processors.process_password],
  47. "MASK_INPUT": True,
  48. "LOOSE_VALIDATION": False,
  49. "USE_DEFAULT": False,
  50. "NEED_CONFIRM": True,
  51. "CONDITION": False},
  52. ]
  53. update_params_usage(basedefs.PACKSTACK_DOC, ironic_params, sectioned=False)
  54. ironic_group = {"GROUP_NAME": "IRONIC",
  55. "DESCRIPTION": "Ironic Options",
  56. "PRE_CONDITION": "CONFIG_IRONIC_INSTALL",
  57. "PRE_CONDITION_MATCH": "y",
  58. "POST_CONDITION": False,
  59. "POST_CONDITION_MATCH": True}
  60. controller.addGroup(ironic_group, ironic_params)
  61. def initSequences(controller):
  62. if controller.CONF['CONFIG_IRONIC_INSTALL'] != 'y':
  63. return
  64. steps = [
  65. {'title': 'Preparing Ironic entries',
  66. 'functions': [create_manifest]},
  67. ]
  68. controller.addSequence("Installing OpenStack Ironic", [], [],
  69. steps)
  70. # -------------------------- step functions --------------------------
  71. def create_manifest(config, messages):
  72. if config['CONFIG_AMQP_ENABLE_SSL'] == 'y':
  73. ssl_host = config['CONFIG_CONTROLLER_HOST']
  74. ssl_cert_file = config['CONFIG_IRONIC_SSL_CERT'] = (
  75. '/etc/pki/tls/certs/ssl_amqp_ironic.crt'
  76. )
  77. ssl_key_file = config['CONFIG_IRONIC_SSL_KEY'] = (
  78. '/etc/pki/tls/private/ssl_amqp_ironic.key'
  79. )
  80. service = 'ironic'
  81. generate_ssl_cert(config, ssl_host, service, ssl_key_file,
  82. ssl_cert_file)
  83. fw_details = dict()
  84. key = "ironic-api"
  85. fw_details.setdefault(key, {})
  86. fw_details[key]['host'] = "ALL"
  87. fw_details[key]['service_name'] = "ironic-api"
  88. fw_details[key]['chain'] = "INPUT"
  89. fw_details[key]['ports'] = ['6385']
  90. fw_details[key]['proto'] = "tcp"
  91. config['FIREWALL_IRONIC_API_RULES'] = fw_details