Juju Charm - Nova Cell Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nova_cell_controller.py 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # Copyright 2016 Canonical Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # The nova_cell_controller handlers class
  15. # bare functions are provided to the reactive handlers to perform the functions
  16. # needed on the class.
  17. from __future__ import absolute_import
  18. import collections
  19. import subprocess
  20. import charmhelpers.core.hookenv as hookenv
  21. import charms_openstack.charm
  22. import charms_openstack.adapters
  23. import charms_openstack.ip as os_ip
  24. PACKAGES = ['nova-conductor']
  25. NOVA_DIR = '/etc/nova/'
  26. NOVA_CONF = NOVA_DIR + "nova.conf"
  27. OPENSTACK_RELEASE_KEY = 'nova-charm.openstack-release-version'
  28. # select the default release function
  29. charms_openstack.charm.use_defaults('charm.default-select-release')
  30. class NovaCellControllerCharm(charms_openstack.charm.HAOpenStackCharm):
  31. """NovaCellControllerCharm provides the specialisation of the OpenStackCharm
  32. functionality to manage a nova_cell_controller unit.
  33. """
  34. release = 'mitaka'
  35. name = 'nova-cell-controller'
  36. packages = PACKAGES
  37. service_type = 'nova-cell-controller'
  38. default_service = 'nova-conductor'
  39. services = ['nova-conductor']
  40. # Note that the hsm interface is optional - defined in config.yaml
  41. required_relations = ['shared-db', 'amqp']
  42. restart_map = {
  43. NOVA_CONF: services,
  44. }
  45. # Package for release version detection
  46. release_pkg = 'nova-common'
  47. # Package codename map for nova-common
  48. package_codenames = {
  49. 'nova-common': collections.OrderedDict([
  50. ('13', 'mitaka'),
  51. ('14', 'newton'),
  52. ('15', 'ocata'),
  53. ('16', 'pike'),
  54. ('17', 'queens'),
  55. ('18', 'rocky'),
  56. ]),
  57. }
  58. sync_cmd = ['nova-manage', 'db', 'sync' ,'--local_cell']
  59. def get_amqp_credentials(self):
  60. """Provide the default amqp username and vhost as a tuple.
  61. :returns (username, host): two strings to send to the amqp provider.
  62. """
  63. return ('nova', 'openstack')
  64. def get_database_setup(self):
  65. """Provide the default database credentials as a list of 3-tuples
  66. returns a structure of:
  67. [
  68. {'database': <database>,
  69. 'username': <username>,
  70. 'hostname': <hostname of this unit>
  71. 'prefix': <the optional prefix for the database>, },
  72. ]
  73. :returns [{'database': ...}, ...]: credentials for multiple databases
  74. """
  75. return [{'username': 'nova', 'database': 'nova'}]
  76. def states_to_check(self, required_relations=None):
  77. """Override the default states_to_check() for the assess_status
  78. functionality so that, if we have to have an HSM relation, then enforce
  79. it on the assess_status() call.
  80. If param required_relations is not None then it overrides the
  81. instance/class variable self.required_relations.
  82. :param required_relations: [list of state names]
  83. :returns: [states{} as per parent method]
  84. """
  85. if required_relations is None:
  86. required_relations = self.required_relations
  87. return super(NovaCellControllerCharm, self).states_to_check(
  88. required_relations=required_relations)