Adding virtual port renaming in case of iSER

Due to RDMA requirement, storage port is changed to a virtual
port on the hypervisor in case of choosing iSER.

The virtual port is renamed to a predefined name that has
already been serialized to astute.yaml network scheme.

This change includes:
  1. Adding a call to a the bash script from stage zero in site.pp
     OS_common class, in case of choosing iSER.
  2. Adding a template of the bash script to a new empty puppet module
     that will include Mellanox manifests.
  3. Adding iser_rename manifest to call the bash script in stage zero.

partially implements: blueprint mellanox-features-support

Change-Id: I2828427e096245408fa536904ea9cece39256ef0
Signed-off-by: Aviram Bar-Haim <aviramb@mellanox.com>
This commit is contained in:
Aviram Bar-Haim
2014-07-02 22:14:29 +03:00
parent 07e41e888f
commit c334bf2a14
7 changed files with 159 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
name 'mellanox-mellanox_openstack'
version '1.0.0'
author 'mellanox'
license 'Apache License, Version 2.0'
summary 'Mellanox module for Mirantis Fuel Openstack deployment'
description 'This is a Puppet module to install Mellanox Openstack components over Mirantis Fuel'

View File

@@ -0,0 +1,2 @@
class mellanox_openstack {
}

View File

@@ -0,0 +1,28 @@
class mellanox_openstack::iser_rename ($storage_parent, $iser_interface_name){
$interfaces_path = '/sys/class/net/'
$iser_script_dir = '/opt/iser'
$iser_rename_script = "$iser_script_dir/iser_rename.sh"
file { $iser_script_dir:
ensure => directory,
}
file { $iser_rename_script:
ensure => file,
owner => 'root',
group => 'root',
mode => '500',
content => template('mellanox_openstack/iser_rename.erb'),
}
exec { 'iser_rename':
command => "bash $iser_rename_script",
unless => "test -f $interfaces_path/$iser_interface_name",
path => ['/usr/bin','/usr/sbin','/bin','/sbin','/usr/local/bin'],
logoutput => true,
require => File[$iser_rename_script],
}
}

View File

@@ -0,0 +1,17 @@
dir = File.expand_path(File.dirname(__FILE__))
$LOAD_PATH.unshift File.join(dir, 'lib')
require 'mocha'
require 'puppet'
require 'rspec'
require 'spec/autorun'
Spec::Runner.configure do |config|
config.mock_with :mocha
end
# We need this because the RAL uses 'should' as a method. This
# allows us the same behaviour but with a different method name.
class Object
alias :must :should
end

View File

@@ -0,0 +1,87 @@
#!/usr/bin/bash
# Constants
readonly SCOPE=`basename $0`
readonly UDEV_FILE='/etc/udev/rules.d/70-persistent-net.rules'
readonly SUCCESS=0
readonly FAILURE=1
# Variables
STORAGE_PORT='<%=@storage_parent%>'
ISER_NAME='<%=@iser_interface_name%>'
FATHER_FIRST_VF="/sys/class/net/$STORAGE_PORT/device/virtfn0"
# This functions print logs to /var/log/messages
function logger_print () {
priority=$1
msg=$2
logger -t $SCOPE "$priority: $msg"
}
# Check that a first probe VF exists
if [ ! -d $FATHER_FIRST_VF ]; then
logger_print err "Did not find probed ports of ${STORAGE_PORT}, skipping rename."
exit $FAILURE
fi
DEVICES='/sys/class/net/*/device'
SON_BUS=`basename $(readlink /sys/class/net/$STORAGE_PORT/device/virtfn0)`
STORAGE_PORT_NUMBER=`cat /sys/class/net/$STORAGE_PORT/dev_id`
# Find the probe VF port that fits the storage ports number and BUS
for dev in $DEVICES; do
# Check for correct bus
CANDIDATE_BUS=`readlink -nq $dev`;
if [[ $CANDIDATE_BUS != *$SON_BUS* ]]; then
continue;
fi
# Check for correct dev_id
CANDIDATE_DIRNAME=`dirname $dev`
PORT_NUMBER=`cat $CANDIDATE_DIRNAME/dev_id`
if [ $PORT_NUMBER = $STORAGE_PORT_NUMBER ]; then
PROBED_DIRNAME=`dirname $dev`
PROBED_PORT_NAME=`basename $PROBED_DIRNAME`
fi
done
# Verify that we find the appropriate virtual port
if [ -z "$PROBED_PORT_NAME" ]; then
logger_print err "Did not find $STORAGE_PORT_NUMBER probed ports of $STORAGE_PORT, exiting."
exit $FAILURE
fi
# Verify that udev file exists
if [ ! -r "$UDEV_FILE" ]; then
logger_print err "Did not find $UDEV_FILE to rename iser port."
exit $FAILURE
fi
# Persistantly rename the matched probed port
if [ $PROBED_PORT_NAME != $ISER_NAME ]; then
#Prepare line for udev
UDEV_LINE="SUBSYSTEM==\"net\", ACTION==\"add\", "
UDEV_LINE+="ATTR{dev_id}==\"$STORAGE_PORT_NUMBER\", KERNELS==\"$SON_BUS\", "
UDEV_LINE+="ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"$ISER_NAME\""
# Change/add line in udev file
grep $PROBED_PORT_NAME $UDEV_FILE > /dev/null 2>&1
if [ $? -eq $SUCCESS ]; then
OLD_LINE_NUMBER=`grep -n $PROBED_PORT_NAME $UDEV_FILE | cut -d : -f 1`
eval "sed '"$OLD_LINE_NUMBER"d' -i $UDEV_FILE"
fi
echo $UDEV_LINE >> $UDEV_FILE
# Restart Mellanox drivers
/etc/init.d/openibd restart
if [ $? -ne $SUCCESS ]; then
logger_print err "Mellanox drivers restart failed."
exit $FAILURE
fi
logger_print info "Changed probed port name from $PROBED_PORT_NAME to $ISER_NAME."
else
logger_print info "Probed port name is configured properly to $ISER_NAME."
fi
exit $SUCCESS

View File

@@ -0,0 +1,12 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation
# errors and view a log of events) or by fully applying the test in a virtual
# environment (to compare the resulting system state to the desired state).
#
# Learn more about module testing here:
# http://docs.puppetlabs.com/guides/tests_smoke.html
#
include mellanox_openstack

View File

@@ -145,6 +145,13 @@ case $::operatingsystem {
}
class os_common {
if ($::fuel_settings['neutron_mellanox']) and ($::fuel_settings['storage']['iser']) {
class { 'mellanox_openstack::iser_rename':
stage => 'zero',
storage_parent => $::fuel_settings['neutron_mellanox']['storage_parent'],
iser_interface_name => $::fuel_settings['neutron_mellanox']['iser_interface_name'],
}
}
class {"l23network::hosts_file": stage => 'netconfig', nodes => $nodes_hash }
class {'l23network': use_ovs=>$use_quantum, stage=> 'netconfig'}
if $use_quantum {