]> git.proxmox.com Git - pve-ha-manager.git/blobdiff - src/PVE/HA/Tools.pm
add auto completion helper for service IDs and HA groups
[pve-ha-manager.git] / src / PVE / HA / Tools.pm
index 896b7ab3d95995cfa886dad71ed4cca093b2d92e..9eec7c4257802405188377f2359bd3386a5354a3 100644 (file)
@@ -138,4 +138,43 @@ sub count_fenced_services {
     return $count;
 }
 
+# bash auto completion helper
+
+sub complete_sid {
+
+    my $vmlist = PVE::Cluster::get_vmlist();
+
+    my $res = [];
+    while (my ($vmid, $info) = each %{$vmlist->{ids}}) {
+
+       my $sid = '';
+
+       if ($info->{type} eq 'lxc') {
+           $sid .= 'ct:';
+       } elsif ($info->{type} eq 'qemu') {
+           $sid .= 'vm:';
+       }
+
+       $sid .= $vmid;
+
+       push @$res, $sid;
+
+    }
+
+    return $res;
+}
+
+sub complete_group {
+
+    my $cfg = PVE::HA::Config::read_group_config();
+
+    my $res = [];
+    foreach my $group (keys %{$cfg->{ids}}) {
+       push @$res, $group;
+    }
+
+    return $res;
+}
+
+
 1;