Wednesday Tidbit: registering multiple vCenters with vCOPs

20150703 - VMwareRecently, the company I work for has done really well in bringing onboard new customers – nearly all of which we have provided with a private cloud solution running on the VMware platform.

As part of the process of transitioning from the build stage to production, the customer’s vCenter system is registered with our in-house vCenter Operations Manager platform, enabling us to constantly monitor the health of their virtual estate.

The process of registering a new vCenter is a trivial one using the vCOPs admin page.  However with twenty or so systems to add, a member of the Operations team asked for my help in automating the process.  This consisted of:

  1. Ensuring networking connectivity between the vCOPs server and the new vCenters (firewall rules, mainly)
  2. Creating an admin account on each customer vCenter for vCOPs
  3. Registering the vCenter servers

It is the last step that required a bit of work.

Familiar with Bash scripting, I decided to create a script which would run on the vCOPs server and do the following:

  1. Import a list of vCenters
  2. Tested connectivity to each one
  3. If successful, register the vCenter (if not, produce an error).

My preferred tool for testing connectivity through firewalls is the excellent netcat utility, but unfortunately this isn’t available the vCOPs SLES 11 box.  Neither is /dev/tcp.

However, cURL is. Therefore I decided to create the following script:


# Variables


# Read CSV file
while read vcname vcip vcuser vcpass

	# Test connectivity to the vCenter IP address
	curl -s -k --connect-timeout 5 https://$vcip >/dev/null 2>&1
	if [ $? -eq 0 ]   
		# Register the vCenter with vCOPs
		vcops-admin register --vc-name $vcname --vc-server https://$vcip/sdk --user $vcuser --password $vcpass --force
		# Write error message
		echo "No connectivity to vCenter" $vcname" at" $vcip". Please check firewall rules"
# Close CSV file
done < $INPUT

# Reset IFS

This uses a CSV file such as:


Once the firewall rules were all put in place, the script ran successfully. Within a few minutes twenty vCenters were registered with vCOPs.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s