VMware Cloud Community
DrJP
Contributor
Contributor

Copying Virtual Disks and trying to register new Virtual Machines from them.

Hi all,

I am trying to build a system in which you can automatically (Using the CLI) create N copies of a previously created Virtual Machine, register them, run them and start doing things with them via ssh.

So far, I have writen some scripts that use the CLI to do some of these tasks.

For example, to create N copies of the original Virtual Machine, I copy the whole folder with a new name:

vifs.pl --config ./config.txt --copy "[datastore1]Original/" "[datastore1]name1/"
vifs.pl --config ./config.txt --copy "[datastore1]Original/" "[datastore1]name2/"
...
etc.

With that, I copy the vmdk, vmx, nvram, vmxf and vmsd files.

After this, I try to register the machines, but if I simply do this:

vmware-cmd.pl --config config.txt -s register /vmfs/volumes/datastore1/name1/Original.vmdk

Then, the new machines will have the same id. To solve this, I created another script to edit the Original.vmx to change the displayName for each machine and I uploaded it to every folder of every VM on the server.

Buuuut the problem is that when I try to start the machines using the CLI ( vmware-cmd.pl --config ./config.txt /vmfs/volumes/datastore1/name1/Original.vmx start soft ), they stay at 95% of starting. When I try to open their consoles using the VSphere Client, I receive a message stating this:

"This Virtual Machine might have been moved or copied. In order to configure certain management and networking features, VMWare ESX needs to know if this virtual machine was moved or copied". After choosing an option, I can use the machine, but I want to start using the machines without opening the console and having to make a manual choice (I want to create and run more than 30 machines at the same time, and I need to make this process automatically).

So, is there something else I should "touch" in the vmx file in order to avoid this problem?
-----------------------------------------------------------------------------------------------------------------------------

Finally, another problem that I've had is when I try to automatically delete the N created folders using the CLI:

vifs.pl --config ./config.txt --rm "[datastore1]name1/Original.vmxf" --force
vifs.pl --config ./config.txt --rm "[datastore1]name1/Original.vmsd" --force
vifs.pl --config ./config.txt --rm "[datastore1]name1/Original.vmx" --force
vifs.pl --config ./config.txt --rm "[datastore1]name1/Original.nvram" --force
vifs.pl --config ./config.txt --rm "[datastore1]name1/CleanUbuntu_1.vmdk" --force
vifs.pl --config ./config.txt --rmdir "[datastore1]name1/" --force

The last command does not work, as the vmdk file has not been erased but has been changed with a file with the same name + _flat.

Thanks and best regards,

JP

Reply
0 Kudos
4 Replies
DrJP
Contributor
Contributor

So, no answer at all from anybody?

Reply
0 Kudos
JESX35
Enthusiast
Enthusiast

I know you can right click on the VM and select choose awnser for guest so you don't have to open the console, however this still probably isn't the scripting awnser you where looking for.

Must be a way tho,

Reply
0 Kudos
DrJP
Contributor
Contributor

That was obiously not the kind of answer I was looking for. This is extremely frustrating. My company even contracted the Basic Support, but we are not able to find a way to contact the support. VMWare Web Page is anything but intuitive, damn it...

Reply
0 Kudos
admin
Immortal
Immortal


You can answer the question while powering on:

  • ESXi

http://kb.vmware.com/kb/1026835

  • PowerCLI

http://communities.vmware.com/thread/303211

However, what I was looking for is not to have to power on to answer the question, OR never had to answer the question.

http://kb.vmware.com/kb/1541 has the information that gave me the solution.

Add
uuid.action = "keep"
or
uuid.action = "change"
to the vmx of the VM and refresh (re-register or kb 1026043) so the vmx is reloaded.

KBs used:

Reply
0 Kudos