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