08-01-2014 09:46 AM - edited 03-01-2019 06:30 AM
Task Name | VIX sample workflows |
Description | |
Prerequisites |
|
Category | Workflow |
Components | vSphere 5.x |
User Inputs |
|
Output |
Instructions for Regular Workflow Use:
Linux example script
================
#!/bin/sh
#
# script used by UCSD to change the hostname and IP of either a solaris
# or linux host.
#
# if 3 arguments are not passed to the script, exit
if [ $# != 3 ]; then
echo "usage: /vix.sh <ip> <netmask> <gateway>"
echo "arguments passed to vix.sh $1, $2, $3" > /vix.out
exit
fi
# set variables to change server identity
HOSTNAME=`hostname | awk -F. '{print $1}'`
IP=$1
NETMASK=$2
GATEWAY=$3
# set parsed out variables
LOCATION=`echo $HOSTNAME | cut -c1-4`
NETWORK=`echo $IP | awk -F. '{print $1"."$2"."$3".0"}'`
OS=`uname -s`
# configure DNS
if [ $LOCATION == "vacu" ]; then
echo "search nss.abc.com dce.isa.abc.com hosts.abc.com" > /etc/resolv.conf
echo "nameserver 10.80.18.21" >> /etc/resolv.conf
echo "nameserver 10.94.89.14" >> /etc/resolv.conf
echo "nameserver 10.36.115.31" >> /etc/resolv.conf
elif [ $LOCATION == "casc" ]; then
echo "search nss.abc.com dcw.isa.abc.com hosts.abc.com" > /etc/resolv.conf
echo "nameserver 10.25.136.41" >> /etc/resolv.conf
echo "nameserver 10.15.210.31" >> /etc/resolv.conf
echo "nameserver 10.14.8.34" >> /etc/resolv.conf
fi
if [ "$OS" == "SunOS" ]; then
# change crash directory name
rm -rf /var/crash/*
mkdir /var/crash/$HOSTNAME
chmod 700 /var/crash/$HOSTNAME
dumpadm -s /var/crash/$HOSTNAME
# change hostname in /etc/hosts
#echo "#" > /etc/hosts
#echo "# Internet host table" >> /etc/hosts
#echo "#" >> /etc/hosts
#echo "::1 localhost" >> /etc/hosts
#echo "127.0.0.1 localhost" >> /etc/hosts
#echo "$IP ${HOSTNAME}.nss.abc.com $HOSTNAME" >> /etc/hosts
sed '/192.168.254/d' /etc/hosts > /tmp/hosts
cp /tmp/hosts /etc/hosts
echo "$IP ${HOSTNAME}.nss.abc.com $HOSTNAME" >> /etc/hosts
# change nodename
echo $HOSTNAME > /etc/nodename
# change interface
echo $HOSTNAME > /etc/hostname.e1000g0
# change netmask
grep '^#' /etc/netmasks > /tmp/netmasks
cp /tmp/netmasks /etc/netmasks
echo "$NETWORK $NETMASK" >> /etc/netmasks
# change gateway
echo $GATEWAY > /etc/defaultrouter
# clean up
rm -rf /.ssh/*
rm -rf /.bash_history
else
# change hostname in /etc/hosts
#echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4" > /etc/hosts
#echo "::1 localhost localhost.localdomain localhost6 localhost6.localdomain6" >> /etc/hosts
#echo "$IP ${HOSTNAME}.nss.abc.com $HOSTNAME" >> /etc/hosts
sed -i '/192.168.254/d' /etc/hosts
echo "$IP ${HOSTNAME}.nss.abc.com $HOSTNAME" >> /etc/hosts
# add hostname to /etc/sysconfig/network
#echo "NETWORKING=yes" > /etc/sysconfig/network
#echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network
# build /etc/sysconfig/network-scripts/ifcfg-eth0
echo "DEVICE=eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0
echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "BOOTPROTO=static" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "IPADDR=$IP" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "NETMASK=$NETMASK" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "GATEWAY=$GATEWAY" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "ETHTOOL_OPTS=\"autoneg on\"" >> /etc/sysconfig/network-scripts/ifcfg-eth0
chmod 644 /etc/sysconfig/network-scripts/ifcfg-eth0
# remove persistent udev
rm -rf /etc/udev/rules.d/70-persistent-net.rules
fi
# remove DO-NOT-RUN.sh script used to wipe host
rm -rf /DO-NOT-RUN.sh
# reboot VM
# init 6
The following is the windows cmd file.
This is copy to notepad and saved as c:\vix.cmd
=======================
echo "%1 %2 %3" > c:\vix.out
c:\\Windows\\System32\\netsh.exe interface set interface name="Local Area Connection" newname="%1"
c:\\Windows\\System32\\netsh.exe interface ip set address "%1" static %1 %2 %3
Examples:
I couldn't find vix.cmd and a.sh files
Where is the link?
--
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: