68e58000591d3ab456b383260e8680d0d2cbf446
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / manifests / agents / ml2 / sriov.pp
1 #
2 # Copyright (C) 2014 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::ml2::sriov
19 #
20 # Setups SR-IOV neutron agent when using ML2 plugin
21 #
22 # === Parameters
23 #
24 # [*package_ensure*]
25 #   (optional) The state of the package
26 #   Defaults to 'present'
27 #
28 # [*enabled*]
29 #   (required) Whether or not to enable the OVS Agent
30 #   Defaults to true
31 #
32 # [*physical_device_mappings*]
33 #   (optional) List of <physical_network>:<physical device>
34 #   All physical networks listed in network_vlan_ranges
35 #   on the server should have mappings to appropriate
36 #   interfaces on each agent.
37 #   Defaults to empty list
38 #
39 # [*polling_interval*]
40 #   (optional) The number of seconds the agent will wait between
41 #   polling for local device changes.
42 #   Defaults to '2"
43 #
44 # [*exclude_devices*]
45 #   (optional) List of <network_device>:<excluded_devices> mapping
46 #   network_device to the agent's node-specific list of virtual functions
47 #   that should not be used for virtual networking. excluded_devices is a
48 #   semicolon separated list of virtual functions to exclude from network_device.
49 #   The network_device in the mapping should appear in the physical_device_mappings list.
50 class neutron::agents::ml2::sriov (
51   $package_ensure             = 'present',
52   $enabled                    = true,
53   $physical_device_mappings   = [],
54   $polling_interval           = 2,
55   $exclude_devices            = [],
56 ) {
57
58   include neutron::params
59
60   Neutron_plugin_ml2<||> ~> Service['neutron-sriov-nic-agent-service']
61
62   neutron_plugin_ml2 {
63     'sriov_nic/polling_interval':         value => $polling_interval;
64     'sriov_nic/exclude_devices':          value => join($exclude_devices, ',');
65     'sriov_nic/physical_device_mappings': value => join($physical_device_mappings, ',');
66   }
67
68
69   Package['neutron-sriov-nic-agent'] -> Neutron_plugin_ml2<||>
70   package { 'neutron-sriov-nic-agent':
71     ensure  => $package_ensure,
72     name    => $::neutron::params::sriov_nic_agent_package,
73   }
74
75   if $enabled {
76     $service_ensure = 'running'
77   } else {
78     $service_ensure = 'stopped'
79   }
80
81   service { 'neutron-sriov-nic-agent-service':
82     ensure  => $service_ensure,
83     name    => $::neutron::params::sriov_nic_agent_service,
84     enable  => $enabled,
85     require => Class['neutron'],
86   }
87
88 }