Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment
Commits
cd7b238a
Commit
cd7b238a
authored
8 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
public_html/deployment/classes/deploy-foreman.class.php
+40
-8
40 additions, 8 deletions
public_html/deployment/classes/deploy-foreman.class.php
with
40 additions
and
8 deletions
public_html/deployment/classes/deploy-foreman.class.php
+
40
−
8
View file @
cd7b238a
...
...
@@ -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
// ----------------------------------------------------------------------
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment