Skip to content
Snippets Groups Projects
Commit cd7b238a authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

task 1462 - add foreman integration: first commit of foreman API class - GET to hostgroups works

parent 13356a34
No related branches found
No related tags found
No related merge requests found
...@@ -5,11 +5,43 @@ ...@@ -5,11 +5,43 @@
* foreman access to API * foreman access to API
* *
* @example * @example
* in project class
* $oForeman=new deployForeman($this->_aConfig['foreman']); * $oForeman=new deployForeman($this->_aConfig['foreman']);
* $aForemanHostgroups=$oForeman->getHostgroups();
* or
* $aForemanHostgroups=$oForeman->getHostgroups(array('id'=>11));
* *
* // enable debugging
* $oForeman->setDebug(1);
*
* // self check
* $oForeman->selfcheck(); die(__FUNCTION__);
*
* // read operating systems and get id and title only
* $aForemanHostgroups=$oForeman->read(array(
* 'request'=>array(
* array('operatingsystems'),
* ),
* 'response'=>array(
* 'id','title'
* ),
* ));
*
* // read details for operating systems #4
* $aForemanHostgroups=$oForeman->read(array(
* 'request'=>array(
* array('operatingsystems', 4),
* ),
* ));
*
*
* $aOptions ... can contain optional subkeys
* - request
* [] list of array(keyword [,id])
* - filter (array)
* - search (string)
* - page (string)
* - per_page (string)
* - response (array)
* - list of keys, i.e. array('id', 'title')
* @author hahn * @author hahn
*/ */
class deployForeman { class deployForeman {
...@@ -99,6 +131,7 @@ class deployForeman { ...@@ -99,6 +131,7 @@ class deployForeman {
return true; return true;
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// private functions // private functions
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
...@@ -179,6 +212,7 @@ class deployForeman { ...@@ -179,6 +212,7 @@ class deployForeman {
} }
return $sReturn; return $sReturn;
} }
/** /**
* make an http get request and return the response body * make an http get request and return the response body
* it is called by _makeRequest * it is called by _makeRequest
...@@ -238,7 +272,7 @@ class deployForeman { ...@@ -238,7 +272,7 @@ class deployForeman {
*/ */
protected function _writeDebug($sMessage){ protected function _writeDebug($sMessage){
if ($this->_bDebug){ if ($this->_bDebug){
echo "$sMessage<br>\n"; echo "DEBUG :: ".__CLASS__." :: $sMessage<br>\n";
} }
return true; return true;
} }
...@@ -364,7 +398,6 @@ class deployForeman { ...@@ -364,7 +398,6 @@ class deployForeman {
return $this->_bDebug=$bNewDebugFlag; return $this->_bDebug=$bNewDebugFlag;
} }
/** /**
* check for missing config entries * check for missing config entries
* @return type * @return type
...@@ -394,18 +427,17 @@ class deployForeman { ...@@ -394,18 +427,17 @@ class deployForeman {
$sOut.="</ul>"; $sOut.="</ul>";
} }
} else { } else {
$sOut.='ERROR: connect to foreman failed.<br>'; $sOut.='ERROR: unable to connect to foreman or missing permissions.<br>';
} }
if ($sWarning){ if ($sWarning){
echo 'WARNINGS:<ol>'.$sWarning.'</ol>'; echo 'WARNINGS:<ol>'.$sWarning.'</ol>';
} }
echo $sOut; echo $sOut;
echo 'API: <pre>'.print_r($aApi,1).'</pre>';
return true; return true;
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// public foreman API functions // public foreman API CRUD functions
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment