Merge remote-tracking branch 'origin/ent-3431-discovery-host-devices' into ent-1798-monitorizacion-aws-amazon

Conflicts:
	pandora_console/godmode/wizards/Wizard.main.php

Former-commit-id: dead86a654f8b2873721387233a9c9797b0cd8b1
This commit is contained in:
fermin831 2019-02-20 13:57:54 +01:00
commit 73a5e691ef
8 changed files with 237 additions and 25 deletions

View File

@ -292,8 +292,13 @@ class DiscoveryTaskList extends Wizard
$data[7] = ui_print_timestamp($task['utimestamp'], true); $data[7] = ui_print_timestamp($task['utimestamp'], true);
if (check_acl($config['id_user'], $task['id_group'], 'PM')) { if (check_acl($config['id_user'], $task['id_group'], 'PM')) {
// Check if is a H&D, Cloud or Application.
$data[8] = '<a href="'.ui_get_full_url( $data[8] = '<a href="'.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan&page=0&task='.$task['id_rt'] sprintf(
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&page=0&task=%d',
$this->getTargetWiz($task),
$task['id_rt']
)
).'">'.html_print_image( ).'">'.html_print_image(
'images/wrench_orange.png', 'images/wrench_orange.png',
true true
@ -348,4 +353,24 @@ class DiscoveryTaskList extends Wizard
} }
/**
* Return target url sub-string to edit target task.
*
* @param array $task With all data.
*
* @return string
*/
public function getTargetWiz($task)
{
// TODO: Do not use description. Use recon_script ID instead.
switch ($task['description']) {
case 'Discovery.Application.VMware':
return 'wiz=app&mode=vmware';
default:
return 'wiz=hd&mode=netscan';
}
}
} }

View File

