Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

VMware: govcsim

Abhijeet Kasurde edited this page Apr 2, 2018 · 9 revisions

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.

What is govcsim (vCenter Server Simulator)

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.

Easy way - Using Dockerfile

Build Docker image using Dockerfile

  • Get Dockerfile
$ mkdir vcenter-simulator
$ cd vcenter-simulator
$ wget https://raw.githubusercontent.com/ansible/ansible/devel/test/utils/docker/vcenter-simulator/Dockerfile -O Dockerfile
  • Build Container image using docker compose
$ cat docker-compose.yml
version: '2'
services:
    vcsim:
      build:
         context: .
         dockerfile: Dockerfile
      image: vcsim
      container_name: vcsim
      Ports:
        - 5000:5000
        - 443:443
  • Start Container in detached mode
$ docker-compose up -d 
Starting vcsim ... done

Other way - Installing everything on virtual machine

Install Golang

Refer detailed steps from Official Golang Page

Installing govcsim

% 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.

Configuring govcsim

Ansible VMware module communicates with govcsim through a Flask controller app.

Starting 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.

Spawn govcsim instance through flask_control.py

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.

Killing govcsim

If you want to kill govcsim and start new instance, then you can kill it using flask routes

Available Flask routes

  • '/' - 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)

(ARchived) Working groups

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

Communities

Modules:
unarchive, xml

Plugins:
httpapi

Wiki

Roles, Communication, Reviewing, Checklist, TODO

Clone this wiki locally