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

Merge branch 'task-2494-config-replacement' into 'master'

Task 2494 config replacement

See merge request !87
parents 2a04ab4b 12115f73
No related branches found
No related tags found
No related merge requests found
...@@ -101,6 +101,10 @@ class configreplacement { ...@@ -101,6 +101,10 @@ class configreplacement {
*/ */
protected function _getForemanReplacement(){ protected function _getForemanReplacement(){
global $aConfig; global $aConfig;
$sProject = $this->_oProject->getId();
// echo "DEBUG: project id = $sProject<br>";
if (!$this->_sPhase){ if (!$this->_sPhase){
return false; return false;
} }
...@@ -111,12 +115,12 @@ class configreplacement { ...@@ -111,12 +115,12 @@ class configreplacement {
} }
// return already cached result // return already cached result
if (array_key_exists($this->_sPhase, $this->_aForemanReplacements)){ if (array_key_exists($sProject, $this->_aForemanReplacements)){
return $this->_aForemanReplacements[$this->_sPhase]; return $this->_aForemanReplacements[$sProject];
} }
// rebuilt // rebuilt
$this->_aForemanReplacements[$this->_sPhase]=false; $this->_aForemanReplacements[$sProject]=false;
$iEffectiveHostgroup=$this->getForemanHostgroup(); $iEffectiveHostgroup=$this->getForemanHostgroup();
// abort if no hostgroup was set // abort if no hostgroup was set
...@@ -204,8 +208,12 @@ class configreplacement { ...@@ -204,8 +208,12 @@ class configreplacement {
$aYaml=spyc_load($sPart); $aYaml=spyc_load($sPart);
// echo 'DEBUG: <pre>'.print_r($aYaml, 1).'</pre>'; // echo 'DEBUG: <pre>'.print_r($aYaml, 1).'</pre>';
if (!isset($aYaml[$sProject])){
return false;
}
foreach ($aYaml as $sPrjId=>$aProject){
$aReturn=array(); $aReturn=array();
foreach ($aYaml as $aProject){
foreach ($aProject as $sFile=>$aParams){ foreach ($aProject as $sFile=>$aParams){
$aReturn[$sFile]=array(); $aReturn[$sFile]=array();
if (array_key_exists('target', $aParams)){ if (array_key_exists('target', $aParams)){
...@@ -222,9 +230,8 @@ class configreplacement { ...@@ -222,9 +230,8 @@ class configreplacement {
} }
} }
} }
} $this->_aForemanReplacements[$sPrjId]=array(
'phase'=>$this->_sPhase,
$this->_aForemanReplacements[$this->_sPhase]=array(
'rules'=>$aReturn, 'rules'=>$aReturn,
'host'=>$sHost, 'host'=>$sHost,
'yaml'=>$sPart, 'yaml'=>$sPart,
...@@ -232,7 +239,9 @@ class configreplacement { ...@@ -232,7 +239,9 @@ class configreplacement {
'hostsall'=>$aHosts, 'hostsall'=>$aHosts,
'hostsphase'=>$aHostsOfPhase, 'hostsphase'=>$aHostsOfPhase,
); );
return $this->_aForemanReplacements[$this->_sPhase]; }
return $this->_aForemanReplacements[$sProject];
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment