]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
enhance ha-managers' group commands
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Sep 2015 06:19:37 +0000 (08:19 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sun, 20 Sep 2015 08:01:23 +0000 (10:01 +0200)
add commands for adding, deleting and modifying groups. Also add
better bash completion for these commands.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/CLI/ha_manager.pm
src/PVE/HA/Groups.pm
src/PVE/HA/Tools.pm

index d858d8efd0a1c127c3f7c008fe7da9146311d40d..35b8d0e9c7bbebec75e08472401af30e146001e7 100644 (file)
@@ -136,7 +136,7 @@ our $cmddef = {
            }
            print "\n";
        }}],
-    groups => [ 'PVE::API2::HA::Groups', 'index', [], {}, sub {
+    groupconfig => [ 'PVE::API2::HA::Groups', 'index', [], {}, sub {
        my $res = shift;
        foreach my $rec (sort { $a->{group} cmp $b->{group} } @$res) {
            print "group: $rec->{group}\n";
@@ -147,6 +147,10 @@ our $cmddef = {
            }
            print "\n";
        }}],
+    groupadd => [ "PVE::API2::HA::Groups", 'create', ['group'] ],
+    groupremove => [ "PVE::API2::HA::Groups", 'delete', ['group'] ],
+    groupset => [ "PVE::API2::HA::Groups", 'update', ['group'] ],
+
     add => [ "PVE::API2::HA::Resources", 'create', ['sid'] ],
     remove => [ "PVE::API2::HA::Resources", 'delete', ['sid'] ],
     set => [ "PVE::API2::HA::Resources", 'update', ['sid'] ],
index 3b4338f1627533209c415221f27fb6c5ee82715c..2e9fe13f1b7006baf5808b10902cab20daafbc32 100644 (file)
@@ -12,7 +12,10 @@ use base qw(PVE::SectionConfig);
 
 my $defaultData = {
     propertyList => {
-       type => { description => "Section type." },
+       type => {
+           description => "Group type.",
+           optional => 1,
+       },
        group => get_standard_option('pve-ha-group-id',
                                    { completion => \&PVE::HA::Tools::complete_group }),
        nodes => get_standard_option('pve-ha-group-node-list', { optional => 1 }),
index 95098b33959d78d11e14eb494215956e8cada823..4a5c2e351f3e7f961f25b2f2a8882a5ac1f92985 100644 (file)
@@ -207,12 +207,17 @@ sub complete_disabled_sid {
 }
 
 sub complete_group {
+    my ($cmd, $pname, $cur) = @_;
 
     my $cfg = PVE::HA::Config::read_group_config();
 
     my $res = [];
-    foreach my $group (keys %{$cfg->{ids}}) {
-       push @$res, $group;
+    if ($cmd ne 'groupadd') {
+
+       foreach my $group (keys %{$cfg->{ids}}) {
+           push @$res, $group;
+       }
+
     }
 
     return $res;