licenses: Add license headers
[ovsnfv.git] / fuel-plugin-ovsnfv / deployment_scripts / puppet / modules / ovsdpdk / manifests / postinstall_ovs_dpdk.pp
1 # Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
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
15 # == Class ovsdpdk::postinstall_ovs_dpdk
16 #
17 # Postinstall configuration of ovs-dpdk service
18 #
19 class ovsdpdk::postinstall_ovs_dpdk (
20   $plugin_dir               = $::ovsdpdk::params::plugin_dir,
21   $nova_conf                = $::ovsdpdk::params::nova_conf,
22   $openvswitch_service_name = $::ovsdpdk::params::openvswitch_service_name,
23   $ml2_conf                 = $::ovsdpdk::params::ml2_conf,
24   $ml2_ovs_conf             = $::ovsdpdk::params::ml2_ovs_conf,
25   $neutron_l3_conf          = $::ovsdpdk::params::neutron_l3_conf,
26   $openvswitch_agent        = $::ovsdpdk::params::openvswitch_agent,
27 ) inherits ovsdpdk {
28
29   require ovsdpdk::install_ovs_dpdk
30
31   package {'crudini': ensure => installed }
32
33   # compute node specific changes
34   if $compute == 'True' {
35     # adapt configuration files
36     exec {'adapt_nova_conf':
37       command => "${plugin_dir}/files/set_vcpu_pin.sh ${nova_conf}",
38       path    => ['/usr/bin','/bin'],
39       user    => root,
40       onlyif  => "test -f ${nova_conf}",
41       require => Package['crudini'],
42     }
43
44     exec {'adapt_ml2_conf_datapath':
45       command => "sudo crudini --set ${ml2_conf} ovs datapath_type ${ovs_datapath_type}",
46       path    => ['/usr/bin','/bin'],
47       user    => root,
48       onlyif  => "test -f ${ml2_conf}",
49       require => Package['crudini'],
50     }
51
52     exec {'adapt_ml2_conf_agent_type':
53       command => "sudo crudini --set ${ml2_conf} agent agent_type 'DPDK OVS Agent'",
54       path    => ['/usr/bin','/bin'],
55       user    => root,
56       onlyif  => "test -f ${ml2_conf}",
57       require => Package['crudini'],
58     }
59
60     exec {'adapt_neutron_l3':
61       command => "sudo crudini --set ${neutron_l3_conf} DEFAULT external_network_bridge br-ex",
62       path    => ['/usr/bin','/bin'],
63       user    => root,
64       onlyif  => "test -f ${neutron_l3_conf}",
65       require => Package['crudini'],
66     }
67
68
69     service {"${openvswitch_service_name}": ensure => 'running' }
70
71     # restart OVS to synchronize ovsdb-server with ovs-vswitchd needed
72     # due to several new --no-wait entries
73     exec {'restart_ovs':
74       command => "/usr/sbin/service ${openvswitch_service_name} restart",
75       user    => root,
76       require => Service["${openvswitch_service_name}"],
77     }
78
79     exec {'configure_bridges':
80       command => "${plugin_dir}/files/configure_bridges.sh ${ovs_datapath_type}",
81       user    => root,
82       require => Exec['restart_ovs'],
83     }
84
85     service { 'libvirtd': ensure => running }
86
87     exec {'libvirtd_disable_tls':
88       command => "sudo crudini --set /etc/libvirt/libvirtd.conf '' listen_tls 0",
89       path    => ['/usr/bin','/bin'],
90       user    => root,
91       require => Package['crudini'],
92       notify  => Service['libvirtd'],
93     }
94
95     exec {'restart_nova_compute':
96       command => "/usr/sbin/service nova-compute restart",
97       user    => root,
98       require => [ Exec['libvirtd_disable_tls'], Service['libvirtd'] ],
99     }
100
101     service {"${openvswitch_agent}":
102       ensure  => 'running',
103       require => [ Exec['restart_ovs'], Service["${openvswitch_service_name}"], Exec['adapt_ml2_conf_datapath'], Exec['adapt_ml2_conf_agent_type']  ],
104     }
105
106     exec { "ovs-vsctl --no-wait set Open_vSwitch . other_config:pmd-cpu-mask=${ovs_pmd_core_mask}":
107       path    => ['/usr/bin','/bin'],
108       user    => root,
109       require => Service["${openvswitch_agent}"],
110     }
111   }
112
113   # controller specific part
114   if $controller == 'True' {
115     service {'neutron-server':
116       ensure => 'running',
117     }
118
119     exec {'append_NUMATopologyFilter':
120       command => "sudo crudini --set ${nova_conf} DEFAULT scheduler_default_filters RetryFilter,AvailabilityZoneFilter,RamFilter,\
121 CoreFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,NUMATopologyFilter",
122       path    => ['/usr/bin','/bin'],
123       user    => root,
124       onlyif  => "test -f ${nova_conf}",
125       require => Package['crudini'],
126     }
127
128     exec { 'agents_flavors_update':
129       command => "${plugin_dir}/files/agents_flavors_update.sh",
130       user      => 'root',
131       logoutput => 'true',
132       timeout   => 0,
133       require   => [ Service['neutron-server'], Exec['append_NUMATopologyFilter'] ],
134     }
135
136     exec {'restart_neutron_server':
137       command => "/usr/sbin/service neutron-server restart",
138       user    => root,
139       require => Exec['agents_flavors_update'],
140     }
141
142     exec {'restart_nova_scheduler':
143       command => "/usr/sbin/service nova-scheduler restart",
144       user    => root,
145       require => Exec['agents_flavors_update'],
146     }
147
148   }
149
150   # common part
151   exec {'adapt_ml2_conf_mechanism_driver':
152     command => "sudo crudini --set ${ml2_conf} ml2 mechanism_drivers ovsdpdk",
153     path    => ['/usr/bin','/bin'],
154     user    => root,
155     onlyif  => "test -f ${ml2_conf}",
156     require => Package['crudini'],
157   }
158
159   exec {'adapt_ml2_conf_security_group':
160     command => "sudo crudini --set ${ml2_conf} securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver",
161     path    => ['/usr/bin','/bin'],
162     user    => root,
163     onlyif  => "test -f ${ml2_conf}",
164     require => Package['crudini'],
165   }
166 }