mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
Merge branch 'ent-8224-Se-puede-crear/editar/borrar-un-grupo-desde-el-CLI-en-nodo-centralizado' into 'develop'
Ent 8224 se puede crear/editar/borrar un grupo desde el cli en nodo centralizado See merge request artica/pandorafms!4542
This commit is contained in:
commit
f66d6e7f9c
@ -343,6 +343,23 @@ sub update_conf_txt ($$$$) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
# PRINT HELP AND CHECK ERRORS FUNCTIONS
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# log wrapper
|
||||
###############################################################################
|
||||
sub print_log ($) {
|
||||
my ($msg) = @_;
|
||||
|
||||
print $msg; # show message
|
||||
|
||||
$msg =~ s/\n+$//;
|
||||
logger( $conf, "($progname) $msg", 10); # save to logging file
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Disable a entire group
|
||||
@ -353,6 +370,11 @@ sub pandora_disable_group ($$$) {
|
||||
my @agents_bd = [];
|
||||
my $result = 0;
|
||||
|
||||
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
|
||||
print_log "[ERROR] This node is configured with centralized mode. To disable a group go to metaconsole. \n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($group == 0){
|
||||
# Extract all the names of the pandora agents if it is for all = 0.
|
||||
@agents_bd = get_db_rows ($dbh, 'SELECT nombre FROM tagente');
|
||||
@ -390,6 +412,11 @@ sub pandora_enable_group ($$$) {
|
||||
my @agents_bd = [];
|
||||
my $result = 0;
|
||||
|
||||
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
|
||||
print_log "[ERROR] This node is configured with centralized mode. To enable a group go to metaconsole. \n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($group == 0){
|
||||
# Extract all the names of the pandora agents if it is for all = 0.
|
||||
@agents_bd = get_db_rows ($dbh, 'SELECT nombre FROM tagente');
|
||||
@ -976,7 +1003,7 @@ sub pandora_get_calendar_id ($$) {
|
||||
sub pandora_get_same_day_id ($$) {
|
||||
my ($dbh, $same_day) = @_;
|
||||
|
||||
my $weeks = { 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6, 'sunday' => 7, 'holiday' => 8};
|
||||
my $weeks = { 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6, 'sunday' => 7, 'holiday' => 8 };
|
||||
|
||||
return defined ($weeks->{$same_day}) ? $weeks->{$same_day} : -1;
|
||||
}
|
||||
@ -998,25 +1025,6 @@ sub pandora_delete_special_day ($$) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
# PRINT HELP AND CHECK ERRORS FUNCTIONS
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# log wrapper
|
||||
###############################################################################
|
||||
sub print_log ($) {
|
||||
my ($msg) = @_;
|
||||
|
||||
print $msg; # show message
|
||||
|
||||
$msg =~ s/\n+$//;
|
||||
logger( $conf, "($progname) $msg", 10); # save to logging file
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Print a parameter error and exit the program.
|
||||
###############################################################################
|
||||
@ -5523,7 +5531,7 @@ sub cli_get_agents() {
|
||||
|
||||
my $head_print = 0;
|
||||
|
||||
use Data::Dumper;
|
||||
# use Data::Dumper;
|
||||
|
||||
|
||||
foreach my $agent (@agents) {
|
||||
@ -5850,7 +5858,12 @@ sub cli_get_planned_downtimes_items() {
|
||||
|
||||
sub cli_create_group() {
|
||||
my ($group_name,$parent_group_name,$icon,$description) = @ARGV[2..5];
|
||||
|
||||
|
||||
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
|
||||
print_log "[ERROR] This node is configured with centralized mode. To create a group go to metaconsole. \n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
my $group_id = get_group_id($dbh,$group_name);
|
||||
non_exist_check($group_id, 'group name', $group_name);
|
||||
|
||||
@ -5922,6 +5935,11 @@ sub cli_create_group() {
|
||||
sub cli_delete_group() {
|
||||
my ($group_name) = @ARGV[2];
|
||||
|
||||
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
|
||||
print_log "[ERROR] This node is configured with centralized mode. To delete a group go to metaconsole. \n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
my $group_id = get_group_id($dbh,$group_name);
|
||||
exist_check($group_id, 'group name', $group_name);
|
||||
|
||||
@ -5946,6 +5964,11 @@ sub cli_update_group() {
|
||||
my ($group_id,$group_name,$parent_group_name,$icon,$description) = @ARGV[2..6];
|
||||
my $result;
|
||||
|
||||
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
|
||||
print_log "[ERROR] This node is configured with centralized mode. To update a group go to metaconsole. \n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = get_db_value ($dbh, 'SELECT * FROM tgrupo WHERE id_grupo=?', $group_id);
|
||||
|
||||
if($result == "0E0"){
|
||||
|
Loading…
x
Reference in New Issue
Block a user