Enhanced create_mellanox_bootstrap script

Added arg parser, changed script name and removed adding intel_iommu
parameter as plugin forces user to add it now.

Change-Id: I4a15ca4a67290ebdb764cedc543ca2afe8f158af
This commit is contained in:
Rawan Herzallah 2016-05-03 06:38:41 +00:00
parent 467a479d4d
commit fcef114eb5
4 changed files with 34 additions and 40 deletions

View File

@ -5,7 +5,7 @@ name: mellanox-plugin
title: Mellanox ConnectX-4 Openstack Features
# Plugin version
version: 3.1.1
version: 3.1.4
# Description
description: Enable features over Mellanox ConnectX-4 Adapters

View File

@ -7,12 +7,12 @@ if [ -d $FUEL_BOOTSTRAP_DIR ]; then
# Add bootstrap scripts to Fuel Master
\cp $PLUGIN_SCRIPTS_DIR/reboot_bootstrap_nodes \
$PLUGIN_SCRIPTS_DIR/create_mellanox_vpi_bootstrap \
$PLUGIN_SCRIPTS_DIR/create_mellanox_bootstrap \
/sbin/
# Print post install message
echo " `tput bold`In order to create Bootstrap discovery image for detecting Mellanox Infiniband HW:"
echo " 1. Please build a new bootstrap ('create_mellanox_vpi_bootstrap can be used')."
echo " 1. Please build a new bootstrap ('create_mellanox_bootstrap [--link_type] [-h, --help] can be used')."
echo " 2. Please reboot your old bootstrap nodes"
echo " ('reboot_bootstrap_nodes [-e environment_id] [-a] [-h]' can be used).`tput sgr0`"

View File

@ -19,26 +19,30 @@ import os
import time
import subprocess
import sys
import argparse
import textwrap
# Verify input
if len(sys.argv) > 1 and (sys.argv[1] == 'eth' or sys.argv[1] == 'ib' or \
sys.argv[1] == 'default_link_type' ):
if 'default_link_type' in sys.argv[1]:
link_type = 'eth'
else:
link_type = "_%s" % sys.argv[1]
elif len(sys.argv) == 1:
link_type = ""
parser = argparse.ArgumentParser(
prog='PROG',
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent('''\
Available link_type values are:
-------------------------------
- eth for changing link type to Ethernet
- ib for changing link type to Infiniband
- current for leaving link type as is
'''))
parser.add_argument("--link_type", choices=['eth', 'ib', 'current'])
args = parser.parse_args()
if not args.link_type:
parser.print_help()
sys.exit(1)
else:
basename = os.path.basename(sys.argv[0])
print "Wrong usage."
print "Usage: %s <link_type>" % basename
print " Valid link type: eth,ib"
print " option 1: %s" % basename
print " option 2: %s eth" % basename
print " option 3: %s ib" % basename
print " option 4: %s default_link_type" % basename
exit(1)
if 'current' in args.link_type:
link_type=""
else:
link_type = "_{0}".format(args.link_type)
# Set variables
plugin = subprocess.Popen("echo /var/www/nailgun/plugins/mellanox-plugin-*/ " +
@ -61,16 +65,7 @@ with open("/etc/fuel-bootstrap-cli/fuel_bootstrap_cli.yaml", 'r') as stream:
'section': None,
'type': 'deb',
'uri': plugin_uri})
override = True
# Verify SR-IOV capabilities
if 'intel_iommu=on' not in fuel_bootstrap_config['extend_kopts']:
fuel_bootstrap_config['extend_kopts'] = fuel_bootstrap_config['extend_kopts'] \
+ ' intel_iommu=on'
override = True
# Override fuel bootstrap yaml if needed
if override:
# Override fuel bootstrap yaml
with open("/etc/fuel-bootstrap-cli/fuel_bootstrap_cli.yaml", "w") as f:
yaml.dump(fuel_bootstrap_config, f)

View File

@ -1,3 +1,5 @@
EXTRA_SCRIPTS="/sbin/reboot_bootstrap_node
/sbin/create_mellanox_bootstrap"
# Verify run is over Fuel Master and we are not During upgrade
if [ -d $FUEL_BOOTSTRAP_DIR ] && [ $1 -eq 0 ]; then
@ -16,13 +18,10 @@ if [ -d $FUEL_BOOTSTRAP_DIR ] && [ $1 -eq 0 ]; then
mv $ORIG_BOOTSTRAP_CLI_YAML $BOOTSTRAP_CLI_YAML
fi
# Remove extra scripts
if [ -f "/sbin/reboot_bootstrap_nodes" ]; then
\rm /sbin/reboot_bootstrap_nodes
fi
if [ -f "/sbin/create_mellanox_vpi_bootstrap" ]; then
\rm /sbin/create_mellanox_vpi_bootstrap
fi
for script in $EXTRA_SCRIPTS; do
# Remove extra scripts
if [ -e $script ]; then
\rm $script
fi
done
fi