Add SR-IOV and IOMMU configuration check

Check if SR-IOV and IOMMU are properly configured for using in
virtual machines on compute nodes before trying to configure
SR-IOV in Nova.

Change-Id: Ide5dfc4779864442b0765e1101d67240398b2f18
Implements: blueprint support-sriov
This commit is contained in:
Aleksandr Didenko 2016-03-02 13:38:37 +01:00
parent 8804e54397
commit 055d795440
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,52 @@
#!/usr/bin/env ruby
#
# This script checks thats SR-IOV and IOMMU are properly configured
# for using in virtual machines.
#
# Example of network scheme with SR-IOV enabled NIC
#
# network_scheme:
# transformations:
# - action: add-port
# name: em1
# provider: sriov
require 'hiera'
ENV['LANG'] = 'C'
errors = 0
hiera = Hiera.new(:config => '/etc/hiera.yaml')
transformations = hiera.lookup(
'network_scheme', {}, {},
order_override = nil,
resolution_type = :hash
)['transformations']
unless transformations.is_a?(Array)
puts "ERROR: Network tranformations not found in Hiera"
exit 1
end
transformations.each do |t|
if t["action"] == "add-port" and t["provider"] == "sriov"
int = t["name"]
begin
if File.exist?("/sys/class/net/#{int}/device/sriov_totalvfs") and
File.readlink("/sys/class/net/#{int}/device/iommu_group") !=
File.readlink("/sys/class/net/#{int}/device/virtfn0/iommu_group") and
Dir["/sys/class/net/#{int}/device/virtfn0/iommu_group/devices/*:*"].length == 1
puts "OK: SR-IOV and IOMMU are properly configured for #{int} interface"
else
puts "ERROR: SR-IOV and IOMMU are not properly configured for #{int} interface"
errors += 1
end
rescue
puts "ERROR: Was not able to check SR-IOV and IOMMU for #{int} interface"
errors += 1
end
end
end
exit 1 unless errors == 0

View File

@ -27,6 +27,16 @@
timeout: 3600
cwd: /
- id: sriov_iommu_check
type: shell
version: 2.0.0
groups: [compute]
requires: [netconfig]
required_for: [firewall, hosts]
parameters:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/netconfig/sriov_iommu_check.rb
timeout: 30
- id: reserved_ports
type: puppet
version: 2.0.0