1 # Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # == Class ovsdpdk::install_ovs_dpdk
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
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,
29 require ovsdpdk::build_ovs_dpdk
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",
39 path => ['/usr/bin','/bin'],
42 file {'/etc/default/ovs-dpdk': content => template("${plugin_dir}/files/ovs-dpdk-conf.erb"), mode => '0644' }
44 exec {'adapt_conf_file':
45 command => "${plugin_dir}/files/tune_params.sh",
47 require => File['/etc/default/ovs-dpdk'],
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' }
69 package { 'bc': ensure => 'installed' }
72 command => "true && cd /opt/code/qemu && ./configure --enable-kvm --target-list=x86_64-softmmu && make && make install",
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']],
83 exec {'build libvirt':
84 command => "true && cd /opt/code/libvirt && ./configure --prefix=/usr --with-dbus && make && make install",
86 path => ['/usr/bin','/bin'],
87 require => [Exec['build qemu'], Package['libyajl2'], Package['libyajl-dev']],
91 exec {'build libvirt-python':
92 command => "true && cd /opt/code/libvirt-python && python setup.py build && python setup.py install",
94 path => ['/usr/bin','/bin'],
95 require => Exec['build libvirt'],
99 exec { "cp ${qemu_kvm} ${qemu_kvm}.orig":
100 path => ['/usr/bin','/bin'],
102 onlyif => "test -f ${qemu_kvm}",
103 require => Exec['build qemu'],
106 exec { "cp ${plugin_dir}/files/kvm-wrapper.sh ${qemu_kvm};chmod +x ${qemu_kvm}":
107 path => ['/usr/bin','/bin'],
109 onlyif => "test -f ${qemu_kvm}",
110 require => [ Exec["cp ${qemu_kvm} ${qemu_kvm}.orig"], Exec['build qemu'] ],
113 exec { 'ln -sf /etc/init.d/libvirtd /etc/init.d/libvirt-bin':
114 path => ['/usr/bin','/bin'],
116 onlyif => 'test -f /etc/init.d/libvirtd',
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'],
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",
129 path => ['/usr/bin','/bin'],
131 onlyif => 'test -f /usr/lib/python2.7/dist-packages/nova/network/linux_net.py',
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}",