VMware {code} Community
benny_Boy
Contributor
Contributor

vmtemplate.pl don't delete the template

Hi,

I think the title above is enough explicit, unless I need to know how I can use vmtemplate (VI Perl Toolkit) without delete the template while I make "Convert a template to virtual machine". So just to know if I can clone template to virtual machine and keep my template for later ?

Thank you,

Benny.

0 Kudos
14 Replies
StefanPahrmann

Hi Benny,

vmtemplate.pl is just for converting a template to a virtual machine and vice versa, so that you easily can modify your template for further deployments.

You can clone your template from inside the Virtual Center, but I guess you want to deploy a Virtual Machine from the template? In that case there is a script (vmprovision.pl) in the sample-folder (under 'vm') and use the 'clone' operation. With this you create a new copy based on your template (and your template stays without being touched/modified).

Regards

Stefan

0 Kudos
benny_Boy
Contributor
Contributor

Thanks Stefan,

I think I've understood, but I need precision, in order you have to :

- deploy your temlplate (vmtemplate.pl) to a VM

- make a new template with that new VM

Or maybe, you said I can copy directly a template to template ?

One of the last questions is : Can you give a particular name to your VM while deploying a template?

And the last one : when you said "so that you easily can modify your template for further deployments", can precise what type of modification you can do directly on your template ?

Thank you for help, appreciate.

Regards

Benny

0 Kudos
ssurana
VMware Employee
VMware Employee

Hi Benny,

You should use the "vmclone.pl" sample present under the apps\vm folder. Using this script you would be able to provision a virtual machine from a template and also customize the VM as well as the Guest OS if you want.

The sample that you are looking at "vmtemplate.pl" converts the template back to a VM and vice versa. Also this script does not perform any delete operation, it is just a conversion.

~ Sidharth

0 Kudos
StefanPahrmann

I think you are a bit confused about the terminology.

I'll try to explain:

First you create a VM, install some OS and some applications

Then you convert this VM as your master-template

When you need another VM you can clone the template to a new virtual machine, where the OS and applications are installed (from your first step). The template will stay the same. This is done with vmprovision.pl or vmclone.pl

When you need to install another application to that template you can convert it with vmtemplate.pl, so that it is a vm again, start it up and log on, install the application, shutdown and convert it back again as a template for further clones.

It doesn't make much sense to clone a template, unless you need it for some rollback-action.

From the vmprovision.pl you can give a particular name to this vm ("--vmname_destination"):

    vmprovision.pl --op clone --server vc-server.example.com
        --vmhost esx1.example.com --vmhost_destination esx2.example.com
        --vmname 'My Virtual Machine' --vmname_destination 'My Clone'

Regards

Stefan

benny_Boy
Contributor
Contributor

Hi Ssurana,

Thank you very much. But can anybody precise me what's the difference between customize the GuestOS and the VM ?

Are you sure I can clone a template ?

And my last question is what is the "Full-Name" in the XML ?

Thank you for your help.

Regards

Benny.

0 Kudos
benny_Boy
Contributor
Contributor

Thank you Stefan,

I explain what I need to do, it will easier for you ti understand Smiley Wink

I need to make an interface for aumatic deployement of template, so I'll do the interface later.

So the step of what I need to do is :

- Ask the user which OS he wants (from a list of template).

- Ask him everything about the hardware that he needs.

- Deploy the template with the user's specifications

Thank you so much for your help, and sorry for my english Smiley Wink

Benny.

0 Kudos
StefanPahrmann

This is more or less exactly what I did. Just follow the steps above and use vmprovision.pl - or you can code it by yourself (I did it, because i wanted more freedom in my scripts).

vmprovision lets you choose amount of memory and cpu, which portgroup to use, disksize etc - so it should be suitable for your need.

Which language would you prefer? (We can discuss this in german or danish either.

Regards

Stefan

benny_Boy
Contributor
Contributor

Thank you Stefan for your answers,

I'm going to take a look on your method, and if I have more questions i'll ask you later.

I didn't know that "vmprovision.pl" works with template.

My prefered language is Perl (of course), no I'm kidding I'm french so I prefer english than german or danish Smiley Wink

Thank you so much for your help, appreciate.

Benny.

0 Kudos
benny_Boy
Contributor
Contributor

Sorry, it's me again Smiley Wink

+perl vm/vmprovision.pl --op clone --server 172.20.1.9 --vmhost

esxhp02.dlc.accenture.com --vmhost_destination

esxhp02.dlc.accenture.com --vmname 'Win_Test_Template3'

--vmname_destination 'Cust_Deploy_Win' --disksize 10485760 --num_cpus 1

--memory 4096+

Stefan, you told me that I can choose the amont of memory, of disk...but while I execute that command above, I deploy my template to a VM but I still have the same memory, and the same Hard Drive than before (still have 2Gb RAM, and 6Gb HD).

If you can tell me how you choose the size.

Regards

Benny.

0 Kudos
ssurana
VMware Employee
VMware Employee

Hi Benny,

The "vmprovision.pl" is only capable of deploying a VM from the template without any additional customization or you can create a new VM all together. For your requirement you need to use the vmclone.pl script as it is capable of even customizing the VM during the cloning process. i.e. the hardware configuration also.

~ Sidharth

0 Kudos
ssurana
VMware Employee
VMware Employee

To answer your questions in the earlier post

Customizing the GuestOS means that you can set some of the configurations of the operating system on the virtual machine e.g. Windows XP / 2000. Using this customization you can set the computer owners name, organization name, administrator's password, network setting, etc. for the new VM that is created out of the template.

Customizing the VM means changing the machines hardware configuration like virtual disks, cd-roms, etc.

The "Full-Name" attribute in the XML is for setting the Computer's Owner name.

Hope the above information helps.

~ Sidharth

0 Kudos
benny_Boy
Contributor
Contributor

Thank you very much.

I'm still tryin to find the best practice to implement what I need. But your answers help me so much.;)

Thank you again.

Regards

Benny.

0 Kudos
benny_Boy
Contributor
Contributor

Hi ,

I have some problems with "vmclone.pl" and can't know which is it cause in verbose mode I only obtain something like :

"Customization failed" in Infrastructure Client and "FaultCustomization failed. at /usr/share/perl/5.8/VMware/VIM25Runtime.pm line 1986" in my console.

The second proble is that i found a listing of GuestOsIdentifier but it seems doesn't work !!

I attach the XML file.

EDIT : It works while I only customize the VM, so I only have trouble while I want to customize the Guest. If you have an idea. Smiley Wink

Thank you, regards.

Benny.

0 Kudos
clem_mars
Contributor
Contributor

Hi Benny,

I have the same issue using a VIperl script to deploy and customize VMs from a template. Did you resolve this issue?

Thanks a lot,

-


Clement

----------- Clement
0 Kudos