Skip to content
Snippets Groups Projects
Commit 9804256a authored by Chris Hines's avatar Chris Hines
Browse files

removing comments and unused scripts from th emellanxo and lsutre roles

parent fb4e9459
No related branches found
No related tags found
1 merge request!32Simons updates
#! /bin/bash
#
#modified by simon to print device name
#
usage()
{
echo "$(basename $0) <options>"
echo "-h, --help print help message"
echo "-v, --verbose print more info"
}
function find_pdev()
{
pdevlist=$(ls /sys/bus/pci/devices)
for pdev in $pdevlist; do
if [ -d /sys/bus/pci/devices/$pdev/infiniband ]; then
ibd=$(ls /sys/bus/pci/devices/$pdev/infiniband/)
if [ "x$ibd" == "x$1" ]; then
echo -n $pdev
fi
fi
done
}
case $1 in
"-h" | "--help")
usage
exit 0
;;
esac
if (( $# > 1 )); then
usage
exit -1
fi
if (( $# == 1 )) && [ "$1" != "-v" ]; then
usage
exit -1
fi
ibdevs=$(ls /sys/class/infiniband/)
devs=
for netpath in /sys/class/net/*
do
if (grep 0x15b3 ${netpath}/device/vendor > /dev/null 2>&1); then
devs="$devs ${netpath##*/}"
fi
done
if [ "x$devs" == "x" ]; then
# no relevant devices - quit immediately
exit
fi
for d in $devs; do
if [ -f /sys/class/net/$d/dev_id ]; then
oldstyle=n
break
fi
done
if [ "x$oldstyle" == "xn" ]; then
for d in $ibdevs; do
ibrsc=$(cat /sys/class/infiniband/$d/device/resource)
eths=$(ls /sys/class/net/)
for eth in $eths; do
filepath_resource=/sys/class/net/$eth/device/resource
if [ -f $filepath_resource ]; then
ethrsc=$(cat $filepath_resource)
if [ "x$ethrsc" == "x$ibrsc" ]; then
filepath_devid=/sys/class/net/$eth/dev_id
filepath_devport=/sys/class/net/$eth/dev_port
if [ -f $filepath_devid ]; then
port1=0
if [ -f $filepath_devport ]; then
port1=$(cat $filepath_devport)
port1=$(printf "%d" $port1)
fi
port=$(cat $filepath_devid)
port=$(printf "%d" $port)
if [ $port1 -gt $port ]; then
port=$port1
fi
port=$(( port + 1 ))
filepath_carrier=/sys/class/net/$eth/carrier
if [ -f $filepath_carrier ]; then
link_state=$(cat $filepath_carrier 2> /dev/null)
if (( link_state == 1 )); then
link_state="Up"
else
link_state="Down"
fi
else
link_state="NA"
fi
x=$(find_pdev $d)
if [ "$1" == "-v" ]; then
filepath_portstate=/sys/class/infiniband/$d/ports/$port/state
filepath_deviceid=/sys/class/infiniband/$d/device/device
filepath_fwver=/sys/class/infiniband/$d/fw_ver
filepath_vpd=/sys/class/infiniband/$d/device/vpd
# read port state
if [ -f $filepath_portstate ]; then
ibstate=$(printf "%-6s" $(cat $filepath_portstate | gawk '{print $2}'))
else
ibstate="NA"
fi
# read device
if [ -f $filepath_deviceid ]; then
devid=$(printf "MT%d" $(cat $filepath_deviceid))
else
devid="NA"
fi
# read FW version
if [ -f $filepath_fwver ]; then
fwver=$(cat $filepath_fwver)
else
fwver="NA"
fi
# read device description and part ID from the VPD
if [ -f $filepath_vpd ]; then
tmp=$IFS
IFS=":"
vpd_content=`cat $filepath_vpd`
devdesc=$(printf "%-15s" $(echo $vpd_content | strings | head -1))
partid=$(printf "%-11s" $(echo $vpd_content | strings | head -4 | tail -1 | gawk '{print $1}'))
IFS=$tmp
else
devdesc=""
partid="NA"
fi
#echo "$x $d ($devid - $partid) $devdesc fw $fwver port $port ($ibstate) ==> $eth ($link_state)"
echo -n "$eth"
else
echo -n "$eth"
#echo "$d port $port ==> $eth ($link_state)"
fi
fi
fi
fi
done
done
else
##########################
### old style
##########################
function print_line()
{
echo -n "$eth"
# echo "$1 port $2 <===> $3"
}
function find_guid()
{
ibdevs=$(ls /sys/class/infiniband/)
for ibdev in $ibdevs; do
ports=$(ls /sys/class/infiniband/$ibdev/ports/)
for port in $ports; do
gids=$(ls /sys/class/infiniband/$ibdev/ports/$port/gids)
for gid in $gids; do
pguid=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 21- | sed -e 's/://g')
if [ x$pguid == x$1 ]; then
print_line $ibdev $port $2
fi
done
done
done
}
function find_mac()
{
ibdevs=$(ls /sys/class/infiniband/)
for ibdev in $ibdevs; do
ports=$(ls /sys/class/infiniband/$ibdev/ports/)
for port in $ports; do
gids=$(ls /sys/class/infiniband/$ibdev/ports/$port/gids)
for gid in $gids; do
first=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 21-22)
first=$(( first ^ 2 ))
first=$(printf "%02x" $first)
second=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 21- | sed -e 's/://g' | cut -b 3-6)
third=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 21- | sed -e 's/://g' | cut -b 11-)
pmac=$first$second$third
if [ x$pmac == x$1 ]; then
print_line $ibdev $port $2
fi
done
done
done
}
ifcs=$(ifconfig -a | egrep '^eth|^ib' | gawk '{print $1}')
for ifc in $ifcs; do
len=$(cat /sys/class/net/$ifc/addr_len)
if (( len == 20 )); then
guid=$(cat /sys/class/net/$ifc/address | cut -b 37- | sed -e 's/://g')
find_guid $guid $ifc
elif (( len == 6)); then
mac=$(cat /sys/class/net/$ifc/address | sed -e 's/://g')
find_mac $mac $ifc
fi
done
fi
...@@ -13,17 +13,11 @@ ...@@ -13,17 +13,11 @@
# with_items: "{{ lustre_pkgs }}" # with_items: "{{ lustre_pkgs }}"
- name: install rpms - name: install rpms
# we now have a new kernel version
#yum: name=/tmp/lustre-client-modules-2.7.0-3.10.0_229.14.1.el7.x86_64.x86_64.rpm
#yum: name=/tmp/lustre-client-modules-2.7.0-3.10.0_229.20.1.el7.x86_64.x86_64.rpm
yum: name=/tmp/lustre-client-modules-2.7.65-3.10.0_327.4.4.el7.x86_64_gab38c3a.x86_64.rpm yum: name=/tmp/lustre-client-modules-2.7.65-3.10.0_327.4.4.el7.x86_64_gab38c3a.x86_64.rpm
sudo: true sudo: true
when: ansible_os_family == "RedHat" when: ansible_os_family == "RedHat"
- name: install rpms - name: install rpms
# we now have a new kernel version
#yum: name=/tmp/lustre-client-2.7.0-3.10.0_229.14.1.el7.x86_64.x86_64.rpm
#yum: name=/tmp/lustre-client-2.7.0-3.10.0_229.20.1.el7.x86_64.x86_64.rpm
yum: name=/tmp/lustre-client-2.7.65-3.10.0_327.4.4.el7.x86_64_gab38c3a.x86_64.rpm yum: name=/tmp/lustre-client-2.7.65-3.10.0_327.4.4.el7.x86_64_gab38c3a.x86_64.rpm
sudo: true sudo: true
when: ansible_os_family == "RedHat" when: ansible_os_family == "RedHat"
...@@ -46,17 +40,6 @@ ...@@ -46,17 +40,6 @@
# vi debian/changelog (the version number on the first line is incorrect) instead of 2.7.50-1 it should be 2.7.62 .... this may not be true depending on what commit you checked out # vi debian/changelog (the version number on the first line is incorrect) instead of 2.7.50-1 it should be 2.7.62 .... this may not be true depending on what commit you checked out
# make debs # make debs
# #
#- linux-patch-lustre_2.7.62-1_all.deb
# - lustre-client-modules-3.13.0-58-generic_2.7.62-1_amd64.deb
# - lustre-utils_2.7.62-1_amd64.deb
#
# LOOPS DO NOT WORK WITH YUM OR APT IN ANSIBLE
#- name: install debs from /tmp
# apt: name="/tmp/{{ item }}"
# #apt: deb="/tmp/{{ item }}"
# sudo: true
# with_items: "{{ lustre_pkgs }}"
# when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "14"
- name: install linux-patch-lustre_2.7.62-1_all.deb - name: install linux-patch-lustre_2.7.62-1_all.deb
......
#!/bin/sh
# A CRUDE Script to install Mellanox OFED drivers
# Philip.Chan@monash.edu
#
# TODO: check if MLNX_OFED is already installed!
# TODO: check kernel...
KERN=`uname -r`
if [ "$KERN" != "3.10.0-229.14.1.el7.x86_64" ]
then
echo "Oops! Did you forget to reboot?"
echo "Kernel version has to be 3.10.0-229.14.1.el7.x86_64"
exit 1
fi
sudo yum install -y pciutils gcc-gfortran libxml2-python tcsh libnl lsof tcl tk perl
sudo yum install -y gtk2 atk cairo
tar xzvf MLNX_OFED_LINUX-3.1-1.0.3-rhel7.1-x86_64-ext.tgz
cd MLNX_OFED_LINUX-3.1-1.0.3-rhel7.1-x86_64-ext
sudo ./mlnxofedinstall -q
cd ..
tmpfile="/tmp/ifcfg.pc"
rm -f $tmpfile
./set_ifcfg.pl $tmpfile
if [ -f $tmpfile ]
then
echo "Attempting to install ifcfg-ens6"
if [ -f /etc/sysconfig/network-scripts/ifcfg-ens6 ]
then
echo "/etc/sysconfig/network-scripts/ifcfg-ens6 already exists!"
grep IP /etc/sysconfig/network-scripts/ifcfg-ens6
echo "bailing!"
else
sudo cp -ip $tmpfile /etc/sysconfig/network-scripts/ifcfg-ens6
sudo chown root:root /etc/sysconfig/network-scripts/ifcfg-ens6
cd /etc/sysconfig/network-scripts
sudo ./ifup ens6
ping -c 1 172.16.228.1
fi
fi
exit 0
#!/usr/bin/perl
#
# Assumes Mellanox NIC is named as ens6
# Philip.Chan@monash.edu
#
# Usage:
# ./set_ifcfg.pl [<tmpfilename>]
# To be used within the mlnx_install.sh
# #
# #
# DO NOT USE. ANACHRONISTIC. HISTORICAL INTERESET ONLY
# #
# #
#
my $outfile = shift @ARGV;
$outfile = "tmp.ifcfg" if (! defined $outfile);
sub get_index
{
my $hn = shift;
my $maxhosts = 32;
if ($hn =~ /hc(\d+)/) {
return 33 + $1 if ($1 < $maxhosts);
}
if ($hn =~ /hs(\d+)/) {
return 1 + $1 if ($1 < $maxhosts);
}
return 0;
}
my $hostname = `/bin/hostname`;
my $x = get_index($hostname);
die "Unable to parse hostname $hostname" if ($x eq '0');
my $ip = "172.16.229.$x";
print "Assigning $ip to $hostname\n";
open OUT, ">$outfile" or die "Failed to create output file $outfile!";
print OUT "DEVICE=ens6\n";
print OUT "ONBOOT=yes\n";
print OUT "NM_CONTROLLED=no\n";
print OUT "BOOTPROTO=none\n";
print OUT "IPADDR=$ip\n";
print OUT "PREFIX=22\n";
print OUT "MTU=9000\n";
close OUT;
exit 0;
...@@ -71,11 +71,6 @@ ...@@ -71,11 +71,6 @@
register: MELLANOX_DEVICE_NAME register: MELLANOX_DEVICE_NAME
sudo: true sudo: true
#- debug: msg="The MELLANOX_DEVICE_NAME is {{ MELLANOX_DEVICE_NAME }} "
# #"
# - debug: msg="The MELLANOX_DEVICE_NAME.stdout is {{ MELLANOX_DEVICE_NAME.stdout }} "
# #"
- name: create /etc/sysconfig/network-scripts/ifcfg-<device name> - name: create /etc/sysconfig/network-scripts/ifcfg-<device name>
template: dest=/etc/sysconfig/network-scripts/ifcfg-{{ MELLANOX_DEVICE_NAME.stdout }} src=ifcfg-conf.j2 owner=root group=root template: dest=/etc/sysconfig/network-scripts/ifcfg-{{ MELLANOX_DEVICE_NAME.stdout }} src=ifcfg-conf.j2 owner=root group=root
sudo: true sudo: true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment