-
Notifications
You must be signed in to change notification settings - Fork 144
VMware: govcsim
govcsim (vCenter Server Simulator)
Following page will provide guide to install and configure govcsim which is used in testing Ansible VMware modules.
This guide is helpful if you are -
- testing VMware module,
- writing a new VMware module,
- exploring VMware module for example,
You can go through already developed Ansible VMware test playbooks here.
govcsim (vCenter Server Simulator) is an open source vCenter Server and ESXi API based simulator written in go language using govmomi library. govcsim simulates vCenter Server model by creating various vCenter related objects e.g., datacenter, hosts, clusters, resource pools, networks and datastores etc.
There is a prebuild image available - https://quay.io/repository/ansible/vcenter-test-container
You can download this image using docker pull
# systemctl start docker
# docker pull quay.io/ansible/vcenter-test-container
Using default tag: latest
Trying to pull repository quay.io/ansible/vcenter-test-container ...
sha256:14662ffcb0adaa2e7004454ab27c3d104dba14488cfe5b289e9e8e363c96b05f: Pulling from quay.io/ansible/vcenter-test-container
ff3a5c916c92: Pull complete
f32d2ea73378: Pull complete
c6678747892c: Pull complete
16b5f22d8b23: Pull complete
8c65927af47b: Pull complete
e9febdafba6b: Pull complete
6356452f2069: Pull complete
Digest: sha256:14662ffcb0adaa2e7004454ab27c3d104dba14488cfe5b289e9e8e363c96b05f
Status: Downloaded newer image for quay.io/ansible/vcenter-test-container:latest
Start container using
# docker run -i quay.io/ansible/vcenter-test-container:latest
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
From another terminal, you get IP address of newly built container
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
67638dd8bfeb quay.io/ansible/vcenter-test-container:latest "/root/flask_control." 23 seconds ago Up 22 seconds 80/tcp, 443/tcp, 5000/tcp, 8080/tcp, 8989/tcp infallible_leakey
# docker inspect 67638dd8bfeb | jq -r '.[0].NetworkSettings.IPAddress'
172.17.0.2
# curl 'http://172.17.0.2:5000' ; echo ''
vcsim controller
Refer detailed steps from Official Golang Page
% export GOPATH=<your_go_path>
% go get -u github.com/vmware/govmomi/vcsim
% cd $GOPATH/src/github.com/vmware/govmomi/vcsim
% go install
% $GOPATH/bin/vcsim -h
If you see help page of govcsim, then you have successfully installed govcsim on your system.
Ansible VMware module communicates with govcsim through a Flask controller app.
% export ANSIBLE_SRC=<path_to_your_ansible_src_dir>
% cd $ANSIBLE_SRC/test/utils/docker/vcenter-simulator
% python flask_control.py
This will start a Flask instance which will serve on localhost with port 5000 by-default.
Once you have vcsim installation on your local machine
You can test this using,
% curl -k http://0.0.0.0:5000/
This command will return plain string vcsim controller
on stdout. This means your flask controller is working.
In order to start govcsim using Flask controller use following command,
% curl -k 'http://0.0.0.0:5000/spawn?username=user&password=pass&hostname=localhost&cluster=2&port=443'
This will start a govcsim server with user
as username, pass
as password, localhost
as hostname and 443
as port. The newly created govcsim will have by-default values of all VMware objects and cluster values as 2
. You can configure these values as per your requirement.
If you want to kill govcsim and start new instance, then you can kill it using flask routes
- http://0.0.0.0:5000/kill/<process_id_of_govcsim_to_be_killed>
- http://0.0.0.0:5000/killall
- '/' - returns string
vcsim simulator
- '/kill/int:number' - kill particular instance of govcsim running on given system
- '/killall' - kill all instances of govcsim
- '/spawn' - spawn a new instance of govcsim
- '/govc_find' - find VMware objects using govc command
- '/govc_vm_info' - get details about Virtual Machine(s)
- '/govc_host_info' - get details about host system(s)
This Wiki is used for quick notes, not for support or documentation.
Working groups are now in the Ansible forum
Ansible project:
Community,
Contributor Experience,
Docs,
News,
Outreach,
RelEng,
Testing
Cloud:
AWS,
Azure,
CloudStack,
Container,
DigitalOcean,
Docker,
hcloud,
Kubernetes,
Linode,
OpenStack,
oVirt,
Virt,
VMware
Networking:
ACI,
AVI,
F5,
Meraki,
Network,
NXOS
Ansible Developer Tools:
Ansible-developer-tools
Software:
Crypto,
Foreman,
GDrive,
GitLab,
Grafana,
IPA,
JBoss,
MongoDB,
MySQL,
PostgreSQL,
RabbitMQ,
Zabbix
System:
AIX,
BSD,
HP-UX,
macOS,
Remote Management,
Solaris,
Windows
Security:
Security-Automation,
Lockdown
Tooling:
AWX,
Galaxy,
Molecule
Plugins:
httpapi