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

Merge branch 'rollout-plugins' into 'master'

AWX - handling leerer AWX felder

See merge request !12
parents 1545195a 4cfa05eb
No related branches found
No related tags found
1 merge request!12AWX - handling leerer AWX felder
Pipeline #321 passed
...@@ -131,7 +131,8 @@ ...@@ -131,7 +131,8 @@
"class-project-info-deploy-skip-sync": "SKIP: Synchronisationstyp "%s" wird (noch) nicht unterstützt.", "class-project-info-deploy-skip-sync": "SKIP: Synchronisationstyp "%s" wird (noch) nicht unterstützt.",
"class-project-info-deploy-start-by-method": "Starte Installation auf Zielhosts", "class-project-info-deploy-start-by-method": "Starte Installation auf Zielhosts",
"class-project-info-deploy-start-by-method-skip": "SKIP: es gibt nichts zu tun. Wurde keine Installationsart und/ oder kein Ziel Host definiert.", "class-project-info-deploy-start-by-method-skip": "SKIP: es gibt nichts zu tun. Wurde keine Installationsart und/ oder kein Ziel Host definiert.",
"class-project-info-deploy-successful": "Das Deployment wurde erfolgreich abgeschlossen.", "class-project-info-deploy-successful": "Das Deployment der Phase %s wurde erfolgreich abgeschlossen.",
"class-project-info-deploy-failed": "Das Deployment der Phase %s enthält Fehler.",
"class-project-info-accept-overview": "Info: in der Phase "%s" ist installiert:", "class-project-info-accept-overview": "Info: in der Phase "%s" ist installiert:",
"class-project-info-accept-version-and-next-phase": "Die aktuelle Version [%s] wird nun in die Queue der Phase [%s] gestellt.", "class-project-info-accept-version-and-next-phase": "Die aktuelle Version [%s] wird nun in die Queue der Phase [%s] gestellt.",
"class-project-info-setup-phaseinfos": "Aktiviere die Phasen des Projektes und gib die URLs der jeweiligen Applikationen an.<br>Der Sysadmin muss zudem die einzelnen Hosts in Puppet konfigurieren - bitte neu zuverwendende Server mit ihm abstimmen.", "class-project-info-setup-phaseinfos": "Aktiviere die Phasen des Projektes und gib die URLs der jeweiligen Applikationen an.<br>Der Sysadmin muss zudem die einzelnen Hosts in Puppet konfigurieren - bitte neu zuverwendende Server mit ihm abstimmen.",
......
...@@ -132,7 +132,8 @@ ...@@ -132,7 +132,8 @@
"class-project-info-deploy-skip-sync": "SKIP: Synchronisation type &quot;%s&quot; is not supported (yet).", "class-project-info-deploy-skip-sync": "SKIP: Synchronisation type &quot;%s&quot; is not supported (yet).",
"class-project-info-deploy-start-by-method": "Starting installation to target hosts", "class-project-info-deploy-start-by-method": "Starting installation to target hosts",
"class-project-info-deploy-start-by-method-skip": "SKIP: nothing to do. No method an/ or target host were defined.", "class-project-info-deploy-start-by-method-skip": "SKIP: nothing to do. No method an/ or target host were defined.",
"class-project-info-deploy-successful": "The deployment was finished successfully.", "class-project-info-deploy-successful": "The deployment of phase %s was finished successfully.",
"class-project-info-deploy-failed": "The deployment of phase %s failed.",
"class-project-info-accept-overview": "Info: in the phase &quot;%s&quot; is installed:", "class-project-info-accept-overview": "Info: in the phase &quot;%s&quot; is installed:",
"class-project-info-accept-version-and-next-phase": "The current version [%s] will be put to the queue of phase [%s].", "class-project-info-accept-version-and-next-phase": "The current version [%s] will be put to the queue of phase [%s].",
"class-project-info-setup-phaseinfos": "Activate the needed phases for your project. Enter the urls of each phase.<br>Fore new hosts: contact the system administrator - he must configure the hosts before the project can be installed there.", "class-project-info-setup-phaseinfos": "Activate the needed phases for your project. Enter the urls of each phase.<br>Fore new hosts: contact the system administrator - he must configure the hosts before the project can be installed there.",
......
...@@ -2191,12 +2191,7 @@ class project extends base { ...@@ -2191,12 +2191,7 @@ class project extends base {
$sReturn.=t("class-project-info-deploy-start-by-method-skip") . "<br>"; $sReturn.=t("class-project-info-deploy-start-by-method-skip") . "<br>";
} else { } else {
$sReturn.='<p>' $sReturn.='<p>' . 'Plugin: '.$this->oRolloutPlugin->getId().'</p>';
. 'Plugin: '.$this->oRolloutPlugin->getId().'<br>'
. '</p>'
. '<pre>Config for phase '.$sPhase.' = '.print_r($this->oRolloutPlugin->getConfig($sPhase), 1).'</pre>'
. '<pre>Commands = '.print_r($this->oRolloutPlugin->getDeployCommands($sPhase), 1).'</pre>'
;
foreach($this->oRolloutPlugin->getDeployCommands($sPhase) as $sCmd){ foreach($this->oRolloutPlugin->getDeployCommands($sPhase) as $sCmd){
$sReturn.=$this->_execAndSend("$sCmd"); $sReturn.=$this->_execAndSend("$sCmd");
...@@ -2234,10 +2229,18 @@ class project extends base { ...@@ -2234,10 +2229,18 @@ class project extends base {
$this->_TempFill($sReturn, $aActionList); $this->_TempFill($sReturn, $aActionList);
$sReturn.="<br>"; $sReturn.="<br>";
$sReturn.=$this->_oHtml->getBox("success", t("class-project-info-deploy-successful"));
$this->_sendMessage(t("class-project-info-deploy-successful")."\nphase: ${sPhase}\n"); if (!$this->_iRcAll == 0) {
$this->_logaction(t('finished') . " deploy($sPhase, $bIgnoreDeploytimes) " . t("class-project-info-deploy-successful"), __FUNCTION__, "success"); $sWarnlevel='error';
$sMessage = sprintf(t('class-project-info-deploy-failed'), $sPhase);
} else {
$sWarnlevel='success';
$sMessage=sprintf(t("class-project-info-deploy-successful"), $sPhase);
}
$sReturn.=$this->_oHtml->getBox($sWarnlevel, $sMessage);
$this->_sendMessage($sMessage);
$this->_logaction(t('finished') . " deploy($sPhase, $bIgnoreDeploytimes) " . $sMessage, __FUNCTION__, $sWarnlevel);
$this->_TempDelete(); $this->_TempDelete();
return $sReturn; return $sReturn;
} }
...@@ -3958,12 +3961,24 @@ class project extends base { ...@@ -3958,12 +3961,24 @@ class project extends base {
// -------------------------------------------------- // --------------------------------------------------
// Tab for raw data // Tab for raw data
// -------------------------------------------------- // --------------------------------------------------
$sRolloutDebug='<hr>DEBUG:<br>';
foreach (array_keys($this->getPhases()) as $sPhase) {
if ($this->isActivePhase($sPhase)){
$sRolloutDebug.='<strong>'.$sPhase.'</strong>'
. '<pre>Config = '.print_r($this->oRolloutPlugin->getConfig($sPhase), 1).'</pre>'
. '<pre>Commands = '.print_r($this->oRolloutPlugin->getDeployCommands($sPhase), 1).'</pre>'
;
}
}
$aForms["setup"]["form"]['input' . $i++] = array( $aForms["setup"]["form"]['input' . $i++] = array(
'type' => 'markup', 'type' => 'markup',
'value' => '</div>' 'value' => '</div>'
. '<div class="tab-pane" id="tab6">' . '<div class="tab-pane" id="tab6">'
. '<br><pre>'.print_r($this->_aPrjConfig, 1).'</pre>' . '<br><pre>'.print_r($this->_aPrjConfig, 1).'</pre>'
. $sRolloutDebug
. '</div>' . '</div>'
. '</div>' . '</div>'
......
...@@ -17,7 +17,15 @@ class rollout_awx extends rollout_base { ...@@ -17,7 +17,15 @@ class rollout_awx extends rollout_base {
// no specific checks needed ... always true // no specific checks needed ... always true
return true; return true;
} }
/**
* check access to a deploy target
*/
public function checkConnectionToTarget() {
// do nothing ... always true
return true;
}
/** /**
* 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
...@@ -71,8 +79,6 @@ class rollout_awx extends rollout_base { ...@@ -71,8 +79,6 @@ class rollout_awx extends rollout_base {
return $aReturn; return $aReturn;
} }
/** /**
* get AWX inventories and return them as array for select box * get AWX inventories and return them as array for select box
* [id] => array('value' => [ID], 'label' => [NAME] [ID]) * [id] => array('value' => [ID], 'label' => [NAME] [ID])
...@@ -129,13 +135,6 @@ class rollout_awx extends rollout_base { ...@@ -129,13 +135,6 @@ class rollout_awx extends rollout_base {
return $aReturn; return $aReturn;
} }
/**
* check access to a deploy target
*/
public function checkConnectionToTarget() {
// do nothing ... always true
return true;
}
/** /**
* get array with commands to execute to deploy a package * get array with commands to execute to deploy a package
...@@ -146,17 +145,31 @@ class rollout_awx extends rollout_base { ...@@ -146,17 +145,31 @@ class rollout_awx extends rollout_base {
public function getDeployCommands($sPhase){ public function getDeployCommands($sPhase){
$aReturn=array(); $aReturn=array();
$aConfig=$this->getConfig($sPhase); $aConfig=$this->getConfig($sPhase);
// ----- Checks:
$sCmdChecks='';
if($aConfig['extravars']){
$aTmp=json_decode($aConfig['extravars']);
if (!$aTmp || !count($aTmp) ){
$sCmdChecks.='echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '.$aConfig['extravars'].'"; exit 1; ';
}
$aConfig['extravars']=json_encode($aTmp);
}
if(!(int)$aConfig['inventory']){ if(!(int)$aConfig['inventory']){
$aReturn[]='echo "ERROR: no inventory was given."; exit 1'; $sCmdChecks.='echo "ERROR: no inventory was given."; exit 1; ';
} }
$sJson='{
"inventory": "'.$aConfig['inventory'].'", // ----- Send variables having values only
"limit": "'.$aConfig['limit'].'", $aBodyvars=array();
"job_tags": "'.$aConfig['tags'].'", foreach(['inventory'=>'inventory', 'limit'=>'limit', 'job_tags'=>'tags', 'extra_vars'=>'extravars'] as $sParam=>$sVarkey){
"extra_vars": '.$aConfig['extravars'].' if ($aConfig[$sVarkey]) {
}'; $aBodyvars[$sParam]=$aConfig[$sVarkey];
}
}
$sAuth=($aConfig['user'] ? '--user '.$aConfig['user'].':'.$aConfig['password'] : ''); $sAuth=($aConfig['user'] ? '--user '.$aConfig['user'].':'.$aConfig['password'] : '');
$aReturn[]="curl -f -k -H 'Content-Type: application/json' -XPOST -d '".$sJson."' $sAuth ".$aConfig['url']."/job_templates/".$aConfig['jobtemplate']."/launch/"; $aReturn[]=$sCmdChecks . "curl -f -k -H 'Content-Type: application/json' -XPOST -d '". json_encode($aBodyvars, JSON_PRETTY_PRINT)."' $sAuth ".$aConfig['url']."/job_templates/".$aConfig['jobtemplate']."/launch/";
return $aReturn; return $aReturn;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment