Home Audience Admin Beginning vCenter Server simulation with Govcsim

Beginning vCenter Server simulation with Govcsim

0
11668

govcsim is a vCenter Server and ESXi API based simulator that offers a quick fix solution for prototyping and testing code. It simulates the vCenter Server model and can be used to create data centres, hosts, clusters, etc.

govcsim (a vCenter Server simulator) is an open source vCenter Server and ESXi API based simulator written in the Go language, using the govmomi library. govcsim simulates the vCenter Server model by creating various vCenter related objects like data centres, hosts, clusters, resource pools, networks and datastores.

If you are a software developer or quality engineer who works with vCenter and related technologies, then you can use govcsim for fast prototyping and for testing your code.

In this article, we will write an Ansible Playbook to gather all VMs installed on a given govcsim installation. Ansible provides many modules for managing and maintaining VMware resources.

Do note that govcsim will simulate almost the identical environments provided by VMWare vCenter and ESXi server.

Figure 1: Getting help from vcsim
Figure 2: Starting vcsim without any parameters

Installation

We will use Fedora 26 for the installation of govcsim. Let’s assume that Ansible has been already installed using dnf or a source tree.

The requirements for installing govcsim are:

1. Golang 1.7+

2. Git

Step 1: Installing Golang

To install the Go tools, type the following command at the terminal:

$ sudo dnf install -y golang

Step 2: Configuring the Golang workspace

Use the following commands to configure the Golang workspace:

$ mkdir -p $HOME/go

$ echo ‘export GOPATH=$HOME/go’ >> $HOME/.bashrc

$ source $HOME/.bashrc

Check if everything is working by using the command given below:

$ go env GOPATH

This should return your home directory path with the Go workspace.

Step 3: Download govcsim using the ‘go get’ command

$ go get github.com/vmware/govmomi/vcsim

$ $GOPATH/bin/vcsim -h

If everything is configured correctly, you will be able to get the help options related to govcsim.

To start govcsim without any argument, use the following command:

$ vcsim

Now, govcsim is working. You can check out the various methods available by visiting https://127.0.0.1:8989/about on your favourite browser.

Figure 3: Ansible Playbook to get details about the virtual mchine
Figure 4: Ansible in action

Testing govcsim with Ansible

Now, let’s try to write a simple Ansible Playbook, which will list down all VMs emulated by govcsim. The complete code is given in Figure 3.

After running the playbook from Figure 3, you will get a list of virtual machine objects that are simulated by the govcsim server (see Figure 4).

You can play around and write different playbooks to get information about govcsim simulated VMware objects.

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here