Hi all,
I am looking for some performance improvements for some of my scripts.
One thing that would help me a lot would be to expand a view afterwards.
Lets have an example. I get a trimed down HostSystem view by using "properties". Later in the script I need to view some values from the summary of this host and now it would be great to expand the view to the properties "name" and "summary".
my $host_view = Vim::find_entity_view(view_type => 'HostSystem', properties => ['name'], filter => {'name' => qr/hostname/i});
print $host_view->{name};
#....
#expand $host_view to have summary hash
print $host_view->{summary}->{runtime};
Of course I could insert 'summary' in the properties array in this simple example. But, there are situations where maby the summary hash is not used due some not matched conditions and so it would have been loaded for nothing.
Any ideas how to do this?
Thanks in advance,
Chris
It's not documented but update_view_data() accepts a properties array as a parameter:
#!/usr/bin/perl
use strict;
use warnings;
use VMware::VIRuntime;
Opts::parse();
Opts::validate();
Util::connect();
my $vm = Vim::find_entity_view(view_type => 'VirtualMachine', properties => ['name']);
# Add some additional properties:
$vm->update_view_data(['guest.guestFullName']);
print "VM: " . $vm->{'name'} . "; " . $vm->{'guest.guestFullName'} . "\n";
$ perl update_view_test.pl --server=172.16.254.10 --username=administrator --password=VMware1!
VM: ESXI-55u2-N-TMPL; Other Linux (64-bit)
One thing to consider: the properties array passed just updates those properties. For example, if the 'name' property was modified between invocations, it would remain the old value in your script object. You can, of course, add the 'name' property to the properties array in the update_view_data() call to get any changes that might have occurred between invocations.
It's not documented but update_view_data() accepts a properties array as a parameter:
#!/usr/bin/perl
use strict;
use warnings;
use VMware::VIRuntime;
Opts::parse();
Opts::validate();
Util::connect();
my $vm = Vim::find_entity_view(view_type => 'VirtualMachine', properties => ['name']);
# Add some additional properties:
$vm->update_view_data(['guest.guestFullName']);
print "VM: " . $vm->{'name'} . "; " . $vm->{'guest.guestFullName'} . "\n";
$ perl update_view_test.pl --server=172.16.254.10 --username=administrator --password=VMware1!
VM: ESXI-55u2-N-TMPL; Other Linux (64-bit)
One thing to consider: the properties array passed just updates those properties. For example, if the 'name' property was modified between invocations, it would remain the old value in your script object. You can, of course, add the 'name' property to the properties array in the update_view_data() call to get any changes that might have occurred between invocations.
great stumpr!
Thank you very much!
Would you mind using it in production, since it is not documented?
Chris
Yeah, it's good. That call is documented, just not the parameter. And it's just sending in a property list, nothing fancy there. You could implement the function yourself if you really wanted.
