summaryrefslogtreecommitdiffstats
path: root/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/install_ovs_dpdk.pp
blob: 3ee6328a0c632ac0876a0753af6816f36159e492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# == Class ovsdpdk::install_ovs_dpdk
#
# Installs ovs-dpdk service together with it's configuration file
# it also deploys qemu-kvm wrapper responsible for enabling some vhostforce
# options and setting huge pages into shared mode
#
class ovsdpdk::install_ovs_dpdk (
  $networking_ovs_dpdk_dir          = $::ovsdpdk::params::networking_ovs_dpdk_dir,
  $plugin_dir                       = $::ovsdpdk::params::plugin_dir,
  $ovs_dir                          = $::ovsdpdk::params::ovs_dir,
  $openvswitch_service_file         = $::ovsdpdk::params::openvswitch_service_file,
  $openvswitch_service_path         = $::ovsdpdk::params::openvswitch_service_path,
  $qemu_kvm                         = $::ovsdpdk::params::qemu_kvm,
) inherits ovsdpdk {
  require ovsdpdk::build_ovs_dpdk

  if $compute == 'True' {
    exec {'create_ovs_dpdk':
      command => "mv /etc/init.d/openvswitch-switch /tmp/openvswitch-switch.bak;\
                  cp ${networking_ovs_dpdk_dir}/devstack/ovs-dpdk/ovs-dpdk-init /etc/init.d/openvswitch-switch;\
                  chmod +x /etc/init.d/openvswitch-switch;\
                  ln -sf /etc/init.d/openvswitch-switch /etc/init.d/ovs-dpdk;\
                  cp /etc/openvswitch/conf.db /etc/openvswitch/conf.db.pre_dpdk",
      user    => root,
      path    => ['/usr/bin','/bin'],
    }

    file {'/etc/default/ovs-dpdk': content => template("${plugin_dir}/files/ovs-dpdk-conf.erb"), mode => '0644' }

    exec {'adapt_conf_file':
      command => "${plugin_dir}/files/tune_params.sh",
      user    => root,
      require => File['/etc/default/ovs-dpdk'],
    }

    package { 'zlib1g-dev':       ensure => 'installed' }
    package { 'libglib2.0-dev':   ensure => 'installed' }
    package { 'libxml2-dev':      ensure => 'installed' }
    package { 'libdevmapper-dev': ensure => 'installed' }
    package { 'libpciaccess-dev': ensure => 'installed' }
    package { 'libnl-dev':        ensure => 'installed' } 
    package { 'pkg-config':       ensure => 'installed' }
    package { 'bison':            ensure => 'installed' }
    package { 'flex':             ensure => 'installed' }
    package { 'libyajl2':         ensure => 'installed' }
    package { 'libyajl-dev':      ensure => 'installed' }
    package { 'python-dev':       ensure => 'installed' }
    package { 'numactl':          ensure => 'installed' }
    package { 'libdbus-1-dev':    ensure => 'installed' }
    package { 'libnuma1':         ensure => 'installed' }
    package { 'libnuma-dev':      ensure => 'installed' }
    package { 'libgnutls26':      ensure => 'installed' }
    package { 'libgnutls-dev':    ensure => 'installed' }

    package { 'bc':               ensure => 'installed' }

    exec {'build qemu':
      command => "true && cd /opt/code/qemu && ./configure --enable-kvm --target-list=x86_64-softmmu && make && make install",
      user    => root,
      path    => ['/usr/bin','/bin'],
      require => [ Package['flex'], Package['bison'], Package['pkg-config'], Package['libnl-dev'],
                   Package['libpciaccess-dev'], Package['libdevmapper-dev'], Package['libxml2-dev'],
                   Package['libglib2.0-dev'], Package['zlib1g-dev'], Package['numactl'], Package['python-dev'],
                   Package['libdbus-1-dev'],Package['bc'],Package['libnuma1'], Package['libnuma-dev'],
                   Package['libgnutls26'], Package['libgnutls-dev']],
      timeout => 0,
    }

    exec {'build libvirt':
      command => "true && cd /opt/code/libvirt && ./configure --prefix=/usr --with-dbus && make && make install",
      user    => root,
      path    => ['/usr/bin','/bin'],
      require => [Exec['build qemu'], Package['libyajl2'], Package['libyajl-dev']],
      timeout => 0,
    }

    exec {'build libvirt-python':
      command => "true && cd /opt/code/libvirt-python && python setup.py build && python setup.py install",
      user    => root,
      path    => ['/usr/bin','/bin'],
      require => Exec['build libvirt'],
      timeout => 0,
    }

    exec { "cp ${qemu_kvm} ${qemu_kvm}.orig":
      path    => ['/usr/bin','/bin'],
      user    => root,
      onlyif  => "test -f ${qemu_kvm}",
      require => Exec['build qemu'],
    }

    exec { "cp ${plugin_dir}/files/kvm-wrapper.sh ${qemu_kvm};chmod +x ${qemu_kvm}":
      path    => ['/usr/bin','/bin'],
      user    => root,
      onlyif  => "test -f ${qemu_kvm}",
      require => [ Exec["cp ${qemu_kvm} ${qemu_kvm}.orig"], Exec['build qemu'] ],
    }

    exec { 'ln -sf /etc/init.d/libvirtd /etc/init.d/libvirt-bin':
      path    => ['/usr/bin','/bin'],
      user    => root,
      onlyif  => 'test -f /etc/init.d/libvirtd',
    }

    # schema convert required as we are not removing original db
    exec { "ovsdb-tool convert /etc/openvswitch/conf.db ${ovs_dir}/vswitchd/vswitch.ovsschema":
      path    => ['/usr/bin','/bin'],
      user    => root,
    }

    # patching of linux_net.py is required for removing error when setting of MTU
    exec { 'patch linux_net':
      command => "cp ${plugin_dir}/files/linux_net.py /usr/lib/python2.7/dist-packages/nova/network/linux_net.py",
      path    => ['/usr/bin','/bin'],
      user    => root,
      onlyif  => 'test -f /usr/lib/python2.7/dist-packages/nova/network/linux_net.py',
    }

  }

  # install mech driver
  exec {'install mech driver':
    command => 'python setup.py install',
    path    => ['/usr/bin','/bin'],
    cwd     => "${networking_ovs_dpdk_dir}",
    user    => root,
  }
}