Showing posts with label automation. Show all posts
Showing posts with label automation. Show all posts

Tuesday, September 15, 2015

Automation for - perennially-reserved=true

My friend Vinod Balakrishnan  & I worked on automation for perennially-reserved please see the details below.



A.) Create file with name list and save all "lun" id into it.  Create list based on clusters and luns specific to those clusters.

===========================================================================================

B.) CHECK IF All LUNS ARE PRESENT. rUN THIS ON SPECIFIC CLUSTERS AND LUN LIST

cat list | while read line
do
if ! esxcli storage core path list | grep "LUN: $line" >/dev/null
then
echo "Rahim LUN $line IS MISSING"
fi
done

===========================================================================================


C.) RUN THIS COMMAND TO SET RESV ON LISTED LUNS IN FILE list on the respective Clusters/ESXI hosts.

cat list | while read line
do
naa=`esxcli storage core path list | egrep -B5 "LUN: $line"  | grep "Device:"  | head -1`
echo $naa
esxcli storage core device setconfig -d "$naa" --perennially-reserved=true
done

============================================================================================


D.) Check if resv has been set on specified luns or not

TO CHECK IF PERENNIAL RESERVATION HAS BEEN SET ON WHICH NAA

esxcli storage core device list | egrep -B18 "Is Perennially Reserved: true" | grep " Device:"  | awk '{print $NF}' | while read line
do
 lunid=`esxcli storage core path list | egrep -A6 "$line" | grep -i lun | head -1`
 echo "$line $lunid"
done


cat list | while read line
do
if ! esxcli storage core path list | grep "LUN: $line" >/dev/null
then
echo "Rahim LUN $line IS MISSING"
fi
done

==============================================================================================

Wednesday, July 8, 2015

VMware tools install from command line.

Installation of VMware tool with GUI is very very painful process with slow mouse movement & keyboard long key press... and if you are connected to the environment from VPN with slow connection you are dead. :-)

to overcome this issue best way to run only 2 commands get the VMware tools installed.

1) To Mount the VMware tools ISO to VM with with VMware powercli

a) open power CLI

b) run the command 
connect-viserver VCENTER_NAME

c) run the below command
Mount-Tools [[-Guest] <VMGuest[]>] [<CommonParameters>] 
Mount-Tools [[-VM] <VirtualMachine[]>] [[-Server] <VIServer[]>] [<CommonParameters>]
Example: Mount-Tool -VM Rahim_VM1

Note: this will require the interactive installation of VMware tools inside of VM (Windows /Linux)

2) To start the installation of VMware in windows machine you can run one single command with command line, it will install the VMware tools on VM silently & reboot the server.
For 64bit system: 
D:\Setup64.exe /S /V"/qn

For 32 bit system;
D:\Setup.exe /S /V"/qn


Wthis 2 small command you can automate the instillation of VMware tools on multiple VM.

Put you thought in comments.

Stopping & Starting firewall with command: Automation

After long time writing post.

Toady found very good automation which can help you start & stop firewall with some small commands.

its very useful for creating script / automation for windows customization 

To check the status of firewall
Netsh Advfirewall show allprofiles

To turn of firewall
NetSh Advfirewall set allprofiles state off

To Turn On firewall
NetSh Advfirewall set allrprofiles state on

to run this command make sure you have enough permission like admin account access on server / workstation.