Dummy Virtual Machine For Dummies: How To Create Hundreds of Them with Several Lines of Scripts

As I introduced in the article on vim-cmd commands, you can use a very simple command as follows to create a new virtual machine. Alternatively, you can ignore the path after the datastore and provide only datastore name (The [ and ] are still needed).

# vim-cmd vmsvc/createdummyvm testVM “[datastore1] testVM/testVM.vmx"

Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.

Other than the name and configuration file path in data store, there is no additional information provided such as the size of the disk, memory capacity, etc. Normally, you have to go through a wizard of several pages to create a new virtual machine.

So, what’s special about the virtual machine created by the vim-cmd? The sub-command name itself “createdummyvm” has hinted something. The new virtual machine is a dummy virtual machine – which means it does not have guest OS installed and cannot even be powered on. Besides that, it’s also a very small sized virtual machine in terms of memory and hard disk. The “Edit Settings” dialog box shows that the dummy virtual machine has 1M memory and 32M of disk, probably is good enough for DOS of 20+ years ago.

Although you cannot do much useful with the dummy virtual machine, it’s good for testing. Except that there is no guest OS (consequently, no VMware Tools), a dummy virtual machine is a virtual machine. A great use case of dummy virtual machines is for testing – what if you want a populated inventory as your testing environment?

You can create a test environment with hundreds of virtual machines very quickly.

# vi /var/opt/createvms.py
#!/bin/python
 
import os
import sys
 
for i in range(0, int(sys.argv[1])):
    vmname = "testvm%d" % i
    os.system("vim-cmd vmsvc/createdummyvm " + vmname + " \"[datastore1] /" + vmname + ".vmx\"")

After the Python script is ready, mark it as executable as follows. When you run the python code, you can specify the number of dummy virtual machines to create. There is no limit with the script, but there is a limit on vSphere ESXi side. I think it’s 512 virtual machines per host. Don’t try a number bigger than that at all.

# chmod 755 /var/opt/createvms.py
# /var/opt/createvms.py 200

You can change the script to name the virtual machine name prefix to whatever name you want.

This entry was posted in Virtualization and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  • NEED HELP?


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.