]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/neutron/manifests/agents/metering.pp
917215ceb7bd13b02a32e81e639953e45fdd1d70
[dsa-puppet.git] / 3rdparty / modules / neutron / manifests / agents / metering.pp
1 #
2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 #
18 # == Class: neutron::agents:metering
19 #
20 # Setups Neutron metering agent.
21 #
22 # === Parameters
23 #
24 # [*package_ensure*]
25 #   (optional) Ensure state for package. Defaults to 'present'.
26 #
27 # [*enabled*]
28 #   (optional) Enable state for service. Defaults to 'true'.
29 #
30 # [*manage_service*]
31 #   (optional) Whether to start/stop the service
32 #   Defaults to true
33 #
34 # [*debug*]
35 #   (optional) Show debugging output in log. Defaults to false.
36 #
37 # [*interface_driver*]
38 #   (optional) Defaults to 'neutron.agent.linux.interface.OVSInterfaceDriver'.
39 #
40 # [*use_namespaces*]
41 #   (optional) Allow overlapping IP (Must have kernel build with
42 #   CONFIG_NET_NS=y and iproute2 package that supports namespaces).
43 #   Defaults to true.
44 #
45 # [*measure_interval*]
46 #   (optional) Interval between two metering measures.
47 #   Defaults to 30.
48 #
49 # [*report_interval*]
50 #   (optional) Interval between two metering reports.
51 #   Defaults to 300.
52 #
53
54 class neutron::agents::metering (
55   $package_ensure   = present,
56   $enabled          = true,
57   $manage_service   = true,
58   $debug            = false,
59   $interface_driver = 'neutron.agent.linux.interface.OVSInterfaceDriver',
60   $use_namespaces   = true,
61   $measure_interval = '30',
62   $report_interval  = '300'
63 ) {
64
65   include neutron::params
66
67   Neutron_config<||>                ~> Service['neutron-metering-service']
68   Neutron_metering_agent_config<||> ~> Service['neutron-metering-service']
69
70   # The metering agent loads both neutron.ini and its own file.
71   # This only lists config specific to the agent.  neutron.ini supplies
72   # the rest.
73   neutron_metering_agent_config {
74     'DEFAULT/debug':              value => $debug;
75     'DEFAULT/interface_driver':   value => $interface_driver;
76     'DEFAULT/use_namespaces':     value => $use_namespaces;
77     'DEFAULT/measure_interval':   value => $measure_interval;
78     'DEFAULT/report_interval':    value => $report_interval;
79   }
80
81   if $::neutron::params::metering_agent_package {
82     Package['neutron']            -> Package['neutron-metering-agent']
83     Package['neutron-metering-agent'] -> Neutron_config<||>
84     Package['neutron-metering-agent'] -> Neutron_metering_agent_config<||>
85     package { 'neutron-metering-agent':
86       ensure  => $package_ensure,
87       name    => $::neutron::params::metering_agent_package,
88     }
89   } else {
90     # Default dependency if the system does not provide a neutron metering agent package.
91     Package['neutron'] -> Neutron_metering_agent_config<||>
92   }
93
94   if $manage_service {
95     if $enabled {
96       $service_ensure = 'running'
97     } else {
98       $service_ensure = 'stopped'
99     }
100   }
101
102   service { 'neutron-metering-service':
103     ensure  => $service_ensure,
104     name    => $::neutron::params::metering_agent_service,
105     enable  => $enabled,
106     require => Class['neutron'],
107   }
108 }