VMware Cloud Community
Aramaki
Contributor
Contributor
Jump to solution

How to set vmGuestOsIdentifier within of a scriptable task?

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

0 Kudos
1 Solution

Accepted Solutions
mmarinov
VMware Employee
VMware Employee
Jump to solution

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

Martin Marinov VMware Software Engineer If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points

View solution in original post

0 Kudos
9 Replies
mmarinov
VMware Employee
VMware Employee
Jump to solution

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

Martin Marinov VMware Software Engineer If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points
0 Kudos
Aramaki
Contributor
Contributor
Jump to solution

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.

0 Kudos
mmarinov
VMware Employee
VMware Employee
Jump to solution

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

Martin Marinov VMware Software Engineer If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points
0 Kudos
colinj
Contributor
Contributor
Jump to solution

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!

0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

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

0 Kudos
MicahGaither
Contributor
Contributor
Jump to solution

I'm also getting:

Unable to create object : VcVirtualMachineGuestOsIdentifier

Were you able to resolve?

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Try this:

var virtualMachineGuestOsIdentifier = VcVirtualMachineGuestOsIdentifier.darwin64Guest;

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I mean

var virtualMachineGuestOsIdentifier = VcVirtualMachineGuestOsIdentifier.fromString("darwin64Guest");

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Also a sample workflow on how to make the presentation looks nicer to display OS names.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos