WIP agent deployment

This commit is contained in:
fbsanchez 2019-07-16 20:56:47 +02:00
parent 3bbd01026e
commit f0bfe6910d
6 changed files with 119 additions and 63 deletions

View File

@ -30,7 +30,7 @@ CREATE TABLE `tdeployment_hosts` (
`arch` ENUM('x64', 'x86') DEFAULT 'x64',
`current_agent_version` VARCHAR(100) DEFAULT '',
`desired_agent_version` VARCHAR(100) DEFAULT '',
`deployed` bigint(20) unsigned COMMENT "When it was deployed",
`deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed",
`last_err` text,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`)

View File

@ -2246,7 +2246,7 @@ CREATE TABLE `tdeployment_hosts` (
`arch` ENUM('x64', 'x86') DEFAULT 'x64',
`current_agent_version` VARCHAR(100) DEFAULT '',
`desired_agent_version` VARCHAR(100) DEFAULT '',
`deployed` bigint(20) unsigned COMMENT "When it was deployed",
`deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed",
`last_err` text,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`)

View File

@ -552,6 +552,17 @@ class DiscoveryTaskList extends Wizard
$data[6] .= __('Discovery.App.Oracle');
break;
case DISCOVERY_DEPLOY_AGENTS:
// Internal deployment task.
$no_operations = true;
$data[6] = html_print_image(
'images/deploy.png',
true,
['title' => __('Agent deployment')]
).'  ';
$data[6] .= __('Discovery.Agent.Deployment');
break;
case DISCOVERY_HOSTDEVICES:
default:
if ($task['id_recon_script'] == 0) {
@ -595,6 +606,7 @@ class DiscoveryTaskList extends Wizard
$data[8] = __('Not executed yet');
}
if (!$no_operations) {
if ($task['disabled'] != 2) {
$data[9] = '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[9] .= html_print_image(
@ -661,6 +673,9 @@ class DiscoveryTaskList extends Wizard
} else {
$data[9] = '';
}
} else {
$data[9] = '-';
}
$table->cellclass[][9] = 'action_buttons';

View File

@ -836,7 +836,7 @@ CREATE TABLE `tdeployment_hosts` (
`arch` ENUM('x64', 'x86') DEFAULT 'x64',
`current_agent_version` VARCHAR(100) DEFAULT '',
`desired_agent_version` VARCHAR(100) DEFAULT '',
`deployed` bigint(20) unsigned COMMENT "When it was deployed",
`deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed",
`last_err` text,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`)

View File

@ -1634,6 +1634,41 @@ sub app_scan($) {
}
##########################################################################
# Perform a deployment scan.
##########################################################################
sub deploy_scan($) {
my $self = shift;
my ($progress, $step);
my $type = '';
# Initialize deployer object.
my $deployer = PandoraFMS::Recon::Util::enterprise_new(
'PandoraFMS::Recon::Deployer',
[
task_data => $self->{'task_data'},
parent => $self
]
);
if (!$deployer) {
# Failed to initialize, check Cloud credentials or anything.
call('message', 'Unable to initialize PandoraFMS::Recon::Deployer', 3);
} else {
# Let deployer object manage scan.
$deployer->scan();
}
# Update progress.
# Done!
$self->{'step'} = '';
$self->call('update_progress', -1);
}
##########################################################################
# Perform a network scan.
##########################################################################
@ -1655,6 +1690,10 @@ sub scan($) {
# Cloud scan.
return $self->cloud_scan();
}
if($self->{'task_data'}->{'type'} == DISCOVERY_DEPLOY_AGENTS) {
return $self->deploy_scan();
}
}
# Find devices.

View File

@ -81,6 +81,7 @@ our @EXPORT = qw(
DISCOVERY_CLOUD_AWS_EC2
DISCOVERY_CLOUD_AWS_RDS
DISCOVERY_CLOUD_AZURE_COMPUTE
DISCOVERY_DEPLOY_AGENTS
$DEVNULL
$OS
$OS_VERSION
@ -191,6 +192,7 @@ use constant DISCOVERY_APP_ORACLE => 5;
use constant DISCOVERY_CLOUD_AWS_EC2 => 6;
use constant DISCOVERY_CLOUD_AWS_RDS => 7;
use constant DISCOVERY_CLOUD_AZURE_COMPUTE => 8;
use constant DISCOVERY_DEPLOY_AGENTS => 9;
# Set OS, OS version and /dev/null
our $OS = $^O;