From 93f7683a2cd9b8020f8870dfc6b162b3d61c3fd2 Mon Sep 17 00:00:00 2001 From: Billy O'Mahony Date: Wed, 6 Jan 2016 17:00:41 +0000 Subject: fuel plugin: Initial version Change-Id: Ib41afff8f0b0f5e7c2f92f78cbdc48c99891b1ab Signed-off-by: Mark D. Gray Signed-off-by: Billy O'Mahony Signed-off-by: Michal Ptacek --- .../modules/ovsdpdk/manifests/build_ovs_dpdk.pp | 20 ++++ .../puppet/modules/ovsdpdk/manifests/clone.pp | 49 ++++++++ .../puppet/modules/ovsdpdk/manifests/init.pp | 131 +++++++++++++++++++++ .../modules/ovsdpdk/manifests/install_ovs_dpdk.pp | 76 ++++++++++++ .../puppet/modules/ovsdpdk/manifests/params.pp | 61 ++++++++++ .../ovsdpdk/manifests/postinstall_ovs_dpdk.pp | 74 ++++++++++++ .../modules/ovsdpdk/manifests/uninstall_ovs.pp | 46 ++++++++ 7 files changed, 457 insertions(+) create mode 100755 fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/build_ovs_dpdk.pp create mode 100755 fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/clone.pp create mode 100755 fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/init.pp create mode 100755 fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/install_ovs_dpdk.pp create mode 100755 fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/params.pp create mode 100755 fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/postinstall_ovs_dpdk.pp create mode 100755 fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/uninstall_ovs.pp (limited to 'fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests') diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/build_ovs_dpdk.pp b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/build_ovs_dpdk.pp new file mode 100755 index 0000000..ad0b712 --- /dev/null +++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/build_ovs_dpdk.pp @@ -0,0 +1,20 @@ +# == Class: ovsdpdk::build_ovs_dpdk +# +# It executes build of OVS with DPDK support from configured shell script +# +class ovsdpdk::build_ovs_dpdk ( + $plugin_dir = $::ovsdpdk::params::plugin_dir, +) inherits ovsdpdk { + require ovsdpdk::uninstall_ovs + + file {"${plugin_dir}/files/build_ovs_dpdk.sh": + content => template("${plugin_dir}/files/build_ovs_dpdk.erb"), + mode => '0775', + } + + exec {"${plugin_dir}/files/build_ovs_dpdk.sh": + require => File["${plugin_dir}/files/build_ovs_dpdk.sh"], + timeout => 0, + } +} + diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/clone.pp b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/clone.pp new file mode 100755 index 0000000..255de0e --- /dev/null +++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/clone.pp @@ -0,0 +1,49 @@ +# == Class: ovsdpdk::clone +# +# Responsible for downloading all relevant git repos for setting up of OVS+DPDK +# +class ovsdpdk::clone( + $dest = $::ovsdpdk::params::dest, + $ovs_dir = $::ovsdpdk::params::ovs_dir, + $ovs_dpdk_dir = $::ovsdpdk::params::ovs_dpdk_dir, + $networking_ovs_dpdk_dir = $::ovsdpdk::params::networking_ovs_dpdk_dir, + $ovs_git_tag = $::ovsdpdk::params::ovs_git_tag, + $ovs_dpdk_git_tag = $::ovsdpdk::params::ovs_dpdk_git_tag, + $ovs_plugin_git_tag = $::ovsdpdk::params::ovs_plugin_git_tag, + $master_ip = $::ovsdpdk::params::master_ip, +) inherits ovsdpdk { + + file { $dest: + ensure => directory, + mode => '0755', + } + + package { 'git': + ensure => installed, + } + + package { 'python-pip': + ensure => installed, + } + + exec { "wget dpdk": + command => "rm -rf dpdk.tgz $ovs_dpdk_dir && wget http://$master_ip:8080/plugins/fuel-plugin-ovsnfv-0.0/repositories/ubuntu/dpdk.tgz && tar xf dpdk.tgz && mv dpdk $ovs_dpdk_dir", + path => "/usr/bin:/usr/sbin:/bin:/sbin", + } + + exec { "wget ovs": + command => "rm -rf ovs.tgz $ovs_dir && wget http://$master_ip:8080/plugins/fuel-plugin-ovsnfv-0.0/repositories/ubuntu/ovs.tgz && tar xf ovs.tgz && mv ovs $ovs_dir", + path => "/usr/bin:/usr/sbin:/bin:/sbin", + } + + exec { "wget networking_ovs_dpdk": + command => "rm -rf networking-ovs-dpdk.tgz $networking_ovs_dpdk_dir && wget http://$master_ip:8080/plugins/fuel-plugin-ovsnfv-0.0/repositories/ubuntu/networking-ovs-dpdk.tgz && tar xf networking-ovs-dpdk.tgz && mv networking-ovs-dpdk $networking_ovs_dpdk_dir", + path => "/usr/bin:/usr/sbin:/bin:/sbin", + } + + exec { "install pbr": + command => "wget http://$master_ip:8080/plugins/fuel-plugin-ovsnfv-0.0/repositories/ubuntu/pbr-1.8.1-py2.py3-none-any.whl && pip install pbr-1.8.1-py2.py3-none-any.whl", + path => "/usr/bin:/usr/sbin:/bin:/sbin", + require => Package['python-pip'], + } +} diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/init.pp b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/init.pp new file mode 100755 index 0000000..de5b362 --- /dev/null +++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/init.pp @@ -0,0 +1,131 @@ +# == Class: ovsdpdk +# +# Configures and installs OVS with DPDK support service +# +# == Parameters: +# +# [*rte_target*] +# rte_target to compile OVS DPDK +# Defaults to 'x86_64-native-linuxapp-gcc' +# +# [*ovs_dpdk_mem_segments*] +# another parameter for OVS DPDK build +# Defaults to '256' +# +# [*ovs_dpdk_rte_librte_vhost*] +# another parameter for OVS DPDK build +# Defaults to 'y' +# +# [*ovs_dpdk_vhost_user_debug*] +# (True/False) indicates whether to enable debugging for VHOST USER in DPDK +# Defaults to 'n' +# +# [*ovs_allocate_hugepages*] +# (True/False) indicates whether to allocate hugepages during ovs-dpdk startup +# Defaults to 'True' +# +# [*ovs_datapath_type*] +# OVS bridges will be set to use this datapath, possible values are 'system' +# for kernel OVS and 'netdev' for userspace OVS +# Defaults to 'netdev' +# +# [*ovs_tunnel_cidr_mapping*] +# (bridge:cidr) when specified, this option enables automatic assignment of +# the tunnel endpoint ip to a specific interface. +# e.g. OVS_TUNNEL_CIDR_MAPPING=br-phy:192.168.50.1/24 assignes the ip of +# 192.168.50.1 with subnetmask 255.255.255.0 to the br-phy local port. +# This is required to enabled vxlan or other tunneling protocols with ovs-dpdk +# and dpdk physical ports. +# +# [*ovs_hugepage_mount*] +# mount point to use for hugepages. It's created and hugepages mounted if +# it doesn't exist on the filesystem +# Defaults to '/mnt/huge' +# +# [*ovs_hugepage_mount_pagesize*] +# preffered hugepage size (2M/1G) +# Defaults to OS defaults if not set. If '1G' value is used hugepages should be +# allocated before starting ovs (e.g. kernel boot command line) +# +# [*ovs_num_hugepages*] +# amount of hugepages to mount if ovs_allocate_hugepages is True +# +# [*ovs_socket_mem*] +# amount of memory to allocate on socket, recommended minimum is '512' MB +# +# [*ovs_mem_channels*] +# number of memory channels into the processor OVS will use +# +# [*ovs_core_mask*] +# cpu core mask in hexa format, is used for ovs-vswitchd process as -c option +# Defaults is '2' +# Example: +# ovs_core_mask=3 (0x11 binary -> first two cores taken) +# +# [*ovs_pmd_core_mask*] +# mask in hexa format for PMD threads od OVS set in the db. +# ovs_pmd_core_mask value is used for other_config:pmd-cpu-mask parameter in +# ovsdb. +# Defaults is '4'. In case of HT enabled, it's 4 + sibling +# +# [*ovs_bridge_mappings*] +# (network:bridge) list of comma separated pairs of "physical network:bridge" +# used by OVS/DPDK. +# Example: ovs_bridge_mappings=default:br-eth1,defaul1:br-enp9s0f0 +# +# [*ovs_dpdk_port_mappings*] +# (nic:bridge) list of comma separated pairs of "nic:bridge name" used by +# OVS/DPDK. "nic" must be a NIC interface present in the system +# "bridge" is the linux bridge created by OVS +# Example: ovs_dpdk_port_mappings=eth1:br-01,eth2:br02 +# +# [*ovs_log_dir*] +# directory where ovs-vswitchd.log will be created +# Defaults: "/tmp" +# +# [*ovs_lock_dir*] +# directory containing OVS lock file +# +# [*ovs_interface_driver*] +# (vfio-pci/igb_uio) NIC driver to use for physical network interfaces. +# Drivers names are the ones supported by DPDK, i.e: not the kernel names. +# Defaults: "igb_uio" +# +# [*ovs_patches*] +# *todo* +# +# [*ovs_dpdk_patches*] +# *todo* +# +class ovsdpdk ( + $rte_target = 'x86_64-native-linuxapp-gcc', + $ovs_dpdk_mem_segments = '256', + $ovs_dpdk_rte_librte_vhost = 'y', + $ovs_dpdk_vhost_user_debug = 'n', + $ovs_allocate_hugepages = 'True', + $ovs_datapath_type = 'netdev', + $ovs_tunnel_cidr_mapping = '', + $ovs_hugepage_mount = '/mnt/huge', + $ovs_hugepage_mount_pagesize = '2M', + $ovs_num_hugepages = '1024', + $ovs_socket_mem = 'auto', + $ovs_mem_channels = '4', + $ovs_core_mask = '2', + $ovs_pmd_core_mask = '4', + $ovs_bridge_mappings = '', + $ovs_dpdk_port_mappings = '', + $ovs_log_dir = '/tmp', + $ovs_lock_dir = '', + $ovs_interface_driver = 'igb_uio', + $ovs_patches = '', + $ovs_dpdk_patches = '', + $controller = 'False', + $compute = 'False', +) inherits ::ovsdpdk::params { + + include '::ovsdpdk::clone' + include '::ovsdpdk::uninstall_ovs' + include '::ovsdpdk::build_ovs_dpdk' + include '::ovsdpdk::install_ovs_dpdk' + include '::ovsdpdk::postinstall_ovs_dpdk' +} diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/install_ovs_dpdk.pp b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/install_ovs_dpdk.pp new file mode 100755 index 0000000..2b446de --- /dev/null +++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/install_ovs_dpdk.pp @@ -0,0 +1,76 @@ +# == 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, + $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'], + } + +# exec { 'update ovs service': +# command => "cp ${plugin_dir}/files/${openvswitch_service_file} ${openvswitch_service_path}/${openvswitch_service_file}", +# path => ['/usr/bin','/bin'], +# user => root, +# onlyif => "test -f ${openvswitch_service_path}/${openvswitch_service_file}", +# } + + if $::operatingsystem == 'CentOS' { + exec { 'systemctl daemon-reload': + path => ['/usr/bin','/bin','/usr/sbin'], + user => root, + require => Exec['update ovs service'], + } + } + + package {'qemu-kvm': ensure => installed } + + exec { "cp ${qemu_kvm} ${qemu_kvm}.orig": + path => ['/usr/bin','/bin'], + user => root, + onlyif => "test -f ${qemu_kvm}", + require => Package['qemu-kvm'], + } + + 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"], Package['qemu-kvm'] ], + } + +#exec {'init ovs-dpdk': +#command => '/etc/init.d/ovs-dpdk init', +#user => root, +#require => [ Exec['create_ovs_dpdk'], File['/etc/default/ovs-dpdk'] ], +#} + } + + # install mech driver + exec {'install mech driver': + command => 'python setup.py install', + path => ['/usr/bin','/bin'], + cwd => "${networking_ovs_dpdk_dir}", + user => root, + } +} diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/params.pp b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/params.pp new file mode 100755 index 0000000..3d7bdfa --- /dev/null +++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/params.pp @@ -0,0 +1,61 @@ +# +# This class contains the platform differences for ovsdpdk +# and environment not commonly configured stuff +# +class ovsdpdk::params { + + case $::operatingsystem { + 'Ubuntu': { + $qemu_kvm = '/usr/bin/kvm' + # we are not removing packages as of now + #$remove_packages = [ 'openvswitch-switch', 'openvswitch-datapath-dkms', 'openvswitch-common' ] + $install_packages = [ 'autoconf', 'libtool', 'screen' ] + $openvswitch_service_name = 'openvswitch-switch' + $openvswitch_service_file = 'openvswitch-switch.conf' + $openvswitch_service_path = '/etc/init' + $openvswitch_agent = 'neutron-plugin-openvswitch-agent' + } + 'CentOS': { + $qemu_kvm = '/usr/libexec/qemu-kvm' + # we are not removing packages as of now + $remove_packages = [ 'openvswitch' ] + $install_packages = [ 'pciutils', 'autoconf', 'libtool', 'screen' ] + $openvswitch_service_name = 'openvswitch' + $openvswitch_service_file = 'openvswitch.service' + $openvswitch_service_path = '/usr/lib/systemd/system' + $openvswitch_agent = 'neutron-openvswitch-agent' + } + default: { + fail("Unsupported os ${::operatingsystem}") + } + } + + $ovs_db_conf_dir = '/etc/openvswitch' + $ovs_db_socket_dir = '/var/run/openvswitch' + $ovs_db_socket = "${ovs_db_socket_dir}/db.sock" + $ovs_db_conf = "${ovs_db_conf_dir}/conf.db" + + # General config + $plugin_dir = '/etc/fuel/plugins/fuel-plugin-ovsnfv-0.0/puppet/modules/ovsdpdk' + $dest = '/opt/code' + $nova_conf_dir = '/etc/nova' + $nova_conf = "${nova_conf_dir}/nova.conf" + $ml2_ovs_conf = '/etc/neutron/plugins/ml2/openvswitch_agent.ini' + $neutron_l3_conf = '/etc/neutron/l3_agent.ini' + + # OVS config + $ovs_install_dir = '/usr' + $ovs_git_repo = 'https://github.com/openvswitch/ovs.git' + $ovs_dir = "${dest}/ovs" + $ovs_git_tag = '88058f19ed9aadb1b22d26d93e46b3fd5eb1ad32' + + # DPDK config + $ovs_dpdk_git_repo = 'http://dpdk.org/git/dpdk' + $ovs_dpdk_git_tag = 'v2.1.0' + $ovs_dpdk_dir = "${dest}/DPDK-${ovs_dpdk_git_tag}" + + # PLUGIN config + $networking_ovs_dpdk_dir = "${dest}/networking-ovs-dpdk" + $ovs_plugin_git_tag = 'master' + +} diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/postinstall_ovs_dpdk.pp b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/postinstall_ovs_dpdk.pp new file mode 100755 index 0000000..4a23a89 --- /dev/null +++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/postinstall_ovs_dpdk.pp @@ -0,0 +1,74 @@ +# == Class ovsdpdk::postinstall_ovs_dpdk +# +# Postinstall configuration of ovs-dpdk service +# +class ovsdpdk::postinstall_ovs_dpdk ( + $plugin_dir = $::ovsdpdk::params::plugin_dir, + $nova_conf = $::ovsdpdk::params::nova_conf, + $openvswitch_service_name = $::ovsdpdk::params::openvswitch_service_name, + $ml2_ovs_conf = $::ovsdpdk::params::ml2_ovs_conf, + $neutron_l3_conf = $::ovsdpdk::params::neutron_l3_conf, + $openvswitch_agent = $::ovsdpdk::params::openvswitch_agent, +) inherits ovsdpdk { + + require ovsdpdk::install_ovs_dpdk + + package {'crudini': ensure => installed } + + if $compute == 'True' { + # adapt configuration files + exec {'adapt_nova_conf': + command => "${plugin_dir}/files/set_vcpu_pin.sh ${nova_conf}", + path => ['/usr/bin','/bin'], + user => root, + onlyif => "test -f ${nova_conf}", + require => Package['crudini'], + } + + exec {'adapt_ml2_conf': + command => "sudo crudini --set ${ml2_ovs_conf} ovs datapath_type ${ovs_datapath_type}", + path => ['/usr/bin','/bin'], + user => root, + onlyif => "test -f ${ml2_ovs_conf}", + require => Package['crudini'], + } + + exec {'adapt_neutron_l3': + command => "sudo crudini --set ${neutron_l3_conf} DEFAULT external_network_bridge br-ex", + path => ['/usr/bin','/bin'], + user => root, + onlyif => "test -f ${neutron_l3_conf}", + require => Package['crudini'], + } + + + service {"${openvswitch_service_name}": ensure => 'running' } + + # restart OVS to synchronize ovsdb-server with ovs-vswitchd needed + # due to several new --no-wait entries + exec {'restart_ovs': + command => "/usr/sbin/service ${openvswitch_service_name} restart", + user => root, + require => Service["${openvswitch_service_name}"], + } + + exec { "${plugin_dir}/files/configure_bridges.sh ${ovs_datapath_type}": + user => root, + require => Exec['restart_ovs'], + } + } + + if $controller == 'True' { + service {'neutron-server': + ensure => 'running', + } + } + + if $compute == 'True' { + service {"${openvswitch_agent}": + ensure => 'running', + require => [ Exec['restart_ovs'], Service["${openvswitch_service_name}"] ], + } + } + +} diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/uninstall_ovs.pp b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/uninstall_ovs.pp new file mode 100755 index 0000000..97afdd7 --- /dev/null +++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/manifests/uninstall_ovs.pp @@ -0,0 +1,46 @@ +# == Class: ovsdpdk::uninstall_ovs +# +# Provides uninstallation of openvswitch package (if present) together with removing of kernel module +# +class ovsdpdk::uninstall_ovs ( + $openvswitch_service_name = $::ovsdpdk::params::openvswitch_service_name, + $openvswitch_agent = $::ovsdpdk::params::openvswitch_agent, + $install_packages = $::ovsdpdk::params::install_packages, + $openvswitch_agent = $::ovsdpdk::params::openvswitch_agent, +) inherits ovsdpdk { + + #Due to dependencies to other packages, we won't purge vanilla OVS + #package { $remove_packages: ensure => 'purged' } + + if $compute == 'True' { + exec { "/usr/sbin/service ${openvswitch_service_name} stop": + user => root, + } + +# This is required for Liberty +# exec { "/usr/sbin/service ${openvswitch_agent} stop": +# user => root, +# path => "/usr/bin:/bin", +# } + } + + if $controller == 'True' { + exec { '/usr/sbin/service neutron-server stop': + user => root, + path => "/usr/bin:/bin", + onlyif => "ps aux | grep -vws grep | grep -ws neutron-server" + } + } + + package { $install_packages: ensure => 'installed' } + + if $compute == 'True' { + exec { '/sbin/modprobe -r openvswitch': + onlyif => "/bin/grep -q '^openvswitch' '/proc/modules'", + user => root, +# require => Exec["/usr/sbin/service ${openvswitch_agent} stop"], + } + } + +} + -- cgit 1.2.3-korg