Add support for offline licenses.
Ref pandora_enterprise#3098.
This commit is contained in:
parent
fd4f848a53
commit
054546fd0f
|
@ -68,6 +68,7 @@ our @EXPORT = qw(
|
||||||
PROVISIONINGSERVER
|
PROVISIONINGSERVER
|
||||||
MIGRATIONSERVER
|
MIGRATIONSERVER
|
||||||
METACONSOLE_LICENSE
|
METACONSOLE_LICENSE
|
||||||
|
OFFLINE_LICENSE
|
||||||
$DEVNULL
|
$DEVNULL
|
||||||
$OS
|
$OS
|
||||||
$OS_VERSION
|
$OS_VERSION
|
||||||
|
@ -93,6 +94,7 @@ our @EXPORT = qw(
|
||||||
sqlWrap
|
sqlWrap
|
||||||
is_numeric
|
is_numeric
|
||||||
is_metaconsole
|
is_metaconsole
|
||||||
|
is_offline
|
||||||
to_number
|
to_number
|
||||||
clean_blank
|
clean_blank
|
||||||
pandora_sendmail
|
pandora_sendmail
|
||||||
|
@ -152,9 +154,12 @@ use constant MODULE_WARNING => 2;
|
||||||
use constant MODULE_UNKNOWN => 3;
|
use constant MODULE_UNKNOWN => 3;
|
||||||
use constant MODULE_NOTINIT => 4;
|
use constant MODULE_NOTINIT => 4;
|
||||||
|
|
||||||
# Value for a metaconsole license type
|
# Mask for a metaconsole license type
|
||||||
use constant METACONSOLE_LICENSE => 0x01;
|
use constant METACONSOLE_LICENSE => 0x01;
|
||||||
|
|
||||||
|
# Mask for an offline license type
|
||||||
|
use constant OFFLINE_LICENSE => 0x02;
|
||||||
|
|
||||||
# Alert modes
|
# Alert modes
|
||||||
use constant RECOVERED_ALERT => 0;
|
use constant RECOVERED_ALERT => 0;
|
||||||
use constant FIRED_ALERT => 1;
|
use constant FIRED_ALERT => 1;
|
||||||
|
@ -1639,7 +1644,7 @@ sub is_metaconsole ($) {
|
||||||
my ($pa_config) = @_;
|
my ($pa_config) = @_;
|
||||||
|
|
||||||
if (defined($pa_config->{"license_type"}) &&
|
if (defined($pa_config->{"license_type"}) &&
|
||||||
$pa_config->{"license_type"} == METACONSOLE_LICENSE &&
|
($pa_config->{"license_type"} & METACONSOLE_LICENSE) &&
|
||||||
$pa_config->{"node_metaconsole"} == 0) {
|
$pa_config->{"node_metaconsole"} == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1647,6 +1652,20 @@ sub is_metaconsole ($) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Returns 1 if a valid offline license is configured, 0 otherwise.
|
||||||
|
###############################################################################
|
||||||
|
sub is_offline ($) {
|
||||||
|
my ($pa_config) = @_;
|
||||||
|
|
||||||
|
if (defined($pa_config->{"license_type"}) &&
|
||||||
|
($pa_config->{"license_type"} & OFFLINE_LICENSE)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Check if a given variable contents a number
|
# Check if a given variable contents a number
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -1042,8 +1042,20 @@ else {
|
||||||
|
|
||||||
# Connect to the DB
|
# Connect to the DB
|
||||||
my $dbh = db_connect ($conf{'dbengine'}, $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
|
my $dbh = db_connect ($conf{'dbengine'}, $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
|
||||||
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ($conf{'dbengine'}, $conf{'_history_db_name'},
|
my $history_dbh = undef;
|
||||||
$conf{'_history_db_host'}, $conf{'_history_db_port'}, $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;
|
is_metaconsole(\%conf);
|
||||||
|
if ($conf{'_history_db_enabled'} eq '1') {
|
||||||
|
eval {
|
||||||
|
$history_dbh = db_connect ($conf{'dbengine'}, $conf{'_history_db_name'}, $conf{'_history_db_host'}, $conf{'_history_db_port'}, $conf{'_history_db_user'}, $conf{'_history_db_pass'});
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
if (is_offline(\%conf)) {
|
||||||
|
log_message ('!', "Cannot connect to the history database. Skipping.");
|
||||||
|
} else {
|
||||||
|
die ("$@\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Get a lock
|
# Get a lock
|
||||||
my $lock = db_get_lock ($dbh, 'pandora_db');
|
my $lock = db_get_lock ($dbh, 'pandora_db');
|
||||||
|
@ -1055,13 +1067,13 @@ if ($lock == 0 && $conf{'_force'} == 0) {
|
||||||
# Main
|
# Main
|
||||||
pandoradb_main(\%conf, $dbh, $history_dbh);
|
pandoradb_main(\%conf, $dbh, $history_dbh);
|
||||||
|
|
||||||
# Cleanup and exit
|
|
||||||
db_disconnect ($history_dbh) if defined ($history_dbh);
|
|
||||||
db_disconnect ($dbh);
|
|
||||||
|
|
||||||
# Release the lock
|
# Release the lock
|
||||||
if ($lock == 1) {
|
if ($lock == 1) {
|
||||||
db_release_lock ($dbh, 'pandora_db');
|
db_release_lock ($dbh, 'pandora_db');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Cleanup and exit
|
||||||
|
db_disconnect ($history_dbh) if defined ($history_dbh);
|
||||||
|
db_disconnect ($dbh);
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
Loading…
Reference in New Issue