Hello,
i am struggling with the fine-tuning of my workflow fo VM creation.
As you probably know, when creating a VM, the guestOS needs to be set.
At first, i've set the input type to vmGuestOsIdentifier, but this didn't look so nice, because the IDs aren't exactly like the original OS-names (e.g. "winLonghorn" is "Windows Server 2008 32-bit").
So i've created a list of all the OS names, that are being used on our VMs, set the input type to string and set the list as a list of predefined elements.
Nonetheless i still need to have a variable of the type vmGuestOsIdentifier which needs to be set, but now within a scriptable task.
And that's what i'm struggling with.
How can i set the the vmGuestOsIdentifier within a scriptable task?
Thanks and
Regards
Andreas
HI Andreas,
My bad. I should carefully use the documentation. The purpose of the fromString method is to convert a well-known enum value to enum. For example, it can be used as
VcVirtualMachineGuestOsIdentifier.fromString("darwin64Guest")
This will result in
VcVirtualMachineGuestOsIdentifier.darwin64Guest
On other hand, because the description column http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.GuestOsDescriptor.Gue... from here should be localized thus the VC objects from the VC plugin,
the VC itself exposes the same values.Thus everybody that wants friendly names should handle it case-by-case.
So in your case since you have the friendly names, you should bind them to the specific VcVirtualMachineGuestOsIdentifier values. Ugly hack, but this is the current implementation. Sorry.
Regards,
--Martin
Hi Andreas,
If I understand you correct, you have a predefined list with all OS names (full description) you are using in your organization. As a result you need to find out how to get an individual OS's identified. If this is the case, the type VcVirtualMachineGuestOsIdentifier has a fromString method which will return you the correct OS identifier.
If I miss something, please elaborate further.
Regards,
--Martin
Hi Martin,
i already tried using the fromString method, but no matter how i use it, it always runs into an error.
I tried:
vmGuestOSID = VcVirtualMachineGuestOsIdentifier().fromString(vmGuestOsString) ;
This fails with: Cannot call method "fromString" of null
I also tried things like this:
vmGuestOSID.fromString(vmGuestOsString) ;
But this encounters the same error.
HI Andreas,
My bad. I should carefully use the documentation. The purpose of the fromString method is to convert a well-known enum value to enum. For example, it can be used as
VcVirtualMachineGuestOsIdentifier.fromString("darwin64Guest")
This will result in
VcVirtualMachineGuestOsIdentifier.darwin64Guest
On other hand, because the description column http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.GuestOsDescriptor.Gue... from here should be localized thus the VC objects from the VC plugin,
the VC itself exposes the same values.Thus everybody that wants friendly names should handle it case-by-case.
So in your case since you have the friendly names, you should bind them to the specific VcVirtualMachineGuestOsIdentifier values. Ugly hack, but this is the current implementation. Sorry.
Regards,
--Martin
Since this is the very thing that I was looking for I thought I would follow up with an example to make sure that I understand this. The following code should give me the VcVirtualMachineGuestOsIdentifier object for the darwin64Guest guest OS.
var GuestOSID = new VcVirtualMachineGuestOsIdentifier();
GuestOSID = VcVirtualMachineGuestOsIdentifier.fromString("darwin64Guest");
I could then pass GuestOSID to a workflow that wanted a parameter of type VC:VirtualMachineGuestOsIdentifier that could then create a vm set up for that guest OS.
Is this what we are saying?
Thanks!
I am attempting to do pretty much the same thing in a scriptable task but I keep getting an error when I run:
Unable to create object : VcVirtualMachineGuestOsIdentifier
Anyone have an idea what would be causing this to fail?
Paul
I'm also getting:
Unable to create object : VcVirtualMachineGuestOsIdentifier
Were you able to resolve?
Try this:
var virtualMachineGuestOsIdentifier = VcVirtualMachineGuestOsIdentifier.darwin64Guest;
Christophe.
I mean
var virtualMachineGuestOsIdentifier = VcVirtualMachineGuestOsIdentifier.fromString("darwin64Guest");
Christophe.
Also a sample workflow on how to make the presentation looks nicer to display OS names.
Christophe.