Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 249166

Re: Clone VM using existing CustomizationSpec and changing ComputerName property

$
0
0

The "identity" variable from my snippet is a reference of type CustomizationIdentitySettings. Not shown in the snippet,

but I got it from the "identity" property of a CustomizationSpec:

     http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.vm.customization.Specification.html

which I turn read via CustomizationSpecManager, just as you do.

 

If you look up CustomizationIdentitySettings:

     http://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/vim.vm.customization.IdentitySettings.html

you'll see it is an abstract type for one of three concrete types. So my snippet is testing if the object I have

is actually of concrete type "CustomizationSysprep", and if it is casting the reference to that type. The code doesn't

create that object, it's already there, the code just needs to refer to that object using the correct concrete type.

 

The code then creates an object of either type CustomizationFixedName or CustomizationVirtualMachineName (both

of which inherit from abstract type CustomizationName) and adds it to the CustomizationUserData object that is

already attached to the CustomizationSysprep.

 

All these "attachments" are references, so my original CustomizationSpec still refers to my CustomizationSysprep, which

still refers to the same CustomizationUserData, which now refers to this new object I attached to it. That CustomizationSpec

can now be fed back into clone.

 

I don't have a .NET setup, but I'd imagine it would look something like:

 

  CustomizationSysrep winIdentity = (CustomizationSysprep) mySpec.Customization.Identity;  CustomizationFixedName fname = new CustomizationFixedName();  fname.Name = myHostName;  winIdentity.UserData.ComputerName = fname;

Viewing all articles
Browse latest Browse all 249166

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>