SR-IOV support

- custom facter added to detect srv-iov capable interfaces
- nova scheduler settings updated
- sr-iov enabled for nova

Change-Id: Ibc4fb4cccadf57506549fbdc7927cc466745193f
Signed-off-by: Oleksandr Martsyniuk <omartsyniuk@mirantis.com>
This commit is contained in:
Przemysław Szypowicz 2016-02-26 18:47:58 +01:00 committed by Oleksandr Martsyniuk
parent ce2b027806
commit e516245aa2
12 changed files with 289 additions and 16 deletions

View File

@ -12,8 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
notice('MODULAR: contrail/controller-dpdk.pp')
notice('MODULAR: contrail/contrail-compute-sriov.pp')
include contrail
class { 'contrail::controller::dpdk': }
class { 'contrail::compute::sriov': }

View File

@ -0,0 +1,19 @@
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
notice('MODULAR: contrail/controller-scheduler.pp')
include contrail
class { 'contrail::controller::scheduler': }

View File

@ -0,0 +1,31 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# This facter returns the version and build for the python-contrail package.
# It may be used to detect a version of contrail used in the environment.
require 'facter'
require 'puppet'
version = nil
pkg = Puppet::Type.type(:package).new(:name => 'libnl-3-200')
v = pkg.retrieve[pkg.property(:ensure)].to_s
version=v unless ["purged", "absent"].include?(v)
Facter.add("libnl_version") do
setcode do
version
end
end

View File

@ -0,0 +1,56 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
require 'yaml'
module Puppet::Parser::Functions
newfunction(:get_sriov_devices, :type => :rvalue, :doc => <<-EOS
Returns sriov capable devices
example:
get_sriov_devices()
EOS
) do |args|
bridge_interfaces = Array.new()
bond_interfaces = Array.new()
network_scheme = function_hiera_hash(['network_scheme', {}])
network_scheme['transformations'].each do |entry|
if entry.has_key?('bridge') and entry['action'] == "add-port"
bridge_interfaces.push(entry['name'])
end
if entry.has_key?('bond_properties') and entry['action'] == "add-bond"
bond_interfaces.push(*entry['interfaces'])
end
end
sriov_hash = Hash.new
Dir.foreach('/sys/class/net') do |network_interface|
next if network_interface == '.' or network_interface == '..'
network_interface_path = "/sys/class/net/" + network_interface
if (File.exists?(network_interface_path + "/device/sriov_totalvfs") and
not bridge_interfaces.include?(network_interface) and
not bond_interfaces.include?(network_interface))
sriov_hash[network_interface] = Hash.new
sriov_hash[network_interface]["totalvfs"] = IO.read(network_interface_path + "/device/sriov_totalvfs").to_i
sriov_hash[network_interface]["numvfs"] = IO.read(network_interface_path + "/device/sriov_numvfs").to_i
end
end
return sriov_hash
end
end

View File

