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,71 +606,75 @@ class DiscoveryTaskList extends Wizard
$data[8] = __('Not executed yet');
}
if ($task['disabled'] != 2) {
$data[9] = '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[9] .= html_print_image(
'images/eye.png',
true
);
$data[9] .= '</a>';
}
if ($task['disabled'] != 2 && $task['utimestamp'] > 0
&& $task['type'] != DISCOVERY_APP_MYSQL
&& $task['type'] != DISCOVERY_APP_ORACLE
&& $task['type'] != DISCOVERY_CLOUD_AWS_RDS
) {
$data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[9] .= html_print_image(
'images/dynamic_network_icon.png',
true
);
$data[9] .= '</a>';
}
if (check_acl(
$config['id_user'],
$task['id_group'],
'PM'
)
) {
if ($ipam === true) {
$data[9] .= '<a href="'.ui_get_full_url(
sprintf(
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id=%d',
$tipam_task_id
)
).'">'.html_print_image(
'images/config.png',
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(
'images/eye.png',
true
).'</a>';
$data[9] .= '<a href="'.ui_get_full_url(
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=delete&id='.$tipam_task_id
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
'images/cross.png',
);
$data[9] .= '</a>';
}
if ($task['disabled'] != 2 && $task['utimestamp'] > 0
&& $task['type'] != DISCOVERY_APP_MYSQL
&& $task['type'] != DISCOVERY_APP_ORACLE
&& $task['type'] != DISCOVERY_CLOUD_AWS_RDS
) {
$data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[9] .= html_print_image(
'images/dynamic_network_icon.png',
true
).'</a>';
);
$data[9] .= '</a>';
}
if (check_acl(
$config['id_user'],
$task['id_group'],
'PM'
)
) {
if ($ipam === true) {
$data[9] .= '<a href="'.ui_get_full_url(
sprintf(
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id=%d',
$tipam_task_id
)
).'">'.html_print_image(
'images/config.png',
true
).'</a>';
$data[9] .= '<a href="'.ui_get_full_url(
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=delete&id='.$tipam_task_id
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
'images/cross.png',
true
).'</a>';
} else {
// Check if is a H&D, Cloud or Application or IPAM.
$data[9] .= '<a href="'.ui_get_full_url(
sprintf(
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
$this->getTargetWiz($task, $recon_script_data),
$task['id_rt']
)
).'">'.html_print_image(
'images/config.png',
true
).'</a>';
$data[9] .= '<a href="'.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&delete=1&task='.$task['id_rt']
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
'images/cross.png',
true
).'</a>';
}
} else {
// Check if is a H&D, Cloud or Application or IPAM.
$data[9] .= '<a href="'.ui_get_full_url(
sprintf(
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
$this->getTargetWiz($task, $recon_script_data),
$task['id_rt']
)
).'">'.html_print_image(
'images/config.png',
true
).'</a>';
$data[9] .= '<a href="'.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&delete=1&task='.$task['id_rt']
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
'images/cross.png',
true
).'</a>';
$data[9] = '';
}
} else {
$data[9] = '';
$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;