But how long would it take to add another portgroup to a vSwitch with a VLAN ID for 20 ESX servers? Quite long, if you have the time or the patience then thats fine, but I'd rather script something like that.
By using the VMware RCLI (Remote Client) you can send vicfg- (esxcfg) commands to both ESX 3.5 and ESXi hosts. Originally it was intended for use with ESXi due to it having limited service console but the functionality is also provided for ESX 3.5 hosts.
The VMware Infrastructure Remote CLI provides a command-line interface for datacenter management from a remote server. This interface is fully supported on VMware ESXi 3.5 and experimental for VMware ESX 3.5. Storage VMotion is a feature that lets you migrate a virtual machine from one datastore to another. It is used by executing the svmotion command from the Remote CLI. The svmotion command, unlike other RCLI commands, is fully supported for VMware ESX 3.5.
I use the RCLI with SSH access enabled, so now my RCLI acts as a service console proxy server. To send an esxcfg- command to an ESX 3.5 host, I would now log into the RCLI using SSH and then send the commands from the RCLI's command line, or execute a .sh script on the RCLI.
So let's use our example above.... to add another portgroup to vSwitch1, with a VLAN ID of 123 onto 20 ESX 3.5 hosts.
- Log into the RCLI using SSH
- the command line command is very similar to esxcfg- but we use vicfg- instead
- vicfg-vswitch --add-pg=VLAN123 vSwitch1 --server=
--username=root --password= - Now you can either repeat the above for all 20 servers or script it into a shell script..
- Create a new script on the RCLI called addportgroup.sh
#Script to add portgroup with vlad id of 123 to vSwitch1 onto all ESX 3.5 hosts
# Assign port groups to vSwitch1
vicfg-vswitch --add-pg=VLAN123 vSwitch1 --server=
vicfg-vswitch --add-pg=VLAN123 vSwitch1 --server=
vicfg-vswitch --add-pg=VLAN123 vSwitch1 --server=
#Assign vlan ids to port groups
vicfg-vswitch -v 123 -p VLAN123 vSwitch1 --server=
vicfg-vswitch -v 123 -p VLAN123 vSwitch1 --server=
vicfg-vswitch -v 123 -p VLAN123 vSwitch1 --server=
Now save, make the script executable and then launch it, and the script will create the new portgroups on all the servers in a couple of seconds.
3 comments:
I dont see a v* command to shut down an (or many :) ESXi host(s), in case of power outage ?
No there isn't one. vicfg- commands are for configuring ESX hosts, but if you have SSH open then you could write a script that shuts down all hosts in the script? A bit dangerous though.
A very useful little script, thanks a lot.
Post a Comment