MigrationServer aux util
This commit is contained in:
parent
c8118c2e08
commit
7d58734ef2
|
@ -3086,11 +3086,15 @@ create table IF NOT EXISTS `tcluster_agent`(
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
|
|
||||||
create table IF NOT EXISTS `tmigration_queue`(
|
create table IF NOT EXISTS `tmigration_queue`(
|
||||||
`id_metaconsole_agent` int unsigned not null auto_increment,
|
`id` int unsigned not null auto_increment,
|
||||||
|
`id_source_agent` int unsigned not null,
|
||||||
|
`id_target_agent` int unsigned not null,
|
||||||
`id_source_node` int unsigned not null,
|
`id_source_node` int unsigned not null,
|
||||||
`id_target_node` int unsigned not null,
|
`id_target_node` int unsigned not null,
|
||||||
`priority` int unsigned default 0,
|
`priority` int unsigned default 0,
|
||||||
`step` int unsigned default 0
|
`step` int unsigned default 0,
|
||||||
|
`running` tinyint(2) unsigned not null default 0,
|
||||||
|
PRIMARY KEY(`id`)
|
||||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
|
@ -3098,9 +3102,16 @@ create table IF NOT EXISTS `tmigration_queue`(
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
|
|
||||||
create table IF NOT EXISTS `tmigration_module_queue`(
|
create table IF NOT EXISTS `tmigration_module_queue`(
|
||||||
|
`id` int unsigned not null auto_increment,
|
||||||
|
`id_migration` int unsigned not null,
|
||||||
`id_source_node` int unsigned not null,
|
`id_source_node` int unsigned not null,
|
||||||
`id_target_node` int unsigned not null,
|
`id_target_node` int unsigned not null,
|
||||||
`id_source_agentmodule` int unsigned not null,
|
`id_source_agentmodule` int unsigned not null,
|
||||||
`id_target_agentmodule` int unsigned not null,
|
`id_target_agentmodule` int unsigned not null,
|
||||||
`last_replication_timestamp` bigint(20) NOT NULL default 0
|
`last_replication_timestamp` bigint(20) NOT NULL default 0,
|
||||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
PRIMARY KEY(`id`),
|
||||||
|
FOREIGN KEY(`id_migration`) REFERENCES tmigration_queue(`id`)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ our @EXPORT = qw(
|
||||||
db_get_lock
|
db_get_lock
|
||||||
db_insert
|
db_insert
|
||||||
db_insert_get_values
|
db_insert_get_values
|
||||||
|
db_insert_from_hash
|
||||||
db_process_insert
|
db_process_insert
|
||||||
db_process_update
|
db_process_update
|
||||||
db_release_lock
|
db_release_lock
|
||||||
|
@ -900,6 +901,29 @@ sub db_process_insert($$$$;@) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
## SQL insert from hash
|
||||||
|
## 1st: dbh
|
||||||
|
## 2nd: table name,
|
||||||
|
## 2nd: {field => value} ref
|
||||||
|
########################################################################
|
||||||
|
sub db_insert_from_hash {
|
||||||
|
my ($dbh, $index, $table, $data) = @_;
|
||||||
|
|
||||||
|
my @fields = keys %{$data};
|
||||||
|
my $values_prep = "";
|
||||||
|
my @values = values %{$data};
|
||||||
|
my $nfields = scalar @fields;
|
||||||
|
|
||||||
|
for (my $i=0; $i<$nfields; $i++) {
|
||||||
|
$values_prep .= "?,";
|
||||||
|
}
|
||||||
|
$values_prep =~ s/,$//;
|
||||||
|
|
||||||
|
return db_insert($dbh, $index, "INSERT INTO " . $table . " (" . join (",", @fields) . ") VALUES ($values_prep)", @values);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
## SQL update.
|
## SQL update.
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
|
@ -27,6 +27,7 @@ use Encode;
|
||||||
use Socket qw(inet_ntoa inet_aton);
|
use Socket qw(inet_ntoa inet_aton);
|
||||||
use Sys::Syslog;
|
use Sys::Syslog;
|
||||||
use Scalar::Util qw(looks_like_number);
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use LWP::UserAgent;
|
||||||
|
|
||||||
# New in 3.2. Used to sendmail internally, without external scripts
|
# New in 3.2. Used to sendmail internally, without external scripts
|
||||||
# use Module::Loaded;
|
# use Module::Loaded;
|
||||||
|
@ -62,8 +63,9 @@ our @EXPORT = qw(
|
||||||
TRANSACTIONALSERVER
|
TRANSACTIONALSERVER
|
||||||
SYNCSERVER
|
SYNCSERVER
|
||||||
SYSLOGSERVER
|
SYSLOGSERVER
|
||||||
METACONSOLE_LICENSE
|
|
||||||
WUXSERVER
|
WUXSERVER
|
||||||
|
MIGRATIONSERVER
|
||||||
|
METACONSOLE_LICENSE
|
||||||
$DEVNULL
|
$DEVNULL
|
||||||
$OS
|
$OS
|
||||||
$OS_VERSION
|
$OS_VERSION
|
||||||
|
@ -74,7 +76,8 @@ our @EXPORT = qw(
|
||||||
MODULE_WARNING
|
MODULE_WARNING
|
||||||
MODULE_UNKNOWN
|
MODULE_UNKNOWN
|
||||||
MODULE_NOTINIT
|
MODULE_NOTINIT
|
||||||
cron_get_closest_in_range
|
api_call_url
|
||||||
|
cron_get_closest_in_range
|
||||||
cron_next_execution
|
cron_next_execution
|
||||||
cron_next_execution_date
|
cron_next_execution_date
|
||||||
cron_check_syntax
|
cron_check_syntax
|
||||||
|
@ -133,6 +136,7 @@ use constant MFSERVER => 15;
|
||||||
use constant SYNCSERVER => 16;
|
use constant SYNCSERVER => 16;
|
||||||
use constant WUXSERVER => 17;
|
use constant WUXSERVER => 17;
|
||||||
use constant SYSLOGSERVER => 18;
|
use constant SYSLOGSERVER => 18;
|
||||||
|
use constant MIGRATIONSERVER => 19;
|
||||||
|
|
||||||
# Module status
|
# Module status
|
||||||
use constant MODULE_NORMAL => 0;
|
use constant MODULE_NORMAL => 0;
|
||||||
|
@ -1708,6 +1712,35 @@ sub uri_encode_literal_percent {
|
||||||
} ## end sub uri_encode_literal_percent
|
} ## end sub uri_encode_literal_percent
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Launch API call
|
||||||
|
################################################################################
|
||||||
|
sub api_call_url {
|
||||||
|
my ($pa_config, $server_url, $api_params, @options) = @_;
|
||||||
|
|
||||||
|
|
||||||
|
my $ua = LWP::UserAgent->new();
|
||||||
|
$ua->timeout($options->{lwp_timeout});
|
||||||
|
# Enable environmental proxy settings
|
||||||
|
$ua->env_proxy;
|
||||||
|
# Enable in-memory cookie management
|
||||||
|
$ua->cookie_jar( {} );
|
||||||
|
|
||||||
|
# Disable verify host certificate (only needed for self-signed cert)
|
||||||
|
$ua->ssl_opts( 'verify_hostname' => 0 );
|
||||||
|
$ua->ssl_opts( 'SSL_verify_mode' => 0x00 );
|
||||||
|
|
||||||
|
my $response;
|
||||||
|
|
||||||
|
eval {
|
||||||
|
$response = $ua->post($server_url, $api_params, @options);
|
||||||
|
};
|
||||||
|
if ((!$@) && $response->is_success) {
|
||||||
|
return $response->decoded_content;
|
||||||
|
}
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
# End of function declaration
|
# End of function declaration
|
||||||
# End of defined Code
|
# End of defined Code
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue