diff options
Diffstat (limited to 'scripts/lib.sh')
-rw-r--r-- | scripts/lib.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/lib.sh b/scripts/lib.sh index b825b9c..b3d9db3 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -7,9 +7,40 @@ hc_username=admin hc_password=admin hc_netconf_port=2831 NODE_PATTERN=overcloud +CONTROLLER_PATTERN=controller overcloudrc_path=/root/$overcloud_file_name overcloud_fds_repo_loc=/root overcloud_script_loc=$overcloud_fds_repo_loc/fds/scripts +IPV4_REGEX='([0-9]{1,3}.){3}[0-9]{1,3}' + +get_nodes() { + if [[ $1 ]] + then + NODES=$(grep -o "$NODE_PATTERN-$1-[0-9]" /etc/hosts) + else + NODES=$(grep -Eo "$NODE_PATTERN-[^-]+-[0-9]" /etc/hosts) + fi +} + +copy_to_controllers () { + get_nodes $CONTROLLER_PATTERN + LOCAL_FILE=$1 + REMOTE_LOC=$2 + for NODE in $NODES + do + scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $LOCAL_FILE $NODE:$REMOTE_LOC & + done + wait +} + +exec_on_controllers() { + get_nodes $CONTROLLER_PATTERN + for NODE in $NODES + do + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $NODE $@ & + done + wait +} in_array() { key=$1 |