WIP Agent repository

This commit is contained in:
fbsanchez 2019-07-17 20:37:13 +02:00
parent 17dc0b82ac
commit 8d9c4682c7
9 changed files with 202 additions and 5 deletions

View File

@ -38,7 +38,22 @@ CREATE TABLE `tdeployment_hosts` (
FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`)
ON UPDATE CASCADE ON DELETE SET NULL,
FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`)
ON UPDATE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tagent_repository` (
`id` SERIAL,
`id_os` INT(10) UNSIGNED DEFAULT 0,
`arch` ENUM('x64', 'x86') DEFAULT 'x64',
`version` VARCHAR(10) DEFAULT '',
`path` text,
`uploaded_by` VARCHAR(100) DEFAULT '',
`uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed",
`last_err` text,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;

View File

@ -2253,5 +2253,22 @@ CREATE TABLE `tdeployment_hosts` (
FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`)
ON UPDATE CASCADE ON DELETE SET NULL,
FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`)
ON UPDATE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tagent_repository`
-- ---------------------------------------------------------------------
CREATE TABLE `tagent_repository` (
`id` SERIAL,
`id_os` INT(10) UNSIGNED DEFAULT 0,
`arch` ENUM('x64', 'x86') DEFAULT 'x64',
`version` VARCHAR(10) DEFAULT '',
`path` text,
`uploaded_by` VARCHAR(100) DEFAULT '',
`uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed",
`last_err` text,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -129,6 +129,7 @@ if (check_acl($config['id_user'], 0, 'PM')) {
$sub['godmode/modules/manage_network_templates']['id'] = 'Module templates';
enterprise_hook('inventory_submenu');
enterprise_hook('autoconfiguration_menu');
enterprise_hook('agent_repository_menu');
}
if (check_acl($config['id_user'], 0, 'AW')) {

View File

@ -93,7 +93,7 @@ function cl_load_cmp($a, $b)
$classes = glob($config['homedir'].'/godmode/wizards/*.class.php');
if (enterprise_installed()) {
$ent_classes = glob(
$config['homedir'].'/enterprise/godmode/wizards/*.class.php'
$config['homedir'].'/'.ENTERPRISE_DIR.'/godmode/wizards/*.class.php'
);
if ($ent_classes === false) {
$ent_classes = [];
@ -142,7 +142,7 @@ if ($classname_selected === null) {
}
}
// Show hints if there is no task
// Show hints if there is no task.
if (get_parameter('discovery_hint', 0)) {
ui_require_css_file('discovery-hint');
ui_print_info_message(__('You must create a task first'));

View File

@ -156,11 +156,30 @@ class HostDevices extends Wizard
),
'label' => __('Discovery'),
],
[
'link' => ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd'
),
'label' => __('Host & Devices'),
'selected' => true,
],
],
true
);
ui_print_page_header(__('Host & devices'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
ui_print_page_header(
__('Host & devices'),
'',
false,
'',
true,
'',
false,
'',
GENERIC_SIZE_TEXT,
'',
$this->printHeader(true)
);
$this->printBigButtonsList($buttons);
return;

View File

@ -331,6 +331,8 @@ function print_inputs($values=null)
case 'CUSTOM':
$user_label = __('Account ID');
$pass_label = __('Password');
$extra1 = false;
$extra2 = false;
default:
// Use defaults.
break;

View File

@ -1870,3 +1870,100 @@ function logo_preview(icon_name, icon_path, incoming_options) {
// console.log(err);
}
}
// Advanced Form control.
/* global $ */
/* exported load_modal */
function load_modal(settings) {
var AJAX_RUNNING = 0;
var data = new FormData();
if (settings.extradata) {
settings.extradata.forEach(function(item) {
if (item.value != undefined) data.append(item.name, item.value);
});
}
data.append("page", settings.onshow.page);
data.append("method", settings.onshow.method);
var width = 630;
if (settings.onshow.width) {
width = settings.onshow.width;
}
$.ajax({
method: "post",
url: settings.url,
processData: false,
contentType: false,
data: data,
success: function(data) {
settings.target.html(data);
settings.target.dialog({
resizable: true,
draggable: true,
modal: true,
title: settings.modal.title,
width: width,
overlay: {
opacity: 0.5,
background: "black"
},
buttons: [
{
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
text: settings.modal.cancel,
click: function() {
$(this).dialog("close");
settings.cleanup();
}
},
{
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: settings.modal.ok,
click: function() {
if (AJAX_RUNNING) return;
AJAX_RUNNING = 1;
var formdata = new FormData();
if (settings.extradata) {
settings.extradata.forEach(function(item) {
if (item.value != undefined)
formdata.append(item.name, item.value);
});
}
formdata.append("page", settings.onsubmit.page);
formdata.append("method", settings.onsubmit.method);
$("#" + settings.form + " :input").each(function() {
if (this.type == "file") {
if ($(this).prop("files")[0]) {
formdata.append(this.name, $(this).prop("files")[0]);
}
} else {
formdata.append(this.name, $(this).val());
}
});
$.ajax({
method: "post",
url: settings.url,
processData: false,
contentType: false,
data: formdata,
success: function(data) {
settings.ajax_callback(data);
AJAX_RUNNING = 0;
}
});
}
}
],
closeOnEscape: false,
open: function() {
$(".ui-dialog-titlebar-close").hide();
}
});
}
});
}

View File

@ -0,0 +1,29 @@
ul.wizard li > label:not(.p-switch) {
width: auto;
}
form.top-action-buttons ul.wizard {
display: flex;
flex-direction: row;
}
ul.wizard li {
margin-right: 1em;
}
form.modal ul.wizard li {
display: flex;
flex-direction: row;
width: 90%;
margin: 0.5em auto;
justify-items: center;
}
form.modal ul.wizard li * {
flex: 1;
}
ul.wizard li.flex-indep {
flex: 1;
margin: 0;
}

View File

@ -3646,3 +3646,20 @@ CREATE TABLE IF NOT EXISTS `tvisual_console_elements_cache` (
ON DELETE CASCADE
ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `tagent_repository`
-- ---------------------------------------------------------------------
CREATE TABLE `tagent_repository` (
`id` SERIAL,
`id_os` INT(10) UNSIGNED DEFAULT 0,
`arch` ENUM('x64', 'x86') DEFAULT 'x64',
`version` VARCHAR(10) DEFAULT '',
`path` text,
`uploaded_by` VARCHAR(100) DEFAULT '',
`uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed",
`last_err` text,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;