@ -92,7 +92,15 @@ class HostDevices extends Wizard
$mode = get_parameter('mode', null); $mode = get_parameter('mode', null);
if ($mode === null) { if ($mode === null) {
$this->setBreadcrum(['<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd" class="text_color">Host & devices</a></div>']); $this->prepareBreadcrum(
[
[
'link' => $this->url.'&wiz=hd',
'label' => __('&nbsp &nbsp Host & devices'),
],
]
);
$this->printHeader(); $this->printHeader();
$this->printBigButtonsList( $this->printBigButtonsList(
[ [
@ -115,10 +123,16 @@ class HostDevices extends Wizard
if (enterprise_installed()) { if (enterprise_installed()) {
if ($mode == 'importcsv') { if ($mode == 'importcsv') {
$this->setBreadcrum( $this->prepareBreadcrum(
[ [
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd" class="text_color">Host & devices</a></div>', [
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=importcsv" class="text_color">Import CSV</a></div>', 'link' => $this->url.'&wiz=hd',
'label' => __('&nbsp &nbsp Host & devices'),
],
[
'link' => $this->url.'&wiz=hd&mode=importcsv',
'label' => __('&nbsp &nbsp &nbsp Import CSV'),
],
] ]
); );
$this->printHeader(); $this->printHeader();
@ -128,20 +142,36 @@ class HostDevices extends Wizard
} }
if ($mode == 'netscan') { if ($mode == 'netscan') {
if ($this->page != 3) { if ($this->page != 2) {
// Do not paint breadcrum in last page. Redirected. // Do not paint breadcrum in last page. Redirected.
$this->setBreadcrum( $this->prepareBreadcrum(
[ [
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd"class="text_color">Host & devices</a></div>', [
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan" class="text_color">Net scan definition</a></div>', 'link' => $this->url.'&wiz=hd',
'label' => __('&nbsp &nbsp Host & devices'),
],
[
'link' => $this->url.'&wiz=hd&mode=netscan',
'label' => __('&nbsp &nbsp &nbsp Net scan definition'),
],
] ]
); );
if ($this->page == 1) { if ($this->page == 1) {
$this->setBreadcrum( $this->prepareBreadcrum(
[ [
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd"class="text_color">Host & devices</a></div>', [
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan" class="text_color">Net scan definition</a></div>', 'link' => $this->url.'&wiz=hd',
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan&page=1" class="text_color">Net scan features</a></div>', 'label' => __('&nbsp &nbsp Host & devices'),
],
[
'link' => $this->url.'&wiz=hd&mode=netscan',
'label' => __('&nbsp &nbsp &nbsp Net scan definition'),
],
[
'link' => $this->url.'&wiz=hd&mode=netscan&page=1',
'label' => __('&nbsp &nbsp &nbsp Net scan features'),
],
] ]
); );
} }
@ -1096,4 +1126,26 @@ $(function() {
} }
/**
* Builder for breadcrum
*
* @param array $urls Array of urls to be stored in breadcrum.
*
* @return void
*/
public function prepareBreadcrum(array $urls)
{
$bc = [];
$i = 0;
foreach ($urls as $url) {
$bc[$i] = '<a href="'.$url['link'].'" class="text_color">';
$bc[$i] .= '<div class="arrow_box">'.$url['label'].'</div>';
$bc[$i++] .= '</a>';
}
$this->setBreadcrum($bc);
}
} }

View File

@ -87,7 +87,8 @@ class Wizard
* *
* @return void * @return void
*/ */
protected function addBreadcrum($string) { protected function addBreadcrum($string)
{
if (empty($string)) { if (empty($string)) {
return; return;
} }
@ -96,6 +97,52 @@ class Wizard
} }
/**
* Setter for label
*
* @param string $str Label.
*
* @return void
*/
public function setLabel(string $str)
{
$this->label = $str;
}
/**
* Getter for label
*
* @return array Breadcrum.
*/
public function getLabel()
{
return $this->label;
}
/**
* Builder for breadcrum
*
* @param array $urls Array of urls to be stored in breadcrum.
*
* @return void
*/
public function prepareBreadcrum(array $urls)
{
$bc = [];
$i = 0;
foreach ($urls as $url) {
$bc[$i] = '<a href="'.$url['link'].'" class="text_color">';
$bc[$i] .= '<div class="arrow_box">'.$url['label'].'</div>';
$bc[$i++] .= '</a>';
}
$this->setBreadcrum($bc);
}
/** /**
* To be overwritten. * To be overwritten.
* *
@ -371,6 +418,17 @@ class Wizard
((isset($data['unique']) === true) ? $data['unique'] : false) ((isset($data['unique']) === true) ? $data['unique'] : false)
); );
case 'textarea':
return html_print_textarea(
$data['name'],
$data['rows'],
$data['columns'],
((isset($data['value']) === true) ? $data['value'] : ''),
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['class']) === true) ? $data['class'] : '')
);
default: default:
// Ignore. // Ignore.
break; break;
@ -385,14 +443,18 @@ class Wizard
* *
* @return void * @return void
*/ */
public function printGoBackButton() public function printGoBackButton($url=null)
{ {
if (isset($url) === false) {
$url = ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery'
);
}
$form = [ $form = [
'form' => [ 'form' => [
'method' => 'POST', 'method' => 'POST',
'action' => ui_get_full_url( 'action' => $url,
'index.php?sec=gservers&sec2=godmode/servers/discovery'
),
], ],
'inputs' => [ 'inputs' => [
[ [
@ -548,7 +610,8 @@ class Wizard
* *
* @return void Print the full list. * @return void Print the full list.
*/ */
public static function printBigButtonsList($list_data){ public static function printBigButtonsList($list_data)
{
echo '<ul>'; echo '<ul>';
array_map('self::printBigButtonElement', $list_data); array_map('self::printBigButtonElement', $list_data);
echo '</ul>'; echo '</ul>';

View File

@ -501,6 +501,7 @@ class ConsoleSupervisor
case 'NOTIF.UPDATEMANAGER.OPENSETUP': case 'NOTIF.UPDATEMANAGER.OPENSETUP':
case 'NOTIF.UPDATEMANAGER.UPDATE': case 'NOTIF.UPDATEMANAGER.UPDATE':
case 'NOTIF.UPDATEMANAGER.MINOR': case 'NOTIF.UPDATEMANAGER.MINOR':
case 'NOTIF.CRON.CONFIGURED':
default: default:
// NOTIF.SERVER.STATUS. // NOTIF.SERVER.STATUS.
// NOTIF.SERVER.STATUS.ID_SERVER. // NOTIF.SERVER.STATUS.ID_SERVER.
@ -1379,7 +1380,10 @@ class ConsoleSupervisor
[ [
'type' => 'NOTIF.PANDORADB', 'type' => 'NOTIF.PANDORADB',
'title' => __('Database maintance problem'), 'title' => __('Database maintance problem'),
'message' => __('Your database is not maintained correctly. It seems that more than 48hrs have passed without proper maintenance. Please review documents of %s on how to perform this maintenance process (DB Tool) and enable it as soon as possible.', get_product_name()), 'message' => __(
'Your database is not maintained correctly. It seems that more than 48hrs have passed without proper maintenance. Please review documents of %s on how to perform this maintenance process (DB Tool) and enable it as soon as possible.',
io_safe_output(get_product_name())
),
'url' => ui_get_full_url( 'url' => ui_get_full_url(
'index.php?sec=general&sec2=godmode/setup/setup&section=perf' 'index.php?sec=general&sec2=godmode/setup/setup&section=perf'
), ),
@ -2081,4 +2085,55 @@ class ConsoleSupervisor
} }
/**
* Check if CRON utility has been configured.
*
* @return void
*/
public function checkCronRunning()
{
global $config;
// Check if DiscoveryCronTasks is running. Warn user if not.
if ($config['cron_last_run'] == 0
|| (get_system_time() - $config['cron_last_run']) > 3600
) {
$message_conf_cron = __('DiscoveryConsoleTasks is not running properly');
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
$message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service');
$message_conf_cron .= '. '.__('Please, add the following line to your crontab file:');
$message_conf_cron .= '<pre>* * * * * &lt;user&gt; wget -q -O - --no-check-certificate ';
$message_conf_cron .= str_replace(
ENTERPRISE_DIR.'/meta/',
'',
ui_get_full_url(false)
);
$message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
$message_conf_cron .= '/cron/cron.php &gt;&gt; ';
$message_conf_cron .= $config['homedir'].'/pandora_console.log</pre>';
}
if (isset($config['cron_last_run']) === true) {
$message_conf_cron .= __('Last execution').': ';
$message_conf_cron .= date('Y/m/d H:i:s', $config['cron_last_run']);
$message_conf_cron .= __('Please check process is no locked.');
}
$this->notify(
[
'type' => 'NOTIF.CRON.CONFIGURED',
'title' => __('DiscoveryConsoleTasks is not configured.'),
'message' => __($message_conf_cron),
'url' => ui_get_full_url(
'index.php?extension_in_menu=gservers&sec=extensions&sec2=enterprise/extensions/cron'
),
]
);
} else {
$this->cleanNotifications('NOTIF.CRON.CONFIGURED');
}
}
} }

View File

@ -2673,9 +2673,14 @@ function config_check()
include_once __DIR__.'/class/ConsoleSupervisor.php'; include_once __DIR__.'/class/ConsoleSupervisor.php';
// Enterprise customers launch supervisor using discovery task. // Enterprise customers launch supervisor using discovery task.
if (license_free()) { if (enterprise_installed() === false) {
$supervisor = new ConsoleSupervisor(false); $supervisor = new ConsoleSupervisor(false);
$supervisor->run(); $supervisor->run();
} else if ($config['cron_last_run'] == 0
|| (get_system_time() - $config['cron_last_run']) > 3600
) {
$supervisor = new ConsoleSupervisor(false);
$supervisor->checkCronRunning();
} }
} }

View File

@ -61,8 +61,7 @@ div.data_container:hover {
display: inline-block; display: inline-block;
position: relative; position: relative;
background: #82b92e; background: #82b92e;
width: 15%; padding: 14px;
padding: 1%;
margin-left: 20px; margin-left: 20px;
margin-bottom: 10px; margin-bottom: 10px;
} }

View File

@ -4305,6 +4305,7 @@ div#dialog_messages table th:last-child {
position: absolute; position: absolute;
width: 400px; width: 400px;
margin-top: -5px; margin-top: -5px;
border-radius: 5px;
} }
#notification-wrapper::before { #notification-wrapper::before {
content: ""; content: "";
@ -4338,12 +4339,15 @@ div#dialog_messages table th:last-child {
background: whitesmoke; background: whitesmoke;
height: 100px; height: 100px;
margin: 7px; margin: 7px;
border: #cccccc solid 1px; border: #e4e4e4 solid 1px;
display: flex; display: flex;
flex-flow: row nowrap; flex-flow: row nowrap;
align-items: center; align-items: center;
padding: 5px; padding: 5px;
} }
.notification-item:hover {
border: #ccc solid 1px;
}
.notification-item > * { .notification-item > * {
padding-left: 15px; padding-left: 15px;
pointer-events: none; pointer-events: none;
@ -4357,6 +4361,9 @@ div#dialog_messages table th:last-child {
width: 87%; width: 87%;
display: flex; display: flex;
flex-flow: column nowrap; flex-flow: column nowrap;
overflow: hidden;
max-height: 83px;
line-height: 1.4em;
} }
.notification-item img { .notification-item img {
max-width: 100%; max-width: 100%;

View File

@ -10,6 +10,12 @@ ul.wizard li {
} }
ul.wizard li > label:not(.p-switch) { ul.wizard li > label:not(.p-switch) {
width: 250px;
vertical-align: top;
display: inline-block;
}
ul.wizard li > textarea {
width: 250px; width: 250px;
display: inline-block; display: inline-block;
} }