[pve-devel] [PATCH pve-ha-manager 1/2] add auto completion helper for service IDs and HA groups

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Sep 15 09:27:36 CEST 2015


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Tools.pm | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/PVE/HA/Tools.pm b/src/PVE/HA/Tools.pm
index 896b7ab..9eec7c4 100644
--- a/src/PVE/HA/Tools.pm
+++ b/src/PVE/HA/Tools.pm
@@ -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;
-- 
2.1.4




More information about the pve-devel mailing list