vSphere

 View Only
  • 1.  catch fault exeption on UpgradeTools_Task

    Posted Oct 04, 2012 04:27 PM

    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



  • 2.  RE: catch fault exeption on UpgradeTools_Task

    Posted Oct 05, 2012 08:15 AM

    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


  • 3.  RE: catch fault exeption on UpgradeTools_Task
    Best Answer

    Posted Oct 05, 2012 07:09 PM

    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.