Quantcast
Channel: VMware Communities : All Content - vSphere Management Assistant (vMA)
Viewing all articles
Browse latest Browse all 482

How to set advanced host options w/ Perl SDK?

$
0
0

I want to write a script that will let me set advanced host options, so I can roll them out to all of my hosts in one go vs. touching each host. I have the Enterprise license so I don't have host profiles - scripts are the best option for me. I'm trying to use the UpdateOptions() method to an OptionManager object to make this happen.

 

The problem I'm having is identical to the one in this discussion: http://communities.vmware.com/message/686401, but the accepted solution is not working for me. Neither my own code nor the script attached to the other discussion will work.

 

For example, if I try to change the value of NFS.SendBufferSize to any valid, I get a response like this:

 

$ perl ./advoptions.pl --server vcenter --host vm1 --name NFS.SendBufferSize --value 64
Changing option NFS.SendBufferSize to 64.
SOAP Fault:
-----------
Fault string: A specified parameter was not correct.
Fault detail: InvalidArgumentFault

This occurs whether I treat the new value as an integer, a string, or use PrimType to set one or the other. It occurs whether I create a new OptionValue instance or change the value of an existing one and submit that. I've tried on a vMA instance (5.0.0.0-472630) as well as a CentOS 6.3 x86_64 host w/ perl 5.10.1 and the perl SDK build 4.1.0-254719, with identical results. Same issue whether I connect to the vCenter server or to a VM host directly.
Here is some sample code. It's similar to the script attached to the other discussion and fails the same way.
#!/usr/bin/perl -w

use strict;
use VMware::VIRuntime;

$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;

Opts::parse();
Opts::validate();

Util::connect();

my $entities = Vim::find_entity_views(
                view_type => 'HostSystem',
                properties => ['configManager'],
                );

foreach my $entity (@$entities) {

        my $optionManager = Vim::get_view(mo_ref => $entity->configManager->advancedOption);

        my $sendBuffer = new OptionValue (key => 'NFS.SendBufferSize', value => PrimType->new('64', 'int') );
        eval { $optionManager->UpdateOptions( changedValue => [$sendBuffer] ); };

        print $@ if ($@);
}

Util::disconnect();

What am I doing wrong here? Any pointers would be appreciated.

Viewing all articles
Browse latest Browse all 482

Trending Articles