Git Product home page Git Product logo

vcsim-docker's Introduction

vCenter Simulator Docker Container

docker pulls docker size docker version

Last Build Time
20.03.2021 (dd.MM.YYYY)

vcsim is a nice vCenter simulator by VMware. It's made with golang and needs to be compiled before use. Easiest way to run it, is to run it in a Docker container. This repository has the ready-to-use container source that you can pull from the Docker Hub as a working Docker Image and run it.

After vcsim container running in your Docker environment you can interact with it with different CLI tools like Powershell or govc. You can even use Terraform against vcsim but currently it's a bit limited since you can't really clone VMs with it.

When you start vcsim it has it's own default configuration with datastores, vms, resource pools and vms that are documented at the end of this document in the Terraform section. You can also put existing VMware configuration from your real vCenter environment and put it in the simulator that is documented here: https://github.com/vmware/govmomi/wiki/vcsim-features

vcsim repository: https://github.com/vmware/govmomi/tree/master/vcsim

Docker

Pull this Docker container and run it in local 443 port

  • docker pull satak/vcsim
  • docker run -d --name vcsim -p 443:443 satak/vcsim

DockerHub url: https://hub.docker.com/r/satak/vcsim


CLI tools

Powershell PowerCLI

You can interact with vcsim with different cmdline tools like PowerCLI, which is a nice Powershell module for VMware.

VMware PowerCLI is a command-line and scripting tool built on Windows PowerShell, and provides more than 700 cmdlets for managing and automating vSphere, vCloud, vRealize Operations Manager, vSAN, NSX-T, VMware Cloud on AWS, VMware HCX, VMware Site Recovery Manager, and VMware Horizon environments.

Install PowerCLI module, connect to vcsim (it doesn't have any authentication so you can use what ever username and password) and get VMs:

# first install the vmware powercli module
Install-Module VMware.PowerCLI -AllowClobber

# connect to vcsim, this takes 1-2 minutes, -Force switch to bypass the SSL certificate issue. Username and password can be anything, there is no authentication
Connect-VIServer localhost -User 'u' -Password 'p' -Force

# to test the connection just get VMs from the vcsim
Get-VM

<#
Should get something like this:

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
DC0_H0_VM0           PoweredOn  1        0.031
DC0_H0_VM1           PoweredOn  1        0.031
DC0_C0_RP0_VM0       PoweredOn  1        0.031
DC0_C0_RP0_VM1       PoweredOn  1        0.031
#>

# stop VM
Get-VM -Name DC0_H0_VM0 | Stop-VM

# start VM
Get-VM -Name DC0_H0_VM0 | Start-VM

govc

govc is a vSphere CLI built on top of govmomi.

govc binaries: https://github.com/vmware/govmomi/releases

Direct links:

Windows Installation

For Windows just download the govc, rename the downloaded binary to govc.exe and move it to C:\Program Files\govc, add that path to environment variables so you can then use govc from any location.

Linux / MacOS

# install govc
URL_TO_BINARY="https://github.com/vmware/govmomi/releases/download/v0.22.1/govc_darwin_amd64.gz"
curl -L $URL_TO_BINARY | gunzip > /usr/local/bin/govc
chmod +x /usr/local/bin/govc

# set envs for your vcsim
export GOVC_URL=https://user:[email protected]:443
export GOVC_INSECURE=1
export GOVC_DATASTORE=datastore/LocalDS_0
export GOVC_RESOURCE_POOL=DC0_H0/Resources
export GOVC_NETWORK="network/VM Network"

# powershell env vars
$env:GOVC_URL = "https://user:[email protected]:443"

govc find

# set ip and name
govc vm.power -off DC0_H0_VM1
govc vm.customize -vm DC0_H0_VM1 -name fourtythree -ip 10.0.0.43
govc vm.power -on DC0_H0_VM1
# get name and ip
govc object.collect -s vm/DC0_H0_VM1 guest.ipAddress guest.hostName
# get ip
govc vm.ip DC0_H0_VM1

# guestId: windows9Server64Guest

# create VM
# govc vm.create -m 2048 -c 2 -g windows9Server64Guest -net.adapter vmxnet3 -disk.controller pvscsi test-vm
govc vm.create -on=false -host DC0_H0 -version 6.7 -g otherLinux64Guest -c 2 template-vm

Terraform

Terraform

Terraform is the leading infrastructure as code (IaC) platform that supports wide variety of APIs like VMware vCenter. We can use Terraform against vcsim too, but currently the support is a bit limited because assets in vcsim are not fully configured for Terraform usage.

Installation

Working variables for vcsim

vsphere_user     = "username"
vsphere_password = "password"
vsphere_server   = "localhost"

datacenter    = "DC0"
cluster       = "DC0_H0"
datastore     = "datastore/LocalDS_0"
resource_pool = "DC0_H0/Resources"
network       = "network/VM Network"

vm_name     = "vcsimtest"
vm_template = "test-vm"
vm_folder   = "vm"
vm_password = "password"

Supports Linux and Windows VMs. To create windows VM first create Windows template by running create_vm.sh and then run terraform apply -var="os_type=windows" -var="vm_template=template-vm"

vcsim-docker's People

Contributors

satak avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.