[pve-devel] [PATCH pve-ha-manager] enhance ha-managers' group commands
Dietmar Maurer
dietmar at proxmox.com
Sun Sep 20 10:04:31 CEST 2015
applied, but changed command names to be consistent
groupcfg => groupconfig
groupdel => groupremove
(we use suffix config/add/remove/set)
On 09/18/2015 08:19 AM, Thomas Lamprecht wrote:
> add commands for adding, deleting and modifying groups. Also add
> better bash completion for these commands.
>
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
> src/PVE/CLI/ha_manager.pm | 6 +++++-
> src/PVE/HA/Groups.pm | 5 ++++-
> src/PVE/HA/Tools.pm | 9 +++++++--
> 3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/src/PVE/CLI/ha_manager.pm b/src/PVE/CLI/ha_manager.pm
> index d858d8e..ec466f2 100644
> --- a/src/PVE/CLI/ha_manager.pm
> +++ b/src/PVE/CLI/ha_manager.pm
> @@ -136,7 +136,7 @@ our $cmddef = {
> }
> print "\n";
> }}],
> - groups => [ 'PVE::API2::HA::Groups', 'index', [], {}, sub {
> + groupcfg => [ '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'] ],
> + groupdel => [ "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'] ],
> diff --git a/src/PVE/HA/Groups.pm b/src/PVE/HA/Groups.pm
> index 3b4338f..2e9fe13 100644
> --- a/src/PVE/HA/Groups.pm
> +++ b/src/PVE/HA/Groups.pm
> @@ -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 }),
> diff --git a/src/PVE/HA/Tools.pm b/src/PVE/HA/Tools.pm
> index 95098b3..4a5c2e3 100644
> --- a/src/PVE/HA/Tools.pm
> +++ b/src/PVE/HA/Tools.pm
> @@ -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;
More information about the pve-devel
mailing list