Open leoncx opened 12 years ago
Original Redmine Comment Author Name: Cedric LECOMTE (Cedric LECOMTE) Original Date: 2012-05-23T12:56:05Z
I have work on this issue this is my current patch in core/class/centreonHost.class.php
@ public function addHostGroup($options) {
$check = $this->checkParameters($options);
if ($check) {
return $check;
}
$svc = new CentreonService($this->DB, "Service");
$info = split(";", $options);
$info[0] = $this->validateName($info[0]);
if ($this->hostExists($info[0]) && strlen($info[0])) {
$convertionTable = array(0 => "host_name",1 => "hostgroup");
$informations = array();
foreach ($info as $key => $value) {
$informations[$convertionTable[$key]] = $value;
}
}
/***
* Init HostGroup object
*/
$this->hg = new CentreonHostGroup($this->DB);
/***
* Check if hostgroup(s) exists
*/
if (isset($informations["hostgroup"]) && $informations["hostgroup"]) {
if (strstr($informations["hostgroup"], ",")) {
$tab = split(",", $informations["hostgroup"]);
foreach ($tab as $hostgroup_name) {
if (!$this->hg->hostGroupExists($hostgroup_name)) {
print "Hostgroup '$hostgroup_name' does not exists.\n";
return 2;
}
}
} else {
if (!$this->hg->hostGroupExists($informations["hostgroup"])) {
print "Hostgroup '".$informations["hostgroup"]."' does not exists.\n";
return 2;
}
}
}
/***
* Get host ID.
*/
$host_id = $this->getHostID($informations['host_name']);
/***
* Insert hostgroup relation
*/
if (isset($informations["hostgroup"]) && $informations["hostgroup"]) {
if (strstr($informations["hostgroup"], ",")) {
$tab = split(",", $informations["hostgroup"]);
foreach ($tab as $hostgroup_name) {
$request = "INSERT INTO hostgroup_relation (hostgroup_hg_id, host_host_id) values ((SELECT hg_id FROM hostgroup WHERE hg_name LIKE '".$hostgroup_name."'),".$host_id.")";
} } }@
Original Redmine Comment Author Name: Cedric LECOMTE (Cedric LECOMTE) Original Date: 2012-06-14T08:10:48Z
Le dernier ticket étant assez illisible je vais faire plus propre. En pièce jointe la fonction que j'ai rajouté au fichier core/class/centreonHost.class.php
Cette fonction permet d'associer un hostgroup à un host (Fonction détaillé dans le wiki : http://forge.centreon.com/projects/centreon-clapi/wiki/Host "Tie hostgroups to a host").
Il reste a faire un check pour vérifier si la liaison entre le hostgroup et le host n'existe pas déjà (visiblement il n'y pas de contrainte d'intégrité a ce niveau dans MySQL).
Cédric.
Original Redmine Comment Author Name: Laurent Pinsivy (Laurent Pinsivy) Original Date: 2012-07-03T10:05:46Z
Can just you attach the patch containing the delta of modified lines by using the following command?
diff -Nru file1 file2 > patch_hostgroup.diff
Regards,
Original Redmine Comment Author Name: Cedric LECOMTE (Cedric LECOMTE) Original Date: 2012-07-03T12:31:02Z
Sorry for the dirty patch :-)
This is a diff -Nru
Original Redmine Comment Author Name: Julien Mathis (Julien Mathis) Original Date: 2012-08-03T13:10:35Z
Please prefer using method addChild in the hostgroup object. In the host object you canot configure hostgroups content.
Thanks
Author Name: granjerox - (granjerox -) Original Redmine Issue: 3238, https://forge.centreon.com/issues/3238 Original Date: 2012-04-14
I'm working on a script to parse csv files and load it to centreon db with Clapi. I came to the point to update hostgroups on existing hosts but when I try the commands from the documentation the module prints "Method not implemented into Centreon API."
I'm using Centreon 2.3.4 and svn rev. 323 clapi version 1.2
./centreon -u admin -p admin -o HOST -a addhostgroup -v "Centreon-Server-II;Printers" Method not implemented into Centreon API.
I've also seen bugs issued for versions 1.3 and 1.4. how can I get those ?