licenses: Add license headers
[ovsnfv.git] / fuel-plugin-ovsnfv / deployment_scripts / puppet / modules / ovsdpdk / manifests / install_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::install_ovs_dpdk
16 #
17 # Installs ovs-dpdk service together with it's configuration file
18 # it also deploys qemu-kvm wrapper responsible for enabling some vhostforce
19 # options and setting huge pages into shared mode
20 #
21 class ovsdpdk::install_ovs_dpdk (
22   $networking_ovs_dpdk_dir          = $::ovsdpdk::params::networking_ovs_dpdk_dir,
23   $plugin_dir                       = $::ovsdpdk::params::plugin_dir,
24   $ovs_dir                          = $::ovsdpdk::params::ovs_dir,
25   $openvswitch_service_file         = $::ovsdpdk::params::openvswitch_service_file,
26   $openvswitch_service_path         = $::ovsdpdk::params::openvswitch_service_path,
27   $qemu_kvm                         = $::ovsdpdk::params::qemu_kvm,
28 ) inherits ovsdpdk {
29   require ovsdpdk::build_ovs_dpdk
30
31   if $compute == 'True' {
32     exec {'create_ovs_dpdk':
33       command => "mv /etc/init.d/openvswitch-switch /tmp/openvswitch-switch.bak;\
34                   cp ${networking_ovs_dpdk_dir}/devstack/ovs-dpdk/ovs-dpdk-init /etc/init.d/openvswitch-switch;\
35                   chmod +x /etc/init.d/openvswitch-switch;\
36                   ln -sf /etc/init.d/openvswitch-switch /etc/init.d/ovs-dpdk;\
37                   cp /etc/openvswitch/conf.db /etc/openvswitch/conf.db.pre_dpdk",
38       user    => root,
39       path    => ['/usr/bin','/bin'],
40     }
41
42     file {'/etc/default/ovs-dpdk': content => template("${plugin_dir}/files/ovs-dpdk-conf.erb"), mode => '0644' }
43
44     exec {'adapt_conf_file':
45       command => "${plugin_dir}/files/tune_params.sh",
46       user    => root,
47       require => File['/etc/default/ovs-dpdk'],
48     }
49
50     package { 'zlib1g-dev':       ensure => 'installed' }
51     package { 'libglib2.0-dev':   ensure => 'installed' }
52     package { 'libxml2-dev':      ensure => 'installed' }
53     package { 'libdevmapper-dev': ensure => 'installed' }
54     package { 'libpciaccess-dev': ensure => 'installed' }
55     package { 'libnl-dev':        ensure => 'installed' } 
56     package { 'pkg-config':       ensure => 'installed' }
57     package { 'bison':            ensure => 'installed' }
58     package { 'flex':             ensure => 'installed' }
59     package { 'libyajl2':         ensure => 'installed' }
60     package { 'libyajl-dev':      ensure => 'installed' }
61     package { 'python-dev':       ensure => 'installed' }
62     package { 'numactl':          ensure => 'installed' }
63     package { 'libdbus-1-dev':    ensure => 'installed' }
64     package { 'libnuma1':         ensure => 'installed' }
65     package { 'libnuma-dev':      ensure => 'installed' }
66     package { 'libgnutls26':      ensure => 'installed' }
67     package { 'libgnutls-dev':    ensure => 'installed' }
68
69     package { 'bc':               ensure => 'installed' }
70
71     exec {'build qemu':
72       command => "true && cd /opt/code/qemu && ./configure --enable-kvm --target-list=x86_64-softmmu && make && make install",
73       user    => root,
74       path    => ['/usr/bin','/bin'],
75       require => [ Package['flex'], Package['bison'], Package['pkg-config'], Package['libnl-dev'],
76                    Package['libpciaccess-dev'], Package['libdevmapper-dev'], Package['libxml2-dev'],
77                    Package['libglib2.0-dev'], Package['zlib1g-dev'], Package['numactl'], Package['python-dev'],
78                    Package['libdbus-1-dev'],Package['bc'],Package['libnuma1'], Package['libnuma-dev'],
79                    Package['libgnutls26'], Package['libgnutls-dev']],
80       timeout => 0,
81     }
82
83     exec {'build libvirt':
84       command => "true && cd /opt/code/libvirt && ./configure --prefix=/usr --with-dbus && make && make install",
85       user    => root,
86       path    => ['/usr/bin','/bin'],
87       require => [Exec['build qemu'], Package['libyajl2'], Package['libyajl-dev']],
88       timeout => 0,
89     }
90
91     exec {'build libvirt-python':
92       command => "true && cd /opt/code/libvirt-python && python setup.py build && python setup.py install",
93       user    => root,
94       path    => ['/usr/bin','/bin'],
95       require => Exec['build libvirt'],
96       timeout => 0,
97     }
98
99     exec { "cp ${qemu_kvm} ${qemu_kvm}.orig":
100       path    => ['/usr/bin','/bin'],
101       user    => root,
102       onlyif  => "test -f ${qemu_kvm}",
103       require => Exec['build qemu'],
104     }
105
106     exec { "cp ${plugin_dir}/files/kvm-wrapper.sh ${qemu_kvm};chmod +x ${qemu_kvm}":
107       path    => ['/usr/bin','/bin'],
108       user    => root,
109       onlyif  => "test -f ${qemu_kvm}",
110       require => [ Exec["cp ${qemu_kvm} ${qemu_kvm}.orig"], Exec['build qemu'] ],
111     }
112
113     exec { 'ln -sf /etc/init.d/libvirtd /etc/init.d/libvirt-bin':
114       path    => ['/usr/bin','/bin'],
115       user    => root,
116       onlyif  => 'test -f /etc/init.d/libvirtd',
117     }
118
119     # schema convert required as we are not removing original db
120     exec { "ovsdb-tool convert /etc/openvswitch/conf.db ${ovs_dir}/vswitchd/vswitch.ovsschema":
121       path    => ['/usr/bin','/bin'],
122       user    => root,
123     }
124
125     # patching of linux_net.py is required for removing error when setting of MTU
126     exec { 'patch linux_net':
127       command   => "${plugin_dir}/files/linux_net.sh",
128       user      => root,
129       path      => ['/usr/bin','/bin'],
130       logoutput => 'true',
131       onlyif    => 'test -f /usr/lib/python2.7/dist-packages/nova/network/linux_net.py',
132     }
133
134   }
135
136   # install mech driver
137   exec {'install mech driver':
138     command => 'python setup.py install',
139     path    => ['/usr/bin','/bin'],
140     cwd     => "${networking_ovs_dpdk_dir}",
141     user    => root,
142   }
143 }