VMware {code} Community
equipesysteme
Contributor
Contributor
Jump to solution

catch fault exeption on UpgradeTools_Task

hi all,

I'm trying to automate update/install of vmware tool in virtual machine but this simple test code aren't work.

I can see error in VSphere console but i can't handle fault

my $vm_view = Vim::find_entity_view( view_type => 'VirtualMachine',
                                         filter => { 'name' => qr/^$vm$/i },
  eval {

    $vm_view->UpgradeTools_Task ;

   } ;

  if ( $@ ) {

    print "erreur\n" ;

    $@->faultMessage() ;

    print Dumper $@ ;

  }

thanks for help

Reply
0 Kudos
1 Solution

Accepted Solutions
stumpr
Virtuoso
Virtuoso
Jump to solution

There are some methods in the API that have a non-task option, such as UpgradeTools.  In those cases, you can call either, but I'm not sure how offical the non _task() version of the call will be in the future.

If you use the Task version, you have to query the task to get the state of the task execution, including error code.  If you use the non-task version, you can probably rely on an eval to catch the SOAP error message.

Reuben Stump | http://www.virtuin.com | @ReubenStump

View solution in original post

Reply
0 Kudos
2 Replies
equipesysteme
Contributor
Contributor
Jump to solution

There are a lot of diference between API reference docuementation and reality.

In this simple example i use UpgradeTools_Task than i read in documentation refence but to catch error status i should use UpgradeTools
Reply
0 Kudos
stumpr
Virtuoso
Virtuoso
Jump to solution

There are some methods in the API that have a non-task option, such as UpgradeTools.  In those cases, you can call either, but I'm not sure how offical the non _task() version of the call will be in the future.

If you use the Task version, you have to query the task to get the state of the task execution, including error code.  If you use the non-task version, you can probably rely on an eval to catch the SOAP error message.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos