Thursday, May 5, 2016

get vCenter Server or Replication appliance update URL from command line using xmllint

My vCenter appliances (Server and Replication) are on an internal network and cannot get to the outside world. To update them, I mirror the update repositories on an internal web server, using the script from http://www.virtuallyghetto.com/2013/05/how-to-create-offline-update-repository.html

The script requires the update URL, which is easy to get manually from the appliance web interface, but I want to automate the update.

I found that the default update URL is stored in

/opt/vmware/var/lib/vami/update/provider/provider-deploy.xml
and the user-entered update URL is stored in
/opt/vmware/var/lib/vami/update/provider/provider-runtime.xml

The appliances come with some command-line tools to parse XML; I'm using xmllint:

echo 'cat //property[@name="repositoryAddress"]/@value' | \
xmllint --shell /opt/vmware/var/lib/vami/update/provider/provider-deploy.xml | \
grep https
The output:
value="https://vapp-updates.vmware.com/vai-catalog/valm/vmw/05d561bc-f3c8-4115-bd9d-22baf13f7178/5.8.1.12927.latest"