Last active
January 15, 2016 16:36
-
-
Save Vegasq/0c8298054c05a04eafe2 to your computer and use it in GitHub Desktop.
Execute command on openstack node thru fuel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# USAGE: | |
# eoc.sh <FUEL NODE> <COMMAND TO EXECUTE> <NODE TYPE> | |
# | |
# FUEL NODE: default 10.20.0.2 | |
# COMMAND: default uname -a | |
# NODE TYPE: default nova | |
# | |
# Mykola Yakovliev <[email protected]> | |
# 2016 | |
if [ -n "$1" ] | |
then | |
export FUEL_NODE=$1 | |
else | |
export FUEL_NODE="10.20.0.2" | |
fi | |
if [ -n "$2" ] | |
then | |
export COMMAND=$2 | |
else | |
export COMMAND="uname -a" | |
fi | |
if [ -n "$3" ] | |
then | |
export NODE_TYPE=$3 | |
else | |
export NODE_TYPE="nova" | |
fi | |
sshpass -p r00tme ssh root@$FUEL_NODE "fuel nodes | grep $NODE_TYPE | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])'" | head -1 > ip_address | |
sshpass -p r00tme ssh root@$FUEL_NODE "ssh $(cat ip_address) \"$COMMAND\"" > $FUEL_NODE.result | |
cat $FUEL_NODE.result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment