Hi All,
We have deployed the VM from template thanks to this discussion forum, Now we need to configure the new VM with all the network related configuration to bring the host live.
Do we have any Perl script which take care of such steps, any pointer should help us.?
Thanks,
Nilesh
Hi Stumpr,
As i started testing template2vm-5.pl on windows i see some issues hopefully you can point me where I am going wrong.
While running it gave me below error message, not sure why, ideally when we use template these information should be taken from template why its expecting these value to provided from command line such such as username, fullname, orgname, productkey
I supplied product key then also it throws the below message.
My command argument is as below:
./template2vm-5.pl --server vcenter.company.com --sourcevm winrg64t --dnsdomain company.com --gateway <ip address> --dnsservers <ip address> --netmask <ip address> --vmhost server.company.com --ipaddress <machine ip address> --vmname mytest_win --datastore pdvnx_pool01_lun_1 --resourcepool ate-cloud --domain company.com --username <username> --fullname Master --orgname company --productkey <product key>
Deploying virtual machine from template swrg614t ...
Fault
SOAP Fault:
-----------
Fault string: Not initialized: string value
Please advise me what is missing. we should not be providing these input, I am correct, will make any issue.
This script requires some more value which i think I am missing.
Please help.
Thanks.
It's probably a script error where some value isn't being set. I may be able to look it over later.
I appreciate your prompt response. One more thing is it mandatory to supply these value --domainuser --domainuserpassword as i see if we don't use these value we see such "Not initialized: string value string value" Please look into the command i am using. We don't require this on linux but its seems we need to use these to add windows machine to domain, but providing password in command line is not secure hence i asked question if its mandatory, any alternative.
Hello Stumpr,
I am having one question.
template2vm-2.pl script deploys the VM in windows but why its configure everything from scratch. Ideally when deploy VM from template apart from vmname and ipaddress rest of the thing should be same, but it does few some initial video initialization during booting which takes long time to bring the VM up. What all option I should be using which does not requires for windows.
here are my options.
template2vm-5.pl --server vcenter1.company.com --sourcevm swrgtwin64 --dnsdomain na.company.com --gateway <ip address gateway> --dnsservers <dns address> --netmask <net mask> --vmhost spd04.company.com --ipaddress <ip address> --vmname testsvr --datastore <datastore> --resourcepool my_pool --domain na.company.com --username <username> --password <password> --fullname <name> --orgname <organization> --productkey <product keys> --domainuser <domain user> --domainuserpassword <domain password> --plaintextpassword --guestid windows7_64Guest
There are few option which i have been forced to set CustomizationUserData ( product id, computerName, fullName, orgName ) how to make this optimized.
Thanks in advance.
-Nilesh
You don't have to reconfigure the VM during cloning, it can be an exact duplicate of the last VM. This usually isn't of use in a production environment though.
If you have a common set of customizations, you can use the CustomizationSpec Manager to create a customization and during cloning you can use that customization spec instead of building it all up your self. This can include your example of having all but 2 values the same for example (hostname and ip).
You'll have to modify that script (template2vm.pl) to get the goals you require. From what I saw of the code, it wasn't written to be particularly robust and had some variable scope issues (which we fixed). I didn't review the entire program though, just the parts you had issues with.
Hi Stumpr,
You are right but if i looked into various object its seems i end up with some of the parameter which is mandatory.
Like
CustomizationSpec->new(
# encryptionKey => "",
identity => $customization_sysprep,
globalIPSettings => $customization_global_ip_settings,
nicSettingMap => \@ifconfig
);
$customization_sysprep = CustomizationSysprep->new(
guiUnattended => $customization_gui_unattended,
identification => $customization_identification,
userData => $customization_user_data
);
In CustomizationSysprep its looks like the field mentioned in the userData => $customization_user_data is mandatory and could not be avoid, can you please let me know if its possible.
| my $customization_user_data = CustomizationUserData->new( |
| computerName => $customization_name, |
| fullName => $fullname, |
| orgName => $orgname, |
| productId => $licensekey |
Apart from computerName rest of the things can be taken as it is. but when we ran without this parameter it report failure.
Due to such delay in deployment of VM from template, we are trying to deploy VM using Linked VM. i.e VM->Snapshot->Linked VM, this works great in Linux but in windows it still takes 6 minutes, during boot-up process i noticed that windows machines perform all the task which initial windows machine takes, i.e setting up video driver, preparing network connect, just like we start windows first time also it perform reboot during this time which adds up to time. is it the expected behavior in windows? We have got the script from ghetto on which i have added get_customization_spec subroutine from template2vm.pl.
Can you please let me know how can we optimize time to deploy using linked VM on windows.
I am very thankful to you for the valuable comment and suggestion you extended to me, appreciated.
Please find the linked VM creation script and the option we use for windows.
deplyVMLinked.pl --server vcenter1.company.com --username admin--vmhost host.company.com --vmname macs6161 --vmname_destination msc6161CLD --snapname Wx64Gold --password <pwd> --dnsdomain company.com --gateway <ip address> --dnsservers <ip address> --netmask <ip address> --ipaddress <ip address> --datastore pool1_LUN_004 --resourcepool cloud-company --domain company.com --plaintextpassword --guestid windows7_64Guest --customize_guest yes --domainuserpassword <ip address> --domainuser admin --autologon --localadminpwd <pwd>
What is missing/require in windows section of customization
I appreciate your quick response.
Thanks,
Nilesh
hi nileshjais ,
do you know how to define disk size when clone vm ?
I have a script can define mem,cpu ..etc .but not disk .
I don't have specific answer to your question but you can refer SDK's sample script vdiskcreate.pl for where you can get some pointer.
I check your script carefully ,you have to write the $customization_user_data before object CustomizationSysprep,you can write like this :
my $customization_user_data = CustomizationUserData->new( computerName => CustomizationFixedName->new(name => $host_name), fullName => $full_name, orgName => $org_name, productId => $prod_ID, );
Yes, but what different your solution is doing compare to the one in my script attached. I think you misunderstood my question, I wanted to know how should i avoid time to bring the windows machine ready to use after power on, Since it reports successful VM creation after which it perform complete initialization as if we setting up new machine from scratch. It perform reboot etc.
But we need only two thing computerName and IP address. So we need new VM to have these value set and rest of the value should not required to set as its already contain all the required information as its taking clone from snapshot.
Those multiple reboots are part of the sysprep process. The whole SID regeneration is an open topic if it's required, I think the last time I looked it wasn't really necessary to security. So you could use the VIX/GuestOps API hooks to just re-ip the box without doing a full customization in your example (you would have the box run a simple WMI script or batch file to change the computername and ip address, then join domain if necessary).
Thanks that was helpful.
How to autologon with some specific user on VM after setup is ready, But not with Admin user.?
You'll need to create a local user service account in your template. You can have your post-clone script delete that user.
You could bake the scripts into the template (so they run using RunOnce, or in linux, init scripts). You can also be sure that VMware tools are installed, and if so, use the VMware API GuestOperations manager to run a script in the GuestOS (GuestOps doesn't require network connectivity as it goes through the HostSystem). I've used this model to re-ip Windows and Linux guests in the past.
There is a QuickPrep that VMware View uses as well, I think it may avoid the SID regeneration to speed up the boot process after cloning. But basically you'd be doing your own custom address reconfiguration to avoid the sys prep process. On Linux, I don't think you have this problem as the customization process is just changing network configuration. Windows I think all the customizations are tied to sys prep (or at least if you want to change the domain it is).
You can test it quickly enough by just doing a customization spec with network and dns name configurations (skip the AD domain). You might not need all this complexity and can just use a minimal customization spec (I haven't tried it on windows like this in a while).
Hi Stumpr,
I found useful util perl script guestOpsmanagement.pl script from ghetto, can i use this script to run batch script on windows from Linux, I see one of the option startprog option.
Regards,
Nilesh
Can you please let me know, how do I know my VM is ready to use.
We are creating linked clone of VM and customization which takes some time a to make VM ready to use. But Clone_VM complete very fast but we would like to know how to determine state where user can start using the VM.
There are state like "Powen on", "Power off" but don't know when we can start using the VM, we need this to perform some Automation step to take place once VM is ready to use.
You may want to look into this code and get some input how to define a desk size
sub get_disksize {
my $disksize = -1;
my $parser = XML::LibXML->new();
eval {
my $tree = $parser->parse_file(Opts::get_option('filename'));
my $root = $tree->getDocumentElement;
my @cspec = $root->findnodes('Virtual-Machine-Spec');
foreach (@cspec) {
$disksize = $_->findvalue('Disksize');
}
};
return $disksize;
}
Hi Stumpr,
I would like to know when the VM is ready to use after deploy or power on( since in windows it reboot 2 which keeps user isolated when this VM can be used) . I seen one of the batch script power-on-default.bat in vmware tools
Can i use this script to perform below operation.
@echo off
if "%1%" == "precustomization" (
echo Put your precustomization code here
) else if "%1%" == "postcustomization" (
echo Put your postcustomization code here
) else (
echo Unknown command line
)
Or there are other places to put this post and per-customization steps.
Mostly I need to touch a file once the VM is ready to use in post-customization.
Please let me know your response.
Thanks in advance.
Regards,
Nilesh
Hi Stumpr,
Hope you are doing good.
I need you valuable comments and wanted to make windows guest OS customization working when i create linked VM, i see CustomizationSysprep does change my existing template data to provide new configuration which taking longer time to make VM ready. Also does it mandatory to provide CustomizationUserData while doing customization.
I need to make my VM Autologon using domain user how to make this working because, existing template default autologon registry setting is been removed during VM creation.
Please help me in this regards, I am using script attached in this forum to create linked VM.
my vcenter server version is 4.1, hence i could do guest post customization using guestosmamangement.pl script which support 5.1 version.
Nilesh
Hi Stumpr,
I trying to find the solution for two things but could not get much pointer for the same, Hopefully you might have encountered this, since i am new to this it would really helpful if you give me input.
1. Whenever i tried to create linked VM, some time but not every time network adapter device for few of the VMs checkbox stay unchecked, i don't know what is the reason, I have sufficient free port of the host. what might be issue. say if i create 6 linked VM in parallel one or two VMs device connected on power on and connected checkbox will be unchecked.
2. I want to get VM count from host server, I have a piece of code but its taking long time to produce count, could you point me why its slow.
my $host_name = Opts::get_option('vmhost');
my $host_view = Vim::find_entity_view(view_type => 'HostSystem', filter => {'name' => $host_name});
&listVMs($host_view);
sub listVMs {
# Prints a list of registered VM on the screen.
# Does not log it's use.
#
my ($host_view) = @_;
my $vms = Vim::get_views(mo_ref_array => $host_view->vm, properties => ['name','runtime.powerState','guest.toolsRunningStatus']);
my $totalVMs = 0;
foreach(@$vms) {
$totalVMs += 1;
print "VM: ".$_->{'name'}.", ".$_->{'runtime.powerState'}->val.", "
.$_->{'guest.toolsRunningStatus'}.", ".$_->{'mo_ref'}->value."\n";
}
print "\nTotal ".$totalVMs." VMs found.\n\n"
}
Thanks in advance.
Nilesh
Not sure on #1, I guess you could just do your reconfig spec to enable it to force it just in case. But double check the settings on your template.
For #2, you get the full Host system data, that can be large. If that's in a loop, it can compound. You can try adding 'properties' list to the host.
