VMware {code} Community
jqvm
Enthusiast
Enthusiast

enum datatype usage

Does anyone know the correct usage to create/set an enum type object? The user guide doco states the following:

To set a property (defined as an enum) on a data object:

$ref = new enum_type (val => value;)

For example, $power_state = new VirtualMachinePowerState (val => 'poweredOff');

When I data dump this object it doesn't set the val field though:

my $power_state = new VirtualMachinePowerState (val => 'poweredOff');

print Dumper($power_state);

Result:

$VAR1 = bless( {

'val' => 'val'

}, 'VirtualMachinePowerState' );

0 Kudos
1 Reply
hrobinson
VMware Employee
VMware Employee

Change to

my $power_state = new VirtualMachinePowerState ('poweredOff');

and it should work.

0 Kudos