diff --git a/public_html/deployment/classes/deploy-foreman.class.php b/public_html/deployment/classes/deploy-foreman.class.php index 564bc71a085e7714e9d0ff7098dde13898281b68..b99127d115155e3d06941b29762f9786ca57f49d 100644 --- a/public_html/deployment/classes/deploy-foreman.class.php +++ b/public_html/deployment/classes/deploy-foreman.class.php @@ -5,11 +5,43 @@ * foreman access to API * * @example + * in project class * $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 */ class deployForeman { @@ -99,6 +131,7 @@ class deployForeman { return true; } + // ---------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------- @@ -179,6 +212,7 @@ class deployForeman { } return $sReturn; } + /** * make an http get request and return the response body * it is called by _makeRequest @@ -238,7 +272,7 @@ class deployForeman { */ protected function _writeDebug($sMessage){ if ($this->_bDebug){ - echo "$sMessage<br>\n"; + echo "DEBUG :: ".__CLASS__." :: $sMessage<br>\n"; } return true; } @@ -364,7 +398,6 @@ class deployForeman { return $this->_bDebug=$bNewDebugFlag; } - /** * check for missing config entries * @return type @@ -394,18 +427,17 @@ class deployForeman { $sOut.="</ul>"; } } else { - $sOut.='ERROR: connect to foreman failed.<br>'; + $sOut.='ERROR: unable to connect to foreman or missing permissions.<br>'; } if ($sWarning){ echo 'WARNINGS:<ol>'.$sWarning.'</ol>'; } echo $sOut; - echo 'API: <pre>'.print_r($aApi,1).'</pre>'; return true; } // ---------------------------------------------------------------------- - // public foreman API functions + // public foreman API CRUD functions // ---------------------------------------------------------------------- /**