Last active
November 1, 2017 19:27
-
-
Save cvrolf/d8dd2ffa6df77dfff559fb66b5d217c0 to your computer and use it in GitHub Desktop.
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
#@RunAs: Open a Terminal with user root @ Master Machine***** | |
### | |
### Bash Shell behavior | |
# @doc -e Exit immediately if a command returns a non-zero status. | |
# @doc -u Treat unset variables and parameters other than the special parameters ‘@’ or ‘*’ as an error when performing parameter expansion. | |
# @doc -x Print a trace of commands after they are expanded and before they are executed. | |
set -u | |
set -x | |
### | |
### Global vars | |
MYDOMAIN="myvmtest" | |
MYIPADDRESS=192.168.122.102 | |
MYMACADDRESS=52:54:00:ff:ff:66 | |
### | |
### Check you are on the correct host: Host Machine (not the VM) | |
hostname | |
whoami | |
if [ "`hostname`" == "${MYDOMAIN}" ]; then | |
echo "ABORT. This is not a session on the Host Machine" | |
sleep 10 | |
exit 1 | |
else | |
echo "OK. This is a session on the Host Machine" | |
fi | |
### | |
### Start VM (make sure it is active) | |
virsh shutdown --domain ${MYDOMAIN} | |
virsh shutdown --domain ${MYDOMAIN} | |
sleep 10 | |
virsh start --domain ${MYDOMAIN} | |
sleep 10 | |
### | |
### Verify the new static IP Address for the Guest VM | |
virsh list --all | |
virsh domifaddr ${MYDOMAIN} | |
if ! ping -c2 ${MYIPADDRESS}; then | |
echo "ERROR. Cannot ping IPV4 address ${MYIPADDRESS}" | |
else | |
echo "OK. Ping IPV4 address ${MYIPADDRESS}" | |
fi | |
if ! ping -c2 ${MYDOMAIN}; then | |
echo "ERROR. Cannot ping DNS Name ${MYDOMAIN}" | |
else | |
echo "OK. Ping DNS Name ${MYDOMAIN}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment