This commit is contained in:
enriquecd 2016-09-28 13:43:05 +02:00
commit 0d8d2d81b4
41 changed files with 614 additions and 87 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 6.1dev-160926
Version: 6.1dev-160928
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="6.1dev-160926"
pandora_version="6.1dev-160928"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '6.1dev';
use constant AGENT_BUILD => '160926';
use constant AGENT_BUILD => '160928';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 6.1dev
%define release 160926
%define release 160928
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 6.1dev
%define release 160926
%define release 160928
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="6.1dev"
PI_BUILD="160926"
PI_BUILD="160928"
OS_NAME=`uname -s`
FORCE=0

View File

@ -19,7 +19,6 @@
# GNU General Public License for more details.
#
###############################################################################
use strict;
use File::Basename;
@ -188,7 +187,10 @@ sub parse_log (;$$) {
seek(LOGFILE, $Idx_pos, 0);
# Parse log file
my @data;
my %data;
# Matched line id
my $matched_line = 0;
if ( (defined($up_lines)) || (defined($bot_lines)) ){
# Detailed workmode
@ -210,8 +212,9 @@ sub parse_log (;$$) {
$flag = 1;
# Push upper lines
for (my $i = ($curr_line-$up_lines); $i<=$curr_line; $i++){
if ($i < 0) {next;}
if (defined ($lines[$i])) {
push (@data, $lines[$i]);
push (@{$data{$matched_line}}, $lines[$i]);
}
}
@ -220,16 +223,17 @@ sub parse_log (;$$) {
# Push bottom lines
for (my $i = ($curr_line+$flag); $i<=($curr_line+$bot_lines); $i++){
if (defined ($lines[$i])) {
push (@data, $lines[$i]);
push (@{$data{$matched_line}}, $lines[$i]);
}
}
}
$matched_line++;
}
}
else { # Standar workmode
while ($line = <LOGFILE>) {
if ($line =~ m/$Reg_exp/i) {
push @data, $line;
push (@{$data{$matched_line++}}, $line);
}
}
}
@ -240,7 +244,7 @@ sub parse_log (;$$) {
# Save the index file
save_idx();
return @data;
return \%data;
}
###############################################################################
@ -262,11 +266,12 @@ sub print_summary() {
# SUB parse_log
# Print log data to stdout.
###############################################################################
sub print_log (@) {
my @data = @_;
sub print_log ($) {
my $data = shift;
# No data
if ($#data < 0) {
my @kdata = keys (%{$data});
if ($#kdata < 0) {
print_summary() if ($summary_flag == 1);
return;
}
@ -276,8 +281,8 @@ sub print_log (@) {
my $output = "<log_module>\n";
$output .= "<source><![CDATA[" . $Module_name . "]]></source>\n";
$output .= "<data><![CDATA[";
foreach my $line (@data) {
$output .= $line;
foreach my $line (@kdata) {
$output .= $data->{$line};
}
$output .= "]]></data>";
$output .= "</log_module>\n";
@ -292,8 +297,12 @@ sub print_log (@) {
$output .= "<name><![CDATA[" . $Module_name . "]]></name>\n";
$output .= "<type><![CDATA[async_string]]></type>\n";
$output .= "<datalist>\n";
foreach my $line (@data) {
$output .= "<data><value><![CDATA[$line]]></value></data>\n";
foreach my $line (@kdata) {
$output .= "<data><value><![CDATA[";
foreach my $content (@{$data->{$line}}) {
$output .= $content;
}
$output .= "]]></value></data>\n";
}
$output .= "</datalist>\n";
$output .= "</module>\n";
@ -348,9 +357,9 @@ if (! -e $Idx_file) {
load_idx();
# Parse log file
my @data = parse_log($up_lines,$bot_lines);
my $data = parse_log($up_lines,$bot_lines);
# Print output to stdout
print_log (@data);
print_log ($data);
exit 0;

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{160926}
{160928}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("6.1dev(Build 160926)")
#define PANDORA_VERSION ("6.1dev(Build 160928)")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(6.1dev(Build 160926))"
VALUE "ProductVersion", "(6.1dev(Build 160928))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 6.1dev-160926
Version: 6.1dev-160928
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="6.1dev-160926"
pandora_version="6.1dev-160928"
package_pear=0
package_pandora=1

View File

@ -45,6 +45,7 @@ RUN yum install -y \
php-common \
php-zip \
nmap \
net-snmp-utils \
xprobe2
#Clone the repo

View File

@ -79,7 +79,7 @@ if (!empty($macros)) {
$macros[$k]['value'] = get_parameter($m['macro'], '');
}
$macros = json_encode($macros);
$macros = io_json_mb_encode($macros);
}
$max_timeout = (int) get_parameter ('max_timeout');

View File

@ -1239,8 +1239,8 @@ function setModuleGraph(id_data) {
id_agente_modulo = data['id_agente_modulo'];
id_custom_graph = data['id_custom_graph'];
label = data['label'];
height = data['height'];
width = data['width'];
height = (data['height'] + 60);
width = (data['width'] + 60);
period = data['period'];
background_color = data['image'];

View File

@ -153,7 +153,7 @@ switch ($action) {
if ($id_custom_graph != 0) {
$img = custom_graphs_print(
$id_custom_graph, $height, $width, $period,
true, true, 0, true, $background_color);
null, true, 0, true, $background_color);
}
else {
$img = grafico_modulo_sparse($id_agent_module,
@ -189,7 +189,8 @@ switch ($action) {
case 'get_layout_data':
$layoutData = db_get_row_filter('tlayout_data',
array('id' => $id_element));
$layoutData['height'] = $layoutData['height'] + 60;
$layoutData['width'] = $layoutData['width'] + 60;
echo json_encode($layoutData);
break;

View File

@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC160926';
$build_version = 'PC160928';
$pandora_version = 'v6.1dev';
// Do not overwrite default timezone set if defined.

View File

@ -2631,8 +2631,8 @@ function reporting_alert_report_group($report, $content) {
$data_row['fired'] = array();
$firedTimes = get_module_alert_fired(
$content['id_agent_module'],
$alert['id_alert_template'],
$alert['id_agent_module'],
$alert['id'],
(int) $content['period'],
(int) $report["datetime"]);
@ -2739,7 +2739,7 @@ function reporting_alert_report_agent($report, $content) {
$data_row['fired'] = array();
$firedTimes = get_module_alert_fired(
$alert['id_agent_module'],
$alert['id_alert_template'],
$alert['id'],
(int) $content['period'],
(int) $report["datetime"]);

View File

@ -94,8 +94,10 @@ function visual_map_print_item($mode = "read", $layoutData,
require_once ($config["homedir"] . '/include/functions_graph.php');
require_once ($config["homedir"] . '/include/functions_custom_graphs.php');
$width = $layoutData['width'];
$height = $max_percentile = $layoutData['height'];
//add 60 px for visual console map
$width = $layoutData['width'] + 60;
$height = $layoutData['height'] + 60;
$max_percentile = $layoutData['height'];
$top = $layoutData['pos_y'];
$left = $layoutData['pos_x'];
$id = $layoutData['id'];

View File

@ -691,7 +691,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
"Mode"=>SCALE_MODE_START0, "LabelRotation" => 60);
$margin_left = 40;
$margin_top = 10;
$margin_bottom = 10 * $max_chars;
$margin_bottom = 3 * $max_chars;
break;
case "hbar":
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,
@ -718,13 +718,13 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
$myPicture->setGraphArea($margin_left,$margin_top,$width - $water_mark_width,$height-$margin_bottom);
$myPicture->drawScale($scaleSettings);
/*
if (isset($legend)) {
/* Write the chart legend */
/* Write the chart legend
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->drawLegend($width-$size['Width'],0,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL, "BoxWidth"=>10, "BoxHeight"=>10));
}
*/
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
@ -1137,8 +1137,9 @@ function pch_bullet_chart($graph_type, $data, $legend,
$MyData->setSerieDescription("Labels", __("Agents/Modules"));
$height_t = ($height * count($data) ) + 40;
$width_t = ($width + ( 200 + $max_chars));
$max_chars = graph_get_max_index($legend_values);
$height_t = $height;
$max_chars = graph_get_max_index($legend);
$width_t = ($width + ( 100 + $max_chars));
/* Create the pChart object */
$myPicture = new pImage($width_t, $height_t,$MyData);
@ -1151,7 +1152,7 @@ function pch_bullet_chart($graph_type, $data, $legend,
$height_t - 10;
/* Draw the scale and chart */
$myPicture->setGraphArea(220,20,($width + 80), $height_t);
$myPicture->setGraphArea(250,20,($width + 100), $height_t);
$myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM, "Mode"=>SCALE_MODE_ADDALL_START0,
"LabelingMethod"=>LABELING_DIFFERENT, "GridR"=>255, "GridG"=>255,
"GridB"=>255, "GridAlpha"=>50, "TickR"=>0,"TickG"=>0, "TickB"=>0,

View File

@ -71,7 +71,7 @@
<div style='height: 10px'>
<?php
$version = '6.1dev';
$build = '160926';
$build = '160928';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 6.1dev
%define release 160926
%define release 160928
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 6.1dev
%define release 160926
%define release 160928
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -66,7 +66,7 @@ INSERT INTO tconfig (token, value) VALUES ('graph_res','5');
INSERT INTO tconfig (token, value) VALUES ('step_compact','1');
INSERT INTO tconfig (token, value) VALUES ('db_scheme_first_version','6.0orc');
INSERT INTO tconfig (token, value) VALUES('db_scheme_version','6.1dev');
INSERT INTO tconfig (token, value) VALUES('db_scheme_build','PD160926');
INSERT INTO tconfig (token, value) VALUES('db_scheme_build','PD160928');
INSERT INTO tconfig (token, value) VALUES ('show_unknown','0');
INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1');
INSERT INTO tconfig (token, value) VALUES ('style','pandora');

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 6.1dev-160926
Version: 6.1dev-160928
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="6.1dev-160926"
pandora_version="6.1dev-160928"
package_cpan=0
package_pandora=1

View File

@ -38,7 +38,7 @@ fi
#Create the pandora user to run the anyterd, mainly
/usr/sbin/useradd -d /home/pandora -s /bin/false -M -g 0 pandora
cd /tmp/pandorafms/pandora_server && chmod +x pandora_server_installer && ./pandora_server_installer --install
cd /tmp/pandorafms/pandora_server && chmod +x pandora_server_installer && sync && ./pandora_server_installer --install
#Configure the Pandora FMS Server to connect to the database
sed -i "s/dbname pandora/dbname $PANDORA_DB_NAME/g" /etc/pandora/pandora_server.conf

View File

@ -43,7 +43,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "6.1dev";
my $pandora_build = "160926";
my $pandora_build = "160928";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 6.1dev
%define release 160926
%define release 160928
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 6.1dev
%define release 160926
%define release 160928
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="6.1dev"
PI_BUILD="160926"
PI_BUILD="160928"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB;
# version: define current version
my $version = "6.1dev PS160926";
my $version = "6.1dev PS160928";
# Pandora server configuration
my %conf;

View File

@ -35,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "6.1dev PS160926";
my $version = "6.1dev PS160928";
# save program name for logging
my $progname = basename($0);

View File

@ -133,48 +133,48 @@ class ACLTags(PandoraWebDriverTestCase):
u"""Create agent and two modules, one without tag and with tag, create a user with tag and check this user can view module with tag and user can´t view module without tag"""
agent_name = gen_random_string(6)
module_name_A = gen_random_string(6)
module_name_B = gen_random_string(6)
user_name = gen_random_string(6)
#agent_name = gen_random_string(6)
#module_name_A = gen_random_string(6)
#module_name_B = gen_random_string(6)
#user_name = gen_random_string(6)
driver = self.driver
self.login()
detect_and_pass_all_wizards(driver)
#driver = self.driver
#self.login()
#detect_and_pass_all_wizards(driver)
create_agent(driver,agent_name,group="Applications",ip="192.168.50.50")
#create_agent(driver,agent_name,group="Applications",ip="192.168.50.50")
#We create a module without a tag
create_module("network_server",driver,agent_name=agent_name,module_name=module_name_A,component_group="Network Management",network_component="Host Alive",ip="192.168.50.50")
#create_module("network_server",driver,agent_name=agent_name,module_name=module_name_A,component_group="Network Management",network_component="Host Alive",ip="192.168.50.50")
#We now create a modulo with tag "critical"
create_module("network_server",driver,agent_name=agent_name,module_name=module_name_B,component_group="Network Management",network_component="Host Alive",ip="192.168.50.50",tag_name="critical")
#create_module("network_server",driver,agent_name=agent_name,module_name=module_name_B,component_group="Network Management",network_component="Host Alive",ip="192.168.50.50",tag_name="critical")
l = [("Operator (Read)","All",["critical"])]
#l = [("Operator (Read)","All",["critical"])]
create_user(driver,user_name,"pandora",profile_list=l)
#create_user(driver,user_name,"pandora",profile_list=l)
self.logout()
#self.logout()
self.login(user=user_name)
#self.login(user=user_name)
detect_and_pass_all_wizards(driver)
#detect_and_pass_all_wizards(driver)
search_agent(driver,agent_name)
#search_agent(driver,agent_name)
time.sleep(6)
#time.sleep(6)
#The user should be able to see the module with Tag
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_B+'")]')
self.assertIsInstance(module,WebElement)
#module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_B+'")]')
#self.assertIsInstance(module,WebElement)
#The user should NOT be able to see the module without tag
modules = driver.find_elements_by_xpath('//td[contains(.,"'+module_name_A+'")]')
self.assertEqual(modules,[])
#modules = driver.find_elements_by_xpath('//td[contains(.,"'+module_name_A+'")]')
#self.assertEqual(modules,[])
if __name__ == "__main__":
unittest2.main()

43
tests/console/Alerts.py Normal file
View File

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
from include.common_classes_60 import PandoraWebDriverTestCase
from include.common_functions_60 import login, click_menu_element, refresh_N_times_until_find_element, detect_and_pass_all_wizards, is_element_present, logout
from include.alert_functions import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import StaleElementReferenceException, NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.remote.webelement import WebElement
import unittest2, time, re
class Alerts (PandoraWebDriverTestCase):
test_name = u'Alerts tests'
tickets_associated = []
def test_create_new_email_action(self):
u"""
Create a new alert action using eMail command and check that create ok
"""
action_name = gen_random_string(6)
driver = self.driver
self.login()
detect_and_pass_all_wizards(driver)
create_new_action_to_alert(driver,action_name,"Applications","eMail",field1="prueba@prueba.com",field2="Test",field3="This is a test")
element = driver.find_element_by_xpath('//td[contains(.,"Successfully created")]')
self.assertIsInstance(element,WebElement)
click_menu_element(driver,"Actions")
element = driver.find_element_by_xpath('//a[contains(.,"'+action_name+'")]')
self.assertIsInstance(element,WebElement)
if __name__ == "__main__":
unittest2.main()

View File

@ -324,7 +324,56 @@ class Bulk_operations(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//tr//td[contains(.,"2")]')
self.assertIsInstance(element,WebElement)
def test_H_copy_modules_in_bulk(self):
u"""
Create three agents One of them with a module. Through a bulk operation, copy this module in other two agents
"""
agent_name_1 = gen_random_string(6)
agent_name_2 = gen_random_string(6)
agent_name_3 = gen_random_string(6)
module_name_1 = gen_random_string(6)
driver = self.driver
activate_api(driver,"1234")
params = [agent_name_1,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
create_agent_api(driver,params,user="admin",pwd="pandora")
params = [agent_name_2,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
create_agent_api(driver,params,user="admin",pwd="pandora")
params = [agent_name_3,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
create_agent_api(driver,params,user="admin",pwd="pandora")
params = [agent_name_1,module_name_1,"0","6","1","0","0","0","0","0","0","0","0","129.99.40.1","0","0","180","0","0","0","0","Host_Alive"]
add_network_module_to_agent_api(driver,params,user="admin",pwd="pandora",apipwd="1234")
lista = driver.current_url.split('/')
url = lista[0]+'//'+lista[2]+'/pandora_console'
driver.get(url)
destiny_agents_list = [agent_name_2,agent_name_3]
module_list = [module_name_1]
agent_name = agent_name_1.lower()
copy_modules_in_bulk(driver,agent_name,module_list,destiny_agents_list)
search_module(driver,agent_name_2,module_name_1)
self.assertEqual(module_name_1 in driver.page_source,True)
search_module(driver,agent_name_3,module_name_1)
self.assertEqual(module_name_1 in driver.page_source,True)
if __name__ == "__main__":
unittest2.main()

View File

@ -0,0 +1,178 @@
# -*- coding: utf-8 -*-
from include.common_classes_60 import PandoraWebDriverTestCase
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards, gen_random_string
from include.agent_functions import search_agent,create_agent,delete_agent
from include.api_functions import *
from include.module_functions import search_module
from include.network_components_functions import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.remote.webelement import WebElement
import unittest2, time, re
class Network_components(PandoraWebDriverTestCase):
test_name = u'Network_components'
test_description = u'Network components test'
tickets_associated = []
def atest_A_create_network_component(self):
u"""
Create and search new network component module
"""
driver = self.driver
self.login()
detect_and_pass_all_wizards(driver)
agent_name = gen_random_string(6)
network_component_name = gen_random_string(6)
activate_api(driver,"1234")
params = [agent_name,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
create_agent_api(driver,params,user="admin",pwd="pandora")
lista = driver.current_url.split('/')
url = lista[0]+'//'+lista[2]+'/pandora_console'
driver.get(url)
create_network_component(driver,network_component_name,"Remote TCP network agent, boolean data","Network Management","Application",min_warning=10,max_critical=100,description="New network component by test")
search_agent(driver,agent_name,go_to_agent=True)
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new network server module")
driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr/td[5]/input').click()
driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()
Select(driver.find_element_by_id("network_component_group")).select_by_visible_text("Network Management")
time.sleep(3)
Select(driver.find_element_by_id("network_component")).select_by_visible_text(network_component_name)
driver.find_element_by_id("submit-crtbutton").click()
search_module (driver,agent_name,network_component_name,go_to_module=False)
self.assertEqual(network_component_name in driver.page_source,True)
def atest_B_create_plugin_component(self):
u"""
Create and search new plug-in component
"""
driver = self.driver
self.login()
detect_and_pass_all_wizards(driver)
agent_name = gen_random_string(6)
plugin_component_name = gen_random_string(6)
activate_api(driver,"1234")
params = [agent_name,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
create_agent_api(driver,params,user="admin",pwd="pandora")
lista = driver.current_url.split('/')
url = lista[0]+'//'+lista[2]+'/pandora_console'
driver.get(url)
create_plugin_component(driver,plugin_component_name,"Generic numeric","Network Management","Application",max_warning=50,max_critical=100,description="New plugin component")
search_agent(driver,agent_name,go_to_agent=True)
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new plug-in server module")
driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr/td[5]/input').click()
driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()
Select(driver.find_element_by_id("network_component_group")).select_by_visible_text("Network Management")
time.sleep(3)
Select(driver.find_element_by_id("network_component")).select_by_visible_text(plugin_component_name)
driver.find_element_by_id("submit-crtbutton").click()
search_module (driver,agent_name,plugin_component_name,go_to_module=False)
self.assertEqual(plugin_component_name in driver.page_source,True)
def test_C_create_wmi_component(self):
u"""
Create and search new wmi component
"""
driver = self.driver
self.login()
detect_and_pass_all_wizards(driver)
agent_name = gen_random_string(6)
plugin_component_name = gen_random_string(6)
activate_api(driver,"1234")
params = [agent_name,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
create_agent_api(driver,params,user="admin",pwd="pandora")
lista = driver.current_url.split('/')
url = lista[0]+'//'+lista[2]+'/pandora_console'
driver.get(url)
create_wmi_component(driver,plugin_component_name,"Generic numeric","Network Management","Application",max_warning=50,max_critical=100,description="New WMI component")
search_agent(driver,agent_name,go_to_agent=True)
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new WMI server module")
driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr/td[5]/input').click()
driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()
Select(driver.find_element_by_id("network_component_group")).select_by_visible_text("Network Management")
time.sleep(3)
Select(driver.find_element_by_id("network_component")).select_by_visible_text(plugin_component_name)
driver.find_element_by_id("submit-crtbutton").click()
search_module (driver,agent_name,plugin_component_name,go_to_module=False)
self.assertEqual(plugin_component_name in driver.page_source,True)
if __name__ == "__main__":
unittest2.main()

View File

@ -128,6 +128,59 @@ class Policies(PandoraWebDriverTestCase):
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_2+'")]')
self.assertIsInstance(module,WebElement)
@is_enterprise
def test_E_Apply_policy_to_agents_with_spaces(self):
u"""
Create a policy and two agents with spaces in name, apply policy in this agents and check that this it works
"""
policy_name = gen_random_string(6)
agent_name_1 = "test agent 1"
agent_name_2 = "test agent 2"
agent_name_3 = "test agent 3"
module_name = gen_random_string(6)
driver = self.driver
create_agent(driver,agent_name_1,description="First agent by test")
create_agent(driver,agent_name_2,description="Second agent by test")
create_agent(driver,agent_name_3,description="Third agent by test")
create_policy(driver,policy_name,"Applications",description="This is policy by test")
add_module_policy(driver,policy_name,"network_server",driver,module_name=module_name,component_group="Network Management",network_component="Host Alive")
list_agent = (agent_name_1,agent_name_2,agent_name_3)
apply_policy_to_agent(driver,policy_name,list_agent)
search_agent(driver,agent_name_1,go_to_agent=True)
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul//img[@data-title="Manage"]').click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name+'")]')
self.assertIsInstance(module,WebElement)
search_agent(driver,agent_name_2,go_to_agent=True)
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul//img[@data-title="Manage"]').click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name+'")]')
self.assertIsInstance(module,WebElement)
search_agent(driver,agent_name_3,go_to_agent=True)
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul//img[@data-title="Manage"]').click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name+'")]')
self.assertIsInstance(module,WebElement)
if __name__ == "__main__":
unittest2.main()

View File

@ -31,6 +31,62 @@ def force_alert_of_module(driver,agent_name,module_name,template_name):
time.sleep(10)
def create_new_action_to_alert(driver,action_name,action_group,command,threshold=None,field1=None,field2=None,field3=None):
click_menu_element(driver,"Actions")
driver.find_element_by_id("submit-create").click()
driver.find_element_by_id("text-name").clear()
driver.find_element_by_id("text-name").send_keys(action_name)
driver.find_element_by_xpath('//option[contains(.,"'+action_group+'")]').click()
driver.find_element_by_xpath('//option[contains(.,"'+command+'")]').click()
if threshold != None:
driver.find_element_by_id("text-action_threshold").clear()
driver.find_element_by_id("text-action_threshold").send_keys(threshold)
if command == "eMail" and field1 != None and field2 != None and field3 != None:
driver.find_element_by_id("textarea_field1_value").clear()
driver.find_element_by_id("textarea_field1_value").send_keys(field1)
driver.find_element_by_id("textarea_field2_value").clear()
driver.find_element_by_id("textarea_field2_value").send_keys(field2)
driver.find_element_by_id("textarea_field3_value").clear()
driver.find_element_by_id("textarea_field3_value").send_keys(field3)
driver.find_element_by_id("submit-create").click()
def create_new_command_to_alert(driver,command_name,command,list_field_description,list_field_values,description=None):
click_menu_element(driver,"Commands")
driver.find_element_by_id("submit-create").click()
driver.find_element_by_id("text-name").clear()
Select(driver.find_element_by_id("text-name")).send_keys(command_name)
driver.find_element_by_id("textarea_command").clear()
Select(driver.find_element_by_id("textarea_command")).send_keys(command)
if description != None:
driver.find_element_by_id("textarea_description").clear()
Select(driver.find_element_by_id("textarea_description")).send_keys(description)
i=1
for field_description in list_field_description:
driver.find_element_by_id("text-field"+i+"_description").clear()
Select(driver.find_element_by_id("text-field"+i+"_description")).send_keys(field_description)
i=1
for field_value in list_field_values:
driver.find_element_by_id("text-field"+i+"_description").clear()
Select(driver.find_element_by_id("text-field"+i+"_description")).send_keys(field_value)
driver.find_element_by_id("submit-create").click()

View File

@ -98,8 +98,6 @@ def copy_modules_in_bulk(driver,owner_agent_name,module_name_list,destiny_agents
Select(driver.find_element_by_id("option")).select_by_visible_text("Copy modules in bulk")
time.sleep(2)
driver.find_element_by_id("source_id_agent").click()
Select(driver.find_element_by_id("source_id_agent")).select_by_visible_text(owner_agent_name)
time.sleep(3)
@ -110,10 +108,9 @@ def copy_modules_in_bulk(driver,owner_agent_name,module_name_list,destiny_agents
for agent_name in destiny_agents_list:
Select(driver.find_element_by_id("destiny_id_agent")).select_by_visible_text(agent_name)
driver.find_element_by_id("submit-go").click()
alert = driver.switch_to_alert()
alert.accept()
def edit_modules_in_bulk(driver,module_name_list,agent_name_list,new_module_group=None,new_min=None,new_max=None,ff_threshold_list=None):

View File

@ -10,8 +10,7 @@ import random, time
import string
def create_network_component_tcp(driver,name,type_component,group,module_group,min_warning=None,max_warning=None,description=None):
def create_network_component(driver,name,type_component,group,module_group,min_warning=None,max_warning=None,min_critical=None,max_critical=None,str_warning=None,str_critical=None,description=None):
# type_component is for example -> Remote ICMP network agent (latency) or Remote TCP network agent, numeric data
@ -19,6 +18,8 @@ def create_network_component_tcp(driver,name,type_component,group,module_group,m
driver.find_element_by_id("id_component_type").click()
Select(driver.find_element_by_id("id_component_type")).select_by_visible_text("Create a new network component")
driver.find_element_by_id("submit-crt").click()
driver.find_element_by_id("text-name").click()
driver.find_element_by_id("text-name").clear()
@ -27,8 +28,7 @@ def create_network_component_tcp(driver,name,type_component,group,module_group,m
driver.find_element_by_id("type").click()
Select(driver.find_element_by_id("type")).select_by_visible_text(type_component)
driver.find_element_by_id("id_group").click()
Select(driver.find_element_by_id("id_group")).select_by_visible_text(group)
driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click()
driver.find_element_by_id("id_module_group").click()
Select(driver.find_element_by_id("id_module_group")).select_by_visible_text(module_group)
@ -57,6 +57,7 @@ def create_network_component_tcp(driver,name,type_component,group,module_group,m
driver.find_element_by_id("text-max_critical").clear()
driver.find_element_by_id("text-max_critical").send_keys(max_critical)
# str_warning and str_critical if type_component supports this type
if str_warning != None:
driver.find_element_by_id("text-str_warning").click()
@ -77,3 +78,139 @@ def create_network_component_tcp(driver,name,type_component,group,module_group,m
driver.find_element_by_id("submit-crt").click()
def create_plugin_component(driver,name,type_component,group,module_group,min_warning=None,max_warning=None,min_critical=None,max_critical=None,str_warning=None,str_critical=None,description=None):
# type_component is for example -> Generic boolean or Generic numeric incremental (absolute)
click_menu_element(driver,"Network components")
driver.find_element_by_xpath('//*[@id="id_component_type"]/option[2]').click()
driver.find_element_by_id("submit-crt").click()
driver.find_element_by_id("text-name").click()
driver.find_element_by_id("text-name").clear()
driver.find_element_by_id("text-name").send_keys(name)
driver.find_element_by_id("type").click()
Select(driver.find_element_by_id("type")).select_by_visible_text(type_component)
driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click()
driver.find_element_by_id("id_module_group").click()
Select(driver.find_element_by_id("id_module_group")).select_by_visible_text(module_group)
if min_warning != None:
driver.find_element_by_id("text-min_warning").click()
driver.find_element_by_id("text-min_warning").clear()
driver.find_element_by_id("text-min_warning").send_keys(min_warning)
if max_warning != None:
driver.find_element_by_id("text-max_warning").click()
driver.find_element_by_id("text-max_warning").clear()
driver.find_element_by_id("text-max_warning").send_keys(max_warning)
if min_critical != None:
driver.find_element_by_id("text-min_critical").click()
driver.find_element_by_id("text-min_critical").clear()
driver.find_element_by_id("text-min_critical").send_keys(min_critical)
if max_critical != None:
driver.find_element_by_id("text-max_critical").click()
driver.find_element_by_id("text-max_critical").clear()
driver.find_element_by_id("text-max_critical").send_keys(max_critical)
# str_warning and str_critical for Generic string type:
if str_warning != None:
driver.find_element_by_id("text-str_warning").click()
driver.find_element_by_id("text-str_warning").clear()
driver.find_element_by_id("text-str_warning").send_keys(str_warning)
if str_critical != None:
driver.find_element_by_id("text-str_critical").click()
driver.find_element_by_id("text-str_critical").clear()
driver.find_element_by_id("text-str_critical").send_keys(str_critical)
if description != None:
driver.find_element_by_id("textarea_description").click()
driver.find_element_by_id("textarea_description").clear()
driver.find_element_by_id("textarea_description").send_keys(description)
driver.find_element_by_id("submit-crt").click()
def create_wmi_component(driver,name,type_component,group,module_group,min_warning=None,max_warning=None,min_critical=None,max_critical=None,str_warning=None,str_critical=None,description=None):
# type_component is for example -> Generic boolean or Generic numeric incremental (absolute)
click_menu_element(driver,"Network components")
driver.find_element_by_xpath('//*[@id="id_component_type"]/option[3]').click()
driver.find_element_by_id("submit-crt").click()
driver.find_element_by_id("text-name").click()
driver.find_element_by_id("text-name").clear()
driver.find_element_by_id("text-name").send_keys(name)
driver.find_element_by_id("type").click()
Select(driver.find_element_by_id("type")).select_by_visible_text(type_component)
driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click()
driver.find_element_by_id("id_module_group").click()
Select(driver.find_element_by_id("id_module_group")).select_by_visible_text(module_group)
if min_warning != None:
driver.find_element_by_id("text-min_warning").click()
driver.find_element_by_id("text-min_warning").clear()
driver.find_element_by_id("text-min_warning").send_keys(min_warning)
if max_warning != None:
driver.find_element_by_id("text-max_warning").click()
driver.find_element_by_id("text-max_warning").clear()
driver.find_element_by_id("text-max_warning").send_keys(max_warning)
if min_critical != None:
driver.find_element_by_id("text-min_critical").click()
driver.find_element_by_id("text-min_critical").clear()
driver.find_element_by_id("text-min_critical").send_keys(min_critical)
if max_critical != None:
driver.find_element_by_id("text-max_critical").click()
driver.find_element_by_id("text-max_critical").clear()
driver.find_element_by_id("text-max_critical").send_keys(max_critical)
# str_warning and str_critical if type_component is Generic boolean
if str_warning != None:
driver.find_element_by_id("text-str_warning").click()
driver.find_element_by_id("text-str_warning").clear()
driver.find_element_by_id("text-str_warning").send_keys(str_warning)
if str_critical != None:
driver.find_element_by_id("text-str_critical").click()
driver.find_element_by_id("text-str_critical").clear()
driver.find_element_by_id("text-str_critical").send_keys(str_critical)
if description != None:
driver.find_element_by_id("textarea_description").click()
driver.find_element_by_id("textarea_description").clear()
driver.find_element_by_id("textarea_description").send_keys(description)
driver.find_element_by_id("submit-crt").click()