cells.pp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. #
  2. # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
  3. #
  4. # Author: Emilien Macchi <emilien.macchi@enovance.com>
  5. # Francois Charlier <francois.charlier@enovance.com>
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. # not use this file except in compliance with the License. You may obtain
  9. # a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. # License for the specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. # == Class: nova::cells
  20. #
  21. # Installs the Nova Cells
  22. #
  23. # === Parameters:
  24. #
  25. # [*enabled*]
  26. # Use Nova Cells or not
  27. # Defaults to true
  28. #
  29. # [*manage_service*]
  30. # (optional) Whether to start/stop the service
  31. # Defaults to true
  32. #
  33. # [*create_cells*]
  34. # Create cells with nova-manage
  35. # Defaults to 'True'
  36. #
  37. # [*ensure_package*]
  38. # Desired ensure state of packages.
  39. # Defaults to present
  40. #
  41. # [*instance_updated_at_threshold*]
  42. # Number of seconds after an instance was updated or deleted to continue to update cells
  43. # Defaults to '3600'
  44. #
  45. # [*max_hop_count*]
  46. # Maximum number of hops for cells routing
  47. # Defaults to '10'
  48. #
  49. # [*scheduler*]
  50. # Cells scheduler to use
  51. # Defaults to 'nova.cells.scheduler.CellsScheduler'
  52. #
  53. # [*instance_update_num_instances*]
  54. # Number of instances to update per periodic task run
  55. # Defaults to '1'
  56. #
  57. # [*cell_name*]
  58. # name of this cell
  59. # Defaults to 'nova'
  60. #
  61. # [*cell_parent_name*]
  62. # * If a child cell, this is the name of the 'parent' cell.
  63. # * If a parent cell, should be left to undef.
  64. #
  65. # [*capabilities*]
  66. # Key/Multi-value list with the capabilities of the cell
  67. # Defaults to 'hypervisor=xenserver;kvm,os=linux;windows'
  68. #
  69. # [*call_timeout*]
  70. # Seconds to wait for response from a call to a cell
  71. # Defaults to '60'
  72. #
  73. # [*reserve_percent*]
  74. # Percentage of cell capacity to hold in reserve. Affects both memory and disk utilization
  75. # Defaults to '10.0'
  76. #
  77. # [*cell_type*]
  78. # Type of cell: parent or child
  79. # Defaults to 'None'
  80. #
  81. # [*mute_child_interval*]
  82. # Number of seconds after which a lack of capability and
  83. # capacity updates signals the child cell is to be treated as a mute
  84. # Defaults to '300'
  85. #
  86. # [*bandwidth_update_interval*]
  87. # Seconds between bandwidth updates for cells
  88. # Defaults to '600'
  89. #
  90. # [*rpc_driver_queue_base*]
  91. # Base queue name to use when communicating between cells
  92. # Various topics by message type will be appended to this
  93. # Defaults to 'cells.intercell'
  94. #
  95. # [*scheduler_filter_classes*]
  96. # Filter classes the cells scheduler should use
  97. # Defaults to 'nova.cells.filters.all_filters'
  98. #
  99. # [*scheduler_weight_classes*]
  100. # Weigher classes the cells scheduler should use
  101. # Defaults to 'nova.cells.weights.all_weighers'
  102. #
  103. # [*scheduler_retries*]
  104. # How many retries when no cells are available
  105. # Defaults to '10'
  106. #
  107. # [*scheduler_retry_delay*]
  108. # How often to retry in seconds when no cells are available
  109. # Defaults to '2'
  110. #
  111. # [*db_check_interval*]
  112. # Seconds between getting fresh cell info from db
  113. # Defaults to '60'
  114. #
  115. # [*mute_weight_multiplier*]
  116. # Multiplier used to weigh mute children (The value should be negative)
  117. # Defaults to '-10.0'
  118. #
  119. # [*mute_weight_value*]
  120. # Weight value assigned to mute children (The value should be positive)
  121. # Defaults to '1000.0'
  122. #
  123. # [*ram_weight_multiplier*]
  124. # Multiplier used for weighing ram. Negative numbers mean to stack vs spread
  125. # Defaults to '10.0'
  126. #
  127. # [*weight_offset*]
  128. # It might be used by some cell scheduling code in the future
  129. # Defaults to '1.0'
  130. #
  131. # [*weight_scale*]
  132. # It might be used by some cell scheduling code in the future
  133. # Defaults to '1.0'
  134. #
  135. class nova::cells (
  136. $bandwidth_update_interval = '600',
  137. $call_timeout = '60',
  138. $capabilities = ['hypervisor=xenserver;kvm','os=linux;windows'],
  139. $cell_name = 'nova',
  140. $cell_type = undef,
  141. $cell_parent_name = undef,
  142. $create_cells = true,
  143. $db_check_interval = '60',
  144. $enabled = true,
  145. $ensure_package = 'present',
  146. $instance_updated_at_threshold = '3600',
  147. $instance_update_num_instances = '1',
  148. $manage_service = true,
  149. $max_hop_count = '10',
  150. $mute_child_interval = '300',
  151. $mute_weight_multiplier = '-10.0',
  152. $mute_weight_value = '1000.0',
  153. $ram_weight_multiplier = '10.0',
  154. $reserve_percent = '10.0',
  155. $rpc_driver_queue_base = 'cells.intercell',
  156. $scheduler_filter_classes = 'nova.cells.filters.all_filters',
  157. $scheduler = 'nova.cells.scheduler.CellsScheduler',
  158. $scheduler_retries = '10',
  159. $scheduler_retry_delay = '2',
  160. $scheduler_weight_classes = 'nova.cells.weights.all_weighers',
  161. $weight_offset = '1.0',
  162. $weight_scale = '1.0',
  163. ) {
  164. include ::nova::deps
  165. include ::nova::params
  166. case $cell_type {
  167. 'parent': {
  168. nova_config { 'DEFAULT/compute_api_class': value => 'nova.compute.cells_api.ComputeCellsAPI' }
  169. nova_config { 'cells/cell_type': value => 'api' }
  170. }
  171. 'child': {
  172. nova_config { 'cells/cell_type': value => 'compute' }
  173. }
  174. default: { fail("Unsupported cell_type parameter value: '${cell_type}'. Should be 'parent' or 'child'.") }
  175. }
  176. nova_config {
  177. 'cells/bandwidth_update_interval': value => $bandwidth_update_interval;
  178. 'cells/call_timeout': value => $call_timeout;
  179. 'cells/capabilities': value => join($capabilities, ',');
  180. 'cells/db_check_interval': value => $db_check_interval;
  181. 'cells/enable': value => $enabled;
  182. 'cells/instance_updated_at_threshold': value => $instance_updated_at_threshold;
  183. 'cells/instance_update_num_instances': value => $instance_update_num_instances;
  184. 'cells/max_hop_count': value => $max_hop_count;
  185. 'cells/mute_child_interval': value => $mute_child_interval;
  186. 'cells/mute_weight_multiplier': value => $mute_weight_multiplier;
  187. 'cells/mute_weight_value': value => $mute_weight_value;
  188. 'cells/name': value => $cell_name;
  189. 'cells/ram_weight_multiplier': value => $ram_weight_multiplier;
  190. 'cells/reserve_percent': value => $reserve_percent;
  191. 'cells/rpc_driver_queue_base': value => $rpc_driver_queue_base;
  192. 'cells/scheduler_filter_classes': value => $scheduler_filter_classes;
  193. 'cells/scheduler_retries': value => $scheduler_retries;
  194. 'cells/scheduler_retry_delay': value => $scheduler_retry_delay;
  195. 'cells/scheduler': value => $scheduler;
  196. 'cells/scheduler_weight_classes': value => $scheduler_weight_classes;
  197. }
  198. nova::generic_service { 'cells':
  199. enabled => $enabled,
  200. manage_service => $manage_service,
  201. package_name => $::nova::params::cells_package_name,
  202. service_name => $::nova::params::cells_service_name,
  203. ensure_package => $ensure_package,
  204. }
  205. if $create_cells {
  206. @@nova::manage::cells { $cell_name:
  207. cell_type => $cell_type,
  208. cell_parent_name => $cell_parent_name,
  209. rabbit_username => $::nova::rabbit_userid,
  210. rabbit_password => $::nova::rabbit_password,
  211. rabbit_hosts => $::nova::rabbit_hosts,
  212. rabbit_port => $::nova::rabbit_port,
  213. rabbit_virtual_host => $::nova::rabbit_virtual_host,
  214. weight_offset => $weight_offset,
  215. weight_scale => $weight_scale,
  216. before => Service['cells']
  217. }
  218. case $cell_type {
  219. 'parent': {
  220. # A parent cell must declare its child cell(s)
  221. Nova::Manage::Cells <<| cell_parent_name == $cell_parent_name and cell_type == 'child' |>>
  222. }
  223. 'child': {
  224. # A child cell must declare its parent cell
  225. Nova::Manage::Cells <<| name == $cell_parent_name and cell_type == 'parent' |>>
  226. }
  227. default: {
  228. fail("Invalid cell_type parameter value: ${cell_type}")
  229. }
  230. }
  231. }
  232. }