vSphere

 View Only
  • 1.  CloneVM while adding nics and customizing - possible?

    Posted Mar 11, 2010 07:35 AM

    Hi,

    I'm writing code (using C#) for cloning a VM from an existing template.

    The template has no nics on it, and I'm trying to add nic(s) and customize them with all the IP settings in the same task, but to no avail.

    Adding nic(s) using the config spec of the Clone task is working, but when I add customization spec to the Clone task, I get errors from the VC because it cannot customize nics that are not there yet.

    Is there any way to accomplish that? Can you point me to a sample code?

    Thanks!



  • 2.  RE: CloneVM while adding nics and customizing - possible?

    Posted Mar 11, 2010 07:51 AM

    Any particular reason prevent you to add a NIC to your VM template? It seems to me an easy fix.

    Steve JIN

    Author of VMware VI and vSphere SDK (Prentice Hall)

    Creator of open source vSphere (VI) Java API(Tutorial, Testimonials, Download, Samples)

    Blog: DoubleCloud.ORG ( Top 10 Best Practices,[Common Mistakes|http://www.doublecloud.org/2010/01/31/common-mistakes-using-vmware-vi-and-vsphere-sdk/], Tiny REST API)

    Twitter: @sjin2008



  • 3.  RE: CloneVM while adding nics and customizing - possible?

    Posted Mar 11, 2010 08:35 AM

    I simply want to keep my template as generic as possible since not all my VMs require the same number of nics.

    For example: test VMs do not require a nic to the backup LAN while prod VMs do.



  • 4.  RE: CloneVM while adding nics and customizing - possible?

    Posted Mar 11, 2010 03:41 PM

    I see. As you pointed out, there is no way to customize something not there yet. :smileyhappy:

    How about adding a NIC to your template VM and then removing it from clone if you don't need it?

    Steve JIN

    Author of VMware VI and vSphere SDK (Prentice Hall)

    Creator of open source vSphere (VI) Java API(Tutorial, Testimonials, Download, Samples)

    Blog: DoubleCloud.ORG ( Top 10 Best Practices,[Common Mistakes|http://www.doublecloud.org/2010/01/31/common-mistakes-using-vmware-vi-and-vsphere-sdk/], Tiny REST API)

    Twitter: @sjin2008



  • 5.  RE: CloneVM while adding nics and customizing - possible?

    Posted Mar 11, 2010 05:01 PM

    I'll try to elaborate a little more about what I'm trying to do:

    I'm using the CloneVM_Task to clone an existing template into a new VM. The CloneVM_Task needs a CloneSpec, which in turn can containg both a ConfigSpec and a CustomizationSpec.

    The ConfigSpec is used to add a device, change RAM, CPU etc. while the CustomizationSpec is used for customizing elements within the operating system like IP settings for NICs, change computer name, joining the Domain etc.

    When I used only the ConfigSpec to add NICs, it worked. The clone operation was completed and I had a new VM with the new NIC.

    When I used only the CustomizationSpec with a template that already had NICs, it worked. The Clone operation was followed by a sysprep that configured the NICs.

    Then I tried using both specs on a template with no NICs, the clone task immediately failed stating a "mismatch" between the number of NICs in the spec and the number of NICs in the VM.

    What I'm trying to find out is if there is a way to force the clone

    task to skip this check and continue, since the NICs will eventually be

    there when the clone task completes.

    BTW - From my tests I've noticed that customization takes place after the

    clone completes, and (I guess) it involves injecting the sysprep files

    and answer file into the VM's vmdk. So basicaly there should be no problem doing this AFTER the NICs are added.