@ -44,6 +44,11 @@ class contrail::compute::nova {
'CONTRAIL/use_userspace_vhost': value => true;
}
}
if $contrail::compute_sriov_enabled {
nova_config {
'DEFAULT/pci_passthrough_whitelist': value => $contrail::passthrough_whitelist;
}
}
Nova_config <||> ~>
service { 'nova-compute':
ensure => running,

View File

@ -0,0 +1,46 @@
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class contrail::compute::sriov {
if $contrail::compute_sriov_enabled {
Kernel_parameter {
provider => 'grub2',
}
kernel_parameter { 'intel_iommu':
ensure => present,
value => 'on',
}
kernel_parameter { 'iommu':
ensure => present,
value => 'pt',
}
create_resources(contrail::rclocal_vfs, $::contrail::sriov_hash)
file_line {"sriov ${title}":
ensure => absent,
path => '/etc/rc.local',
line => 'exit 0'
}
exec { 'reboot_require':
path => ['/bin', '/usr/bin'],
command => 'touch /tmp/contrail-reboot-require'
}
}
}

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
class contrail::controller::dpdk {
class contrail::controller::scheduler {
if $contrail::global_dpdk_enabled {
ini_subsetting {'add_aggregateinstanceextraspecsfilter':
@ -27,6 +27,19 @@ class contrail::controller::dpdk {
}
}
if $contrail::global_sriov_enabled {
ini_subsetting {'add_pci_passthrough_filter':
ensure => present,
section => 'DEFAULT',
key_val_separator => '=',
path => '/etc/nova/nova.conf',
setting => 'scheduler_default_filters',
subsetting => 'PciPassthroughFilter',
subsetting_separator => ',',
notify => Service['nova-scheduler'],
}
}
Ini_subsetting <||> ~>
service { 'nova-scheduler':
ensure => $ensure,

View File

@ -64,6 +64,14 @@ class contrail {
$hugepages_amount = pick($settings['hugepages_amount'],10)
$hugepages_number = floor($::memorysize_mb * $hugepages_amount / '100' / $hugepages_size)
# SRIOV settings
$global_sriov_enabled = $settings['contrail_global_sriov']
$compute_sriov_enabled = $global_sriov_enabled and 'sriov' in hiera_array('roles')
$sriov_physnet = $settings['sriov_physnet']
$sriov_hash = get_sriov_devices()
$passthrough_whitelist = inline_template(
'<%= "[" + scope.lookupvar("::contrail::sriov_hash").map{ |dev, _| "{\"devname\":\"#{dev}\", \"physical_network\":\"#{sriov_physnet}\"}" }.join(", ") + "]" %>')
# Custom mount point for contrail-db
$cassandra_path = '/var/lib/contrail_db'

View File

@ -0,0 +1,40 @@
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
define contrail::rclocal_vfs (
$totalvfs,
$numvfs,
$physnet = $::contrail::sriov_physnet,
$network_device = $title,
)
{
if (versioncmp($::libnl_version, '3.2.21-1') > 0) {
$final_vf = $::contrail::sriov_hash[$network_device]['totalvfs']
} else {
$final_vf = min(30, $::contrail::sriov_hash[$network_device]['totalvfs'])
}
file {"/etc/network/interfaces.d/ifcfg-${network_device}":
content => "auto ${network_device}\niface ${network_device} inet manual\n"
}
file_line {"sriov ${network_device}":
line => "echo ${final_vf} > /sys/class/net/${network_device}/device/sriov_numvfs",
path => '/etc/rc.local',
match => ".* /sys/class/net/${network_device}/device/sriov_numvfs"
}
}

View File

@ -87,6 +87,18 @@
strategy:
type: parallel
#
# Compute sriov feature
- id: sriov
type: group
role: [sriov]
tasks: []
required_for: [deploy_end]
requires: [deploy_start]
parameters:
strategy:
type: parallel
# Tasks
# Install Contrail utils, java
- id: contrail-utils
@ -301,6 +313,17 @@
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 120
# Congirures DPDK and SR-IOV filters in nova-scheduler
- id: controller-scheduler
type: puppet
role: [primary-controller, controller]
required_for: [post_deployment_end]
requires: [post_deployment_start]
parameters:
puppet_manifest: puppet/manifests/controller-scheduler.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 120
# Configuration for Neutron and Heat on Primary OpenStack Controller
- id: openstack-controller-contrail-primary
type: puppet
@ -334,17 +357,6 @@
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
# Congirures DPDK-filter scheduler
- id: controller-dpdk-scheduler
type: puppet
role: [primary-controller, controller]
required_for: [post_deployment_end]
requires: [post_deployment_start]
parameters:
puppet_manifest: puppet/manifests/controller-dpdk.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 120
# Workaround for #1550450
- id: enable_nova_compute_service
type: skipped
@ -371,6 +383,17 @@
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
# Configures sriov
- id: contrail-compute-sriov
type: puppet
role: [compute]
required_for: [post_deployment_end, contrail-compute-provision]
requires: [post_deployment_start]
parameters:
puppet_manifest: puppet/manifests/contrail-compute-sriov.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: contrail-compute-provision
type: puppet
role: [compute]

View File

@ -99,7 +99,28 @@ attributes:
description: "Override Qemu and Libvirt packages from contrail repository"
weight: 150
type: "checkbox"
restrictions:
- condition: "not (settings:contrail.metadata.enabled == true and settings:contrail.contrail_global_dpdk.value == true)"
action: "hide"
contrail_global_sriov:
value: false
label: "Enable SRIOV feature for this environment."
description: >
Enable this option to unlock the SRIOV feature.
NOTE: You still have to assign SRIOV-role to compute nodes to enable SRIOV on them.
weight: 210
type: "checkbox"
sriov_physnet:
value: 'physnet1'
label: 'Provide name for physical net'
description: >
This physical network will be provided over SRIOV capable interfaces.
weight: 220
type: 'text'
regex:
source: '^\w+$'
error: "Name has to be alphanumeric"
restrictions:
- action: hide
condition: not (settings:contrail.metadata.enabled == true and settings:contrail.contrail_global_dpdk.value == true)
condition: not (settings:contrail.contrail_global_sriov.value == true)

View File

@ -52,3 +52,15 @@ dpdk:
- ceph-osd
- cinder
sriov:
name: SRIOV compute
description: >
Enable SRIOV feature on compute node. NOTE: Use this role only together with Compute role to enable SRIOV feature in other cases it will not have any effect.
has_primary: false
public_ip_required: false
weight: 100
conflicts:
- controller
- contrail-db
- contrail-config
- contrail-control