VMWare sdk stuff
Requirements: Install VMware-vsphere-cli
The following tools are used to remotely manage vmware instances.
You must install the VMware-vsphere-cli tools onto the system where you execute these tools from.
The tools rely on an authentication file in ~/.ssh called "vmware", with the following structure:
$HOME/.ssh/vmware
vmuser='wrk\username'
vmpsw='password'
vmserver='some-server-fqdn'
1 #! /bin/bash
2 # vi:set nu ai ap aw smd showmatch tabstop=4 shiftwidth=4:
3 # vmpoweroff fqdn
4 # Include path to location of vmware sdk tools
5 PATH=$PATH:/usr/lib/vmware-vcli/apps/vm
6 # include our credentials
7 . ${HOME}/.ssh/vmware
8 # poweroff the remote vhost
9 vmcontrol.pl \
10 ${vmuser:+--username $vmuser} \
11 ${vmpsw:+--password $vmpsw} \
12 --server $vmserver \
13 --operation poweroff \
14 --vmname ${1?Must declare virtual machine name}
1 #! /bin/bash
2 # vi:set nu ai ap aw smd showmatch tabstop=4 shiftwidth=4:
3 # vmpoweron fqdn
4 PATH=$PATH:/usr/lib/vmware-vcli/apps/vm
5 . ${HOME}/.ssh/vmware
6 vmcontrol.pl \
7 ${vmuser:+--username $vmuser} \
8 ${vmpsw:+--password $vmpsw} \
9 --server $vmserver \
10 --operation poweron \
11 --vmname ${1?Must declare virtual machine name}
1 #! /bin/bash
2 # vi:set nu ai ap aw smd showmatch tabstop=4 shiftwidth=4:
3 # vmshutdown fqdn
4 # will attempt a gracefull shutdown
5 PATH=$PATH:/usr/lib/vmware-vcli/apps/vm
6 . ${HOME}/.ssh/vmware
7 vmcontrol.pl \
8 ${vmuser:+--username $vmuser} \
9 ${vmpsw:+--password $vmpsw} \
10 --server $vmserver \
11 --operation shutdown \
12 --vmname ${1?Must declare virtual machine name}
1 #! /bin/bash
2 # vi:set nu ai ap aw smd showmatch tabstop=4 shiftwidth=4:
3 # vmreboot fqdn
4 PATH=$PATH:/usr/lib/vmware-vcli/apps/vm
5 . ${HOME}/.ssh/vmware
6 vmcontrol.pl \
7 ${vmuser:+--username $vmuser} \
8 ${vmpsw:+--password $vmpsw} \
9 --server $vmserver \
10 --operation reboot \
11 --vmname ${1?Must declare virtual machine name}
Example input.xml file that worked with vmcreate.pl
<?xml version="1.0"?> <Virtual-Machines> <Virtual-Machine> <Name>tomsand1</Name> <Host>rwesxc10b09.dc.fmcna.com</Host> <Datacenter>ha-datacenter</Datacenter> <Guest-Id>rhel6_64Guest</Guest-Id> <Datastore>RWINSRV01_SB_VMFS00</Datastore> <Disksize>4096</Disksize> <Memory>256</Memory> <Number-of-Processor>1</Number-of-Processor> <Nic-Network>VM HP-Production</Nic-Network> <Nic-Poweron>0</Nic-Poweron> </Virtual-Machine> </Virtual-Machines>
* Uploaded my feeble attempt to create a "portal" for creation of vmware nodes using php, not a php guru so please be gentle with me...hehe.