On the 31st of december I read a very nice post over at brianbunke.com on running a simulated vCenter with govcsim. Simulated is maybe a bit overstated as it only contains a subset of the API. A vCenter API mocker is a probably better description. Now the nice thing about Brian’s post is that it describes how to run the simulator in a container. This got me thinking. Why run this on your own hardware when you can test it in the cloud?
I’m not a container wizard by any means but I know about Docker Playground. This is THE go-to place if you want to prototype a containerized application. And with the newly gained knowledge about running a vCenter simulator why not try to run it there?
As it turns out running the vCenter simulator itself was a breeze. I simply used the command from Brian’s post and within a couple of seconds I had a running instance.
docker run --rm -d -p 443:443/tcp nimmis/vcsim:latest
Now connecting to this server was a bit more challenging. Because when connecting remotely you need to be able to talk to the lookup service. When you try to connect from your local machine you get an error that looks something like this.
Connect-VIServer : There was no endpoint listening at https://127.0.0.1/lookupservice/sdk that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
At line:1 char:1
Connect-VIServer -server ip172-18-0-24-bgm7afc3uhdg00913fng-443.direc …
~~~~~~~~~~~~~~~~~ CategoryInfo : NotSpecified: (:) [Connect-VIServer], EndpointNotFoundException
FullyQualifiedErrorId : System.ServiceModel.EndpointNotFoundException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer ConnectVIServer
There’s probably an easy docker fix that exposes the lookupservice to the internet but my docker-fu is not that strong. Alternatively you can just install PowerCLI in Docker Playground and test it from there. Simply run the following command and you have a local instance of PowerCLI installed.
docker run --rm -it --net=host vmware/powerclicore
Once you are presented with a Powershell prompt enter the following commands and you’re good to go.
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false Connect-VIServer -Server localhost -Port 443 -User u -Password p Get-VM