VIX example

Version 2
    Task Name
    VIX sample workflows
    Description
    Prerequisites
    1. Tested on 4.1.0.3b
    CategoryWorkflow
    ComponentsvSphere 5.x
    User Inputs
    1. User ID
    2. Password
    3. VIX command
    Output

    Instructions for Regular Workflow Use:

    1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
    2. Unzip the file on your computer. Should end up with a .WFD file.
    3. Log in to UCS Director as a user that has "system-admin" privileges.
    4. Navigate to "Policies-->Orchestration" and click on "Import".
    5. Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
    6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
    7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
    8. Click "Submit".
    9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.

     

    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:

     

    Screen Shot 2015-03-19 at 5.51.33 PM.png

     

    Screen Shot 2015-03-19 at 12.03.54 PM.png

     

    Screen Shot 2015-03-19 at 1.00.51 PM.png