aodh_810.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 Aodh
  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. # ------------- Aodh Packstack Plugin Initialization --------------
  24. PLUGIN_NAME = "OS-Aodh"
  25. PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
  26. def initConfig(controller):
  27. aodh_params = {
  28. "AODH": [
  29. {"CONF_NAME": "CONFIG_AODH_KS_PW",
  30. "CMD_OPTION": "aodh-ks-passwd",
  31. "PROMPT": "Enter the password for the Aodh Keystone access",
  32. "OPTION_LIST": [],
  33. "VALIDATORS": [validators.validate_not_empty],
  34. "DEFAULT_VALUE": "PW_PLACEHOLDER",
  35. "PROCESSORS": [processors.process_password],
  36. "MASK_INPUT": True,
  37. "LOOSE_VALIDATION": False,
  38. "USE_DEFAULT": False,
  39. "NEED_CONFIRM": True,
  40. "CONDITION": False},
  41. {"CMD_OPTION": "aodh-db-passwd",
  42. "PROMPT": "Enter the password for the aodh DB 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. "CONF_NAME": "CONFIG_AODH_DB_PW",
  50. "USE_DEFAULT": False,
  51. "NEED_CONFIRM": True,
  52. "CONDITION": False},
  53. ]
  54. }
  55. update_params_usage(basedefs.PACKSTACK_DOC, aodh_params)
  56. def use_aodh(config):
  57. return (config['CONFIG_CEILOMETER_INSTALL'] == 'y' and
  58. config['CONFIG_AODH_INSTALL'] == 'y')
  59. aodh_groups = [
  60. {"GROUP_NAME": "AODH",
  61. "DESCRIPTION": "Aodh Config parameters",
  62. "PRE_CONDITION": use_aodh,
  63. "PRE_CONDITION_MATCH": True,
  64. "POST_CONDITION": False,
  65. "POST_CONDITION_MATCH": True},
  66. ]
  67. for group in aodh_groups:
  68. paramList = aodh_params[group["GROUP_NAME"]]
  69. controller.addGroup(group, paramList)
  70. def initSequences(controller):
  71. if (controller.CONF['CONFIG_AODH_INSTALL'] != 'y' or
  72. controller.CONF['CONFIG_CEILOMETER_INSTALL'] != 'y'):
  73. return
  74. steps = [{'title': 'Preparing Aodh entries',
  75. 'functions': [create_manifest]}]
  76. controller.addSequence("Installing OpenStack Aodh", [], [],
  77. steps)
  78. # -------------------------- step functions --------------------------
  79. def create_manifest(config, messages):
  80. if config['CONFIG_AMQP_ENABLE_SSL'] == 'y':
  81. ssl_cert_file = config['CONFIG_AODH_SSL_CERT'] = (
  82. '/etc/pki/tls/certs/ssl_amqp_aodh.crt'
  83. )
  84. ssl_key_file = config['CONFIG_AODH_SSL_KEY'] = (
  85. '/etc/pki/tls/private/ssl_amqp_aodh.key'
  86. )
  87. ssl_host = config['CONFIG_CONTROLLER_HOST']
  88. service = 'aodh'
  89. generate_ssl_cert(config, ssl_host, service, ssl_key_file,
  90. ssl_cert_file)
  91. fw_details = dict()
  92. key = "aodh_api"
  93. fw_details.setdefault(key, {})
  94. fw_details[key]['host'] = "ALL"
  95. fw_details[key]['service_name'] = "aodh-api"
  96. fw_details[key]['chain'] = "INPUT"
  97. fw_details[key]['ports'] = ['8042']
  98. fw_details[key]['proto'] = "tcp"
  99. config['FIREWALL_AODH_RULES'] = fw_details