HomeClusterLabs Projects

fence_vbox: fix status-based actions

Description

fence_vbox: fix status-based actions

The status action (and any other status-based actions, like off,
which checks the status beforehand) was broken - it always
returned OFF for all the virtual nodes, even for the running ones:

$ fence_vbox -o list-status -a 10.0.2.2 -l 520414 --host-os=macos -k .ssh/id_rsa
centos_1905.1_pod-c1,0872858e-132e-44bc-89fe-23f7608cadb0,off
centos_1905.1_cmu,f9172ad8-0700-4c65-9aac-304f60175f44,off
centos-7-1-1.x86_64_1572001960195_51877,d8e19439-3cc7-43fc-8fd4-16b8c673f8f4,off
centos_1905.1_pod-c2,5eef6fe9-de25-4891-8326-d440a633d6a9,off
$ fence_vbox -o status -a 10.0.2.2 -l 520414 --host-os=macos -k .ssh/id_rsa --plug centos_1905.1_pod-c2
Status: OFF
$ fence_vbox -o off -a 10.0.2.2 -l 520414 --host-os=macos -k .ssh/id_rsa --plug centos_1905.1_pod-c2
Success: Already OFF

The logs added to the get_outlets_status() function revealed, that
the VBoxManage list runningvms command did not return the list of
running nodes, instead, it would always return a special symbol:

$ ./fence_vbox -o list-status -a 10.0.2.2 -l 520414 --host-os=macos -k .ssh/id_rsa
['/Applications/VirtualBox.app/Contents/MacOS/VBoxManage list vms', '"centos-7-1-1.x86_64_1572001960195_51877" {d8e19439-3cc7-43fc-8fd4-16b8c673f8f4}', '"centos_1905.1_pod-c1" {0872858e-132e-44bc-89fe-23f7608cadb0}', '"centos_1905.1_pod-c2" {5eef6fe9-de25-4891-8326-d440a633d6a9}', '"centos_1905.1_cmu" {f9172ad8-0700-4c65-9aac-304f60175f44}']
['/Applications/VirtualBox.app/Contents/MacOS/VBoxManage list runningvms ', '\x1b[A']
centos_1905.1_pod-c1,0872858e-132e-44bc-89fe-23f7608cadb0,off
centos_1905.1_cmu,f9172ad8-0700-4c65-9aac-304f60175f44,off
centos-7-1-1.x86_64_1572001960195_51877,d8e19439-3cc7-43fc-8fd4-16b8c673f8f4,off
centos_1905.1_pod-c2,5eef6fe9-de25-4891-8326-d440a633d6a9,off

The problem was fixed by removing the trailing space from the PS1
bash prompt.

Event Timeline