VMware {code} Community
jumsky79
Contributor
Contributor
Jump to solution

Perl script to create role for ESX 4.0

======================================================================

my $host_view = Vim::find_entity_view(view_type => 'Folder', filter => {'name' => 'ha-folder-root'});

my $auth_mgr = Vim::get_view(mo_ref => Vim::get_service_content()->authorizationManager);

my $role = "test-role";

my @roleprivIds = ('Datastore.Browse','Global.ManageCustomFields');

$auth_mgr->AddAuthorizationRole(name => $role, privIds => \@roleprivIds);

======================================================================

This code succeed on ESX 3.5.

but it fail on ESX 4.0.

 Can't locate object method "deserialize" via package "ArrayOfTag" (perhaps you f

 orgot to load "ArrayOfTag"?) at C:/Program Files/VMware/VMware vSphere CLI/Perl/

 lib/VMware/VICommon.pm line 2030.

Does anyone have any code to create a role for ESX 4.0?

Any help is greatly appreciated!

help me.

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

Take a look at this script:

Works both on ESX(i) 3.5 and 4.0 and on vCenter 4.0 (don't have a spare vCenter 2.5 to test)

Note: Test was done on vMA 4.0

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
3 Replies
lamw
Community Manager
Community Manager
Jump to solution

Take a look at this script:

Works both on ESX(i) 3.5 and 4.0 and on vCenter 4.0 (don't have a spare vCenter 2.5 to test)

Note: Test was done on vMA 4.0

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
jumsky79
Contributor
Contributor
Jump to solution

Thank you

I succeeded by using createRole.pl on ESXi4.0.

Test was done on windows(Perl for SDK)

0 Kudos
pbsellers
Contributor
Contributor
Jump to solution

I know you've already found a working solution, but I had a different type script throwing the same error and so I wanted to post for anyone else who may be seeing this problem.

Error: Can't locate object method "deserialize" via package "ArrayOfTag" (perhaps you forgot to load "ArrayOfTag"?) at /usr/lib/perl5/5.8.8/VMware/VICommon.pm line 2030.

I found the root cause in my script and I suspect in your original script. The working ESX 3.5 script probably included:

use VMware::VIM2Runtime

To work with the ESX 4.0 or vMA 4.0, you should instead have:

use VMware::VIRuntime

This cleared up my issue.

0 Kudos