0

I am using vSphere CLI 6.5.0 for resetting a VM from a Perl script. This is in the context a (proprietary) STONITH plugin for Pacemaker.

Immediately after STONITH, journalctl -u pacemaker reports a warning in vmcontrol.pl, which belongs to vSphere CLI. The warning is reported by fence_legacy, which belongs to Pacemaker.

Use of uninitialized value $hostname in concatenation (.) or string at 
/opt/vmware-vsphere-cli-distrib/apps/vm/vmcontrol.pl line 168.

The error occurs in a call to UTIL::trace in this context:

sub reset_vm {
   foreach (@$vm_views) {
      my $mor_host = $_->runtime->host;
      my $hostname = Vim::get_view(mo_ref => $mor_host)->name;
      eval {
        $_->ResetVM();
        Util::trace(0, "\nvirtual machine '" . $_->name . "' under host".
                                  " $hostname reset successfully ");
      };

I am wondering whether this is a feature or a bug. Could it be that Vim::get_view communicates with VMware at a time where the hostname cannot be reported (and hence $hostname cannot be initialized) because the VM is rebooting?

It sounds unlikely (e.g because the call to ResetVM occurs after the assignment to $hostname), but I suspect something like this is going on, in which case the warning could be ignored. I also suspect that the problem is related to vSphere CLI alone (i.e. is not caused by its use inside a Pacemaker stack).

rookie09
  • 736
  • 1
  • 6
  • 18
  • As a standalone script, I'm not hitting any issues with vmcontrol. I'm not familiar with the other two items. Have you tried running vmcontrol as a standalone script? – Kyle Ruddy Dec 04 '17 at 23:15
  • @KyleRuddy That's what I'm also planning to do. I'll report back here once it's done. – rookie09 Dec 05 '17 at 07:20

1 Answers1

0

Can you try this one instead.

sub reset_vm {
   foreach $mor_host(@$vm_views) {
     my $hostname = Vim::get_view(mo_ref => $mor_host->runtime->host, properties => );
      eval {
        $_->ResetVM();
        Util::trace(0, "\nvirtual machine '" . $_->name . "' under host".
                                " $hostname reset successfully ");
      };
Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • Thx, but the script `vmcontrol.pl` is part of VMware's vSphere CLI product, and I don't want to touch/patch that at all. – rookie09 Dec 01 '17 at 13:49