1 2 3 4 Previous Next 47 Replies Latest reply on May 13, 2014 1:03 PM by samsvmware

    Network configuration of VM after deploy from template

    nileshjais Enthusiast

      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

        • 1. Re: Network configuration of VM after deploy from template
          stumpr Master

          What sort of network related configuration?  Most of the network configuration can be done in your customization spec (either the vSphere Customization Spec or by setting the customization values during a CloneVM_Task).

           

          If you need some more advanced interface configuration (such as ip aliases), then you may need to do some post-cloning automation with the GuestOperations object on the VM (assuming it has VMware Tools installed and running).

          • 2. Re: Network configuration of VM after deploy from template
            nileshjais Enthusiast

            Thank you for the response. I think you got it perfectly right. I found similar script from VSphere forum ( Script need to deploy a VM from a template ) which does somewhat the same as per my requirement. But when i ran this script i got error message as below:

             

            Deploying virtual machine from template surg649t  ...

            FaultCannot serialize identity as CustomizationIdentitySettings at /usr/lib/perl5/5.8.8/VMware/VICommon.pm line 2432

            ComplexType::serialize('CustomizationSpec=HASH(0x1bb1cfd0)', 'customization', 'undef') called at /usr/lib/perl5/5.8.8/VMware/VICommon.pm line 2439

            ComplexType::serialize('VirtualMachineCloneSpec=HASH(0x1b715060)', 'spec') called at (eval 30) line 111

            VimService::get_arg_string('VirtualMachineCloneSpec=HASH(0x1b715060)', 'spec', 'VirtualMachineCloneSpec') called at (eval 30) line 132

            VimService::build_arg_string('ARRAY(0x180063a0)', 'HASH(0x18006320)') called at (eval 30) line 2923

            VimService::CloneVM_Task('VimService=HASH(0x18dd42f0)', '_this', 'ManagedObjectReference=HASH(0x18f86d20)', 'spec', 'VirtualMachineCloneSpec=HASH(0x1b715060)', 'name', 'surg649_new', 'folder', 'ManagedObjectReference=HASH(0x190a13b0)', ...) called at /usr/lib/perl5/5.8.8/VMware/VICommon.pm line 1693

            ViewBase::invoke('VirtualMachine=HASH(0x18f26940)', 'CloneVM_Task', 'spec', 'VirtualMachineCloneSpec=HASH(0x1b715060)', 'name', 'surg649_new', 'folder', 'ManagedObjectReference=HASH(0x190a13b0)') called at (eval 39) line 201

            VirtualMachineOperations::CloneVM_Task('VirtualMachine=HASH(0x18f26940)', 'spec', 'VirtualMachineCloneSpec=HASH(0x1b715060)', 'name', 'surg649_new', 'folder', 'ManagedObjectReference=HASH(0x190a13b0)') called at (eval 39) line 207

            VirtualMachineOperations::CloneVM('VirtualMachine=HASH(0x18f26940)', 'folder', 'ManagedObjectReference=HASH(0x190a13b0)', 'name', 'surg649_new', 'spec', 'VirtualMachineCloneSpec=HASH(0x1b715060)') called at /opt/vmware-vsphere-cli-distrib/apps/vm/template2vm.pl line 263

                    eval {...} called at /opt/vmware-vsphere-cli-distrib/apps/vm/template2vm.pl line 262

            main::deploy_template() called at /opt/vmware-vsphere-cli-

             

            Don't know what is missing here.

            • 3. Re: Network configuration of VM after deploy from template
              stumpr Master

              Looks like something with the format of the CustomizationIdentitySettings.  I'm not sure which script you are using, can you post it here?  I looked at the one linked from the other forum post, but line 262 where the error occurs doesn't look right for the error message.  I'm guessing it's a different script.

              • 4. Re: Network configuration of VM after deploy from template
                nileshjais Enthusiast

                Here is the script which i am using? Please advise me if any thing is missing in this script which needs attention.

                 

                I need to valuable input and help.

                • 5. Re: Network configuration of VM after deploy from template
                  stumpr Master

                  What are your run options?  (you can mask the password/username/server url)

                   

                  Also, is this is a windows or linux clone?

                  • 6. Re: Network configuration of VM after deploy from template
                    nileshjais Enthusiast

                    Here are my run option.

                     

                    template2vm.pl  --server dev-vcenter1.company.com --credstore ~/.vmware/credstore/vicredentials.xml --sourcevm surg649t --dnsdomain company.com --gateway <ip address> --dnsservers <ip address> --netmask 255.255.255.0 --vmhost sesxdp04.company.com  --ipaddress <ip address> --vmname surg649_new --datastore pdvnx_pool01_LUN_91 --resourcepool private-cloud

                     

                    Presently i am trying this for linux but later we need to do this for windows as well, so you can assume its for both. Do you see anything missing or script requires any changes. got stuck ....please help

                    • 7. Re: Network configuration of VM after deploy from template
                      stumpr Master

                      It was a scope issue, the linux prep was being rescoped with my in the elsif block and getting undef in your customization.

                       

                      Try the attached version.  However, from the code looks like it will only work for RHEL5_64Guest, so it would need more modification to support additional linux guest os types.

                      1 person found this helpful
                      • 8. Re: Network configuration of VM after deploy from template
                        nileshjais Enthusiast

                        Thanks a lot ... you have been fantastic on this ... will try this script and get back to you. Yeah you are right this script can only perform RHEL5_64Guest, as we start using other platform we will keep on enhancing the script.

                        • 9. Re: Network configuration of VM after deploy from template
                          nileshjais Enthusiast

                          Hi Stumpr,

                           

                          I used the script after over few hickups i was able to deploy VM.

                           

                          Following was observation:

                          1. After deploying VM took some time to bring the machine into network is it expected behavior? , using vminfo.pl we tried to get details of new VM, initially it didn't show any details but after some time it shows the details. does it requires reboot or start of the services. we did restart of network services after which we were able to see the details of vminfo.pl

                          2. /etc/resolve.conf was not having entries of primary dns and secondary dns.

                           

                          Does it requires any more configuration changes.

                           

                          Thanks in advance.

                           

                          Regards,

                          Nilesh

                          • 10. Re: Network configuration of VM after deploy from template
                            stumpr Master

                            VMware Tools information such as the Guest Disks, IP Addressing, etc will not be available until VMware Tools is running (the VM is fully booted).  Some of the other information should be available, however.

                             

                            In terms of the /etc/resolv.conf, looks like the script you provided doesn't really support Linux name servers properly.  It's being set on the nic level, not the global level as Linux requires.

                             

                            I made a change (but didn't test it).  Basically, for Linux you need to set your dns servers in the CustomizationGlobalIPSettings (line 469 in this script).  I added the dnsServerList there.  I believe that this will work just fine on both Windows and Linux (but please test).  However, for Linux, you have to do your dns servers here, you can't do them on the NicAdapter level as the script was doing before my edit.

                            • 11. Re: Network configuration of VM after deploy from template
                              nileshjais Enthusiast

                              The script which you attached and the one which i sent, i don't see any difference hence i am not able to figure out the changes you made. because the dnsServerList is also present in my copy of script?  Please let me know if i am missing something here.

                              • 12. Re: Network configuration of VM after deploy from template
                                stumpr Master

                                No, you're absolutely right.  I accidentally attached the older script version.  Here's the correct version.  Sorry about that.

                                • 13. Re: Network configuration of VM after deploy from template
                                  nileshjais Enthusiast

                                  Thank you !! That's looks changed one will test it. One more request Do you have script which will add vmdisk to add to a VM or reference will also help. I got the one script http://communities.vmware.com/docs/DOC-11213, But it reports datastore not find. looks like old script, do you have better script than this, also it does not take size of disk which we needed.

                                  • 14. Re: Network configuration of VM after deploy from template
                                    stumpr Master

                                    That should work, if it's not finding the datastore could be a permission issue.  The same process applies, you just call ReconfigVM_Task() with the new disk configuration.

                                    1 2 3 4 Previous Next