Skip to content
Snippets Groups Projects
Commit be29c329 authored by hahn's avatar hahn
Browse files

- added: comparison of lang texts

- project class: removed a hardcoded variable
- project overview: no tabs (was not handy)
- added: logging project actions
parent 4520e890
No related branches found
No related tags found
No related merge requests found
......@@ -82,7 +82,7 @@ switch (php_uname("n")) {
}
$aConfig = array_merge($aConfig, array(
'appDir' => dirname(dirname(__FILE__)),
'appRootDir' => dirname(dirname(__FILE__)),
'configDir' => dirname(__FILE__),
'buildDir' => $aConfig['workDir'] . '/build',
'buildDefaultsDir' => $aConfig['workDir'] . '/defaults',
......
......@@ -180,6 +180,7 @@
"page-setup-info-check-lang": "Vergleich Sprachtexte",
"page-setup-info-check-lang-intro": "In der nachfolgenden Tabelle werden die sprachabhängigen Texte miteinander verglichen und fehlende Sprachelemente gefunden.",
"aborted": "Abgebrochen",
"accept": "Accept",
"accept-hint": "Accept Phase [%s] und in die Queue von Phase [%s] stellen.",
"all": "alle",
......@@ -206,6 +207,7 @@
"exitcode": "exitcode",
"fileprefix": "File Prefix",
"fileprefix-label": "File-Prefix <span class=\"error\"><br>Nach dem ersten Build nicht mehr änderbar!</span>",
"finished": "Beendet",
"hostname4puppet": "Hostname f&uuml;r Puppet Agent",
"inactive": "inaktiv",
"info": "Info",
......@@ -239,6 +241,7 @@
"setup-metadata": "Allgemeine Metadaten",
"setup-hint-build": "Einstellungen zum Erstellen eines neuen Builds. Es werden Zugriffsdaten auf das Repository benötigt.<br>Der Fileprefix bestimmt einen Teil des Dateinamens und wird auch in Puppet konfiguriert. Er darf nach eingerichtetem Deployment nicht mehr geändert werden.",
"skip": "SKIP",
"starting": "Starte",
"success": "OK",
"unknown": "unbekannt",
"url": "URL",
......
......@@ -182,6 +182,7 @@
"page-setup-info-check-lang-intro": "In the table below the language specific texts will be compared and missing elements will be detected.",
"aborted": "Aborted",
"accept": "Accept",
"accept-hint": "Accept phase [%s] and put package to the queue of phase [%s].",
"all": "all",
......@@ -208,6 +209,7 @@
"exitcode": "exitcode",
"fileprefix": "File prefix",
"fileprefix-label": "File prefix <span class=\"error\"><br>It cannot be changed after the first build!</span>",
"finished": "Fisnished",
"hostname4puppet": "Hostname to start puppet agent",
"inactive": "inactive",
"info": "Info",
......@@ -241,6 +243,7 @@
"setup-metadata": "General metadata",
"setup-hint-build": "Settings to create a new build. You will need credentials to access the repository.<br>The file prefix defines a part of the package name and must be configured in the puppet manifest. After the setup of the deployment or first build it cannot be changed anymore.",
"skip": "SKIP",
"starting": "Starting",
"success": "OK",
"unknown": "unknown",
"url": "Url",
......
File added
......@@ -196,6 +196,18 @@ class project {
return $sReturn;
}
/**
* add an action log message
* @param string $sMessage message
* @param string $sAction project action
* @param string $sLoglevel loglevel
*/
private function _logaction($sMessage, $sAction="", $sLoglevel="info"){
require_once("./classes/actionlog.class.php");
$oLog=new Actionlog($this->_aConfig["id"]);
$oLog->add($sMessage, (__CLASS__."->".$sAction), $sLoglevel);
}
// ----------------------------------------------------------------------
// GETTER
// ----------------------------------------------------------------------
......@@ -766,8 +778,9 @@ class project {
}
switch ($this->_aPrjConfig["build"]["type"]) {
case "git":
$sKeyfile = dirname(dirname(dirname(dirname(__file__)))) . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = dirname(dirname(dirname(dirname(__file__)))) . "/shellscripts/gitsshwrapper.sh";
$sKeyfile = $this->_aConfig["appRootDir"] . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = $this->_aConfig["appRootDir"] . "/shellscripts/gitsshwrapper.sh";
$sTmpDir = "/tmp/checkout_" . $this->_aConfig["id"] . "/";
......@@ -958,6 +971,7 @@ class project {
$this->_iRcAll = 0;
// return $this->_execAndSend("bash --login -c 'ruby --version' " . $sTempDir);
$this->_logaction(t('starting')." build()", __FUNCTION__);
$sReturn = "<h2>" . t("build") . " " . $this->getLabel() . "</h2>";
// --------------------------------------------------
......@@ -977,6 +991,7 @@ class project {
$sFirstLevel = $this->getNextPhase();
if (!$sFirstLevel) {
$this->_TempDelete();
$this->_logaction(t('page-overview-no-phase'), __FUNCTION__, "error");
return false;
}
......@@ -987,7 +1002,9 @@ class project {
$sReturn.=$this->_execAndSend("ls -ld " . $sTempDir);
if (!file_exists($sTempDir)) {
$this->_TempDelete();
return $this->getBox("error", sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempDir) . $sReturn);
$sError=sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempDir);
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
}
$this->_iRcAll = 0;
$aActionList['iActive'] ++;
......@@ -1003,8 +1020,8 @@ class project {
// $sReturn.=$this->_execAndSend("find " . $this->_aConfig["workDir"]);
// SKIP $sReturn.=$this->_execAndSend("cd $sTempDir && git init");
$sKeyfile = dirname(dirname(dirname(dirname(__file__)))) . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = dirname(dirname(dirname(dirname(__file__)))) . "/shellscripts/gitsshwrapper.sh";
$sKeyfile = $this->_aConfig["appRootDir"] . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = $this->_aConfig["appRootDir"] . "/shellscripts/gitsshwrapper.sh";
// $sReturn.=$this->_execAndSend("cd $sTempDir && export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; git pull " . $this->_aPrjConfig["build"]["ssh"]);
$sReturn.=$this->_execAndSend("export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; git clone " . $this->_aPrjConfig["build"]["ssh"] . " $sTempDir ");
......@@ -1026,11 +1043,15 @@ class project {
default:
$this->_TempDelete();
return $this->getBox("error", sprintf(t('class-project-error-build-type-not-supported'), $this->_aPrjConfig["build"]["type"]) . $sReturn);
$sError=sprintf(t('class-project-error-build-type-not-supported'), $this->_aPrjConfig["build"]["type"]);
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error",$sError . $sReturn);
}
if (!$this->_iRcAll == 0) {
$this->_TempDelete();
return $this->getBox("error", sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn);
$sError=sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error",$sError);
}
$sReturn.=$this->getBox("success", t('class-project-info-build-checkout-ok'));
$aActionList['iActive'] ++;
......@@ -1047,7 +1068,9 @@ class project {
$sReturn.=$this->_execAndSend('bash --login -c \'' . $sTempDir . '/' . $sHookfile . '\'');
if (!$this->_iRcAll == 0) {
$this->_TempDelete();
return $this->getBox("error", sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn);
$sError=sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error",$sError);
}
} else {
$sReturn.=t('skip') . '<br>';
......@@ -1080,7 +1103,9 @@ class project {
$sReturn.=$this->_execAndSend('bash --login -c \'' . $sTempDir . '/' . $sHookfile . '\'');
if (!$this->_iRcAll == 0) {
$this->_TempDelete();
return $this->getBox("error", sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn);
$sError=sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError);
}
} else {
$sReturn.=t('skip') . '<br>';
......@@ -1118,12 +1143,16 @@ class project {
if (!$sWebroot) {
$this->_TempDelete();
return $this->getBox("error", t('class-project-error-build-docroot-not-found') . $sReturn);
$sError=t('class-project-error-build-docroot-not-found');
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
}
if (!$this->_iRcAll == 0) {
$this->_TempDelete();
return $this->getBox("error", sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn);
$sError=sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError);
}
// $sReturn.=$this->getBox("success", "preparations ok - directory is ready for packaging now.");
// generate info file
......@@ -1155,7 +1184,9 @@ class project {
$sReturn.=$this->_execAndSend("ls -ld " . dirname($sPackageFileArchiv));
if (!file_exists(dirname($sPackageFileArchiv))) {
$this->_TempDelete();
return $this->getBox("error", sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempDir) . $sReturn);
$sError=sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempDir);
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
}
$this->_TempFill($sReturn, $aActionList);
......@@ -1183,7 +1214,9 @@ class project {
if (!$this->_iRcAll == 0) {
$this->_TempDelete();
return $this->getBox("error", t('class-project-error-build-docroot-not-found') . $sReturn);
$sError=t('class-project-error-build-docroot-not-found');
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
}
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
......@@ -1193,7 +1226,9 @@ class project {
$sReturn.=t("class-project-info-build-remove-oldest-archives");
$sReturn.='<pre>' . print_r($this->cleanupArchive(), true) . '</pre>';
$sReturn.=$this->getBox("success", t("class-project-info-build-successful"));
$sError=t("class-project-info-build-successful");
$this->_logaction(t('finished').' '.$sError, __FUNCTION__, "success");
$sReturn.=$this->getBox("success", $sError);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
......@@ -1222,11 +1257,14 @@ class project {
array('label' => t("class-project-queue-label-deploy")),
),
);
$this->_logaction(t('starting')." queue($sPhase, $sVersion)", __FUNCTION__);
$sReturn = "<h2> " . t("queue") . " " . $this->getLabel() . " :: $sPhase</h2>";
$this->_TempFill($sReturn, $aActionList);
if (!$this->isActivePhase($sPhase)) {
return $sReturn . $this->getBox("error", sprintf(t("class-project-warning-phase-not-active"), $sPhase));
$sError=sprintf(t("class-project-warning-phase-not-active"), $sPhase);
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
}
$sPlace = "onhold";
......@@ -1273,8 +1311,11 @@ class project {
if (!$this->_iRcAll == 0) {
$this->_TempDelete();
return $this->getBox("error", t("class-project-error-command-failed") . $sReturn);
$sError=t("class-project-error-command-failed");
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
}
$this->_logaction(t('finished')." queue($sPhase, $sVersion) " . t("class-project-info-queue-successful"), __FUNCTION__);
$sReturn.=$this->getBox("success", t("class-project-info-queue-successful"));
$sReturn.=$this->deploy($sPhase);
$this->_TempDelete();
......@@ -1301,11 +1342,14 @@ class project {
array('label' => t("class-project-deploy-label-install-on-target")),
),
);
$this->_logaction(t('starting')." deploy($sPhase, $bIgnoreDeploytimes)", __FUNCTION__);
$sReturn = "<h2>" . t("deploy") . " " . $this->getLabel() . " :: $sPhase</h2>";
$this->_TempFill($sReturn, $aActionList);
if (!$this->isActivePhase($sPhase)) {
return $sReturn . $this->getBox("error", sprintf(t("class-project-warning-phase-not-active"), $sPhase));
$sError=sprintf(t("class-project-warning-phase-not-active"), $sPhase);
$this->_logaction($sError, __FUNCTION__, "error");
return $sReturn . $this->getBox("error", $sError);
}
$sQueueLink = $this->_getFileBase($sPhase, "onhold");
......@@ -1333,7 +1377,9 @@ class project {
}
if (!$bCanDeploy) {
if (!$bIgnoreDeploytimes) {
$sReturn.=$this->getBox("info", t("class-project-info-deploy-time-not-reached"));
$sError=t("class-project-info-deploy-time-not-reached");
$this->_logaction($sError, __FUNCTION__, "error");
$sReturn.=$this->getBox("info", $sError);
$this->_TempDelete();
return $sReturn;
} else {
......@@ -1345,7 +1391,9 @@ class project {
// if ()
}
if (!file_exists($sQueueLink)) {
$sReturn.=$this->getBox("info", sprintf(t("class-project-info-deploy-nothing-in-queue"), $sQueueLink));
$sError=sprintf(t("class-project-info-deploy-nothing-in-queue"), $sQueueLink);
$this->_logaction($sError, __FUNCTION__, "error");
$sReturn.=$this->getBox("info", $sError);
$this->_TempDelete();
return $sReturn;
}
......@@ -1369,7 +1417,10 @@ class project {
if (!$this->_iRcAll == 0) {
$this->_TempDelete();
return $this->getBox("error", t("class-project-error-command-failed") . $sReturn);
$sError=t("class-project-error-command-failed");
$this->_logaction($sError, __FUNCTION__, "error");
$sReturn.=$this->getBox("error", $sError. $sReturn);
return $sReturn;
}
$aActionList['iActive'] ++;
......@@ -1433,6 +1484,7 @@ class project {
$sReturn.="<br>";
$sReturn.=$this->getBox("success", t("class-project-info-deploy-successful"));
$this->_logaction(t('finished')." deploy($sPhase, $bIgnoreDeploytimes) " . t("class-project-info-deploy-successful"), __FUNCTION__, "success");
$this->_TempDelete();
return $sReturn;
}
......@@ -1445,8 +1497,12 @@ class project {
*/
public function accept($sPhase) {
$sReturn = "<h2>" . t("accept") . " " . $this->getLabel() . " :: $sPhase</h2>";
$this->_logaction(t('starting')." accept($sPhase)", __FUNCTION__);
if (!$this->canAcceptPhase($sPhase)) {
return $sReturn . $this->getBox("error", sprintf(t("class-project-error-accept-impossible"), $sPhase));
$sError=sprintf(t("class-project-error-accept-impossible"), $sPhase);
$this->_logaction($sError, __FUNCTION__, "error");
return $sReturn . $this->getBox("error", $sError);
}
$sReturn.="<h3>" . sprintf(t("class-project-info-accept-overview"), $sPhase) . "</h3>";
......@@ -1458,6 +1514,7 @@ class project {
$sReturn.='<pre>' . print_r($aInfos["deployed"], true) . '</pre>';
$sReturn.=$this->getBox("info", sprintf(t("class-project-info-accept-version-and-next-phase"), $sVersion, $sNext));
$this->_logaction(t('finished')." accept($sPhase)" .sprintf(t("class-project-info-accept-version-and-next-phase"), $sVersion, $sNext), __FUNCTION__, "success");
$sReturn.=$this->queue($sNext, $sVersion);
$this->_TempFill($sReturn);
$this->_TempDelete();
......@@ -1470,10 +1527,13 @@ class project {
* @return boolean
*/
public function saveConfig($aData = false) {
$this->_logaction(t('starting')." saveConfig(...)", __FUNCTION__);
if (!$aData)
$aData = $_POST;
if (!array_key_exists("id", $aData))
if (!array_key_exists("id", $aData)) {
$this->_logaction(t('abortet')." no id in \$_POST", __FUNCTION__, "error");
return false;
}
// if (!array_key_exists("setupaction", $_POST)) return false;
$sId = $aData["id"];
......@@ -1491,6 +1551,7 @@ class project {
copy($sCfgFile, $sBakFile);
$bReturn = file_put_contents($sCfgFile, json_encode($aData));
$this->_logaction(t('finished')." saveConfig(...)", __FUNCTION__, "success");
$this->setProjectById($sId);
return $bReturn;
}
......@@ -1502,18 +1563,27 @@ class project {
* @return string
*/
public function create($sId) {
$this->_logaction(t('starting')." create($sId)", __FUNCTION__);
if (!$sId) {
return t("class-project-error-create-missing-id");
$sError=t("class-project-error-create-missing-id");
$this->_logaction(t('aborted')." create($sId)" . $sError, __FUNCTION__, "error");
return $sError;
}
$s = preg_replace('/[a-z\-\_0-9]*/', "", $sId);
if ($s) {
return sprintf(t("class-project-error-create-wrcng-chars-in-id"), $sId);
$sError=sprintf(t("class-project-error-create-wrcng-chars-in-id"), $sId);
$this->_logaction(t('aborted')." create($sId)" . $sError, __FUNCTION__, "error");
return $sError;
}
if ($sId == "all") {
return sprintf(t("class-project-error-create-id-has-reserved-name"), $sId);
$sError=sprintf(t("class-project-error-create-id-has-reserved-name"), $sId);
$this->_logaction(t('aborted')." create($sId)" . $sError, __FUNCTION__, "error");
return $sError;
}
if (array_search($sId, $this->getProjects()) !== false) {
return sprintf(t("class-project-error-create-id-exists"), $sId);
$sError=sprintf(t("class-project-error-create-id-exists"), $sId);
$this->_logaction(t('aborted')." create($sId)" . $sError, __FUNCTION__, "error");
return $sError;
}
// reset config and create a skeleton
......@@ -1541,10 +1611,13 @@ class project {
$this->_verifyConfig(); // check skeleton
$bReturn = $this->saveConfig($this->_aPrjConfig);
if (!$bReturn) {
return t("class-project-error-create-save-failed");
$sError=t("class-project-error-create-save-failed");
$this->_logaction(t('aborted')." create($sId)" . $sError, __FUNCTION__, "error");
return $sError;
}
// alles OK - dann leeren String
$this->_logaction(t('finished')." create($sId)", __FUNCTION__, "success");
return "";
}
......@@ -1558,6 +1631,7 @@ class project {
if (!file_exists($sCfgfile)) {
return t("class-project-error-delete-project-no-configfile");
}
$this->_logaction(t('starting')." delete()", __FUNCTION__);
// (array("bRemoveRepolinks", "bRemoveArchive", "bRemoveConfig")
// --- remove links in phases directory to built archives
......@@ -1570,7 +1644,9 @@ class project {
if (file_exists($sLink)){
echo "Removing $sLink ($sPhase - $sPlace)...<br>";
if (!unlink($sLink)) {
return t("class-project-error-delete-project-deletion-failed-data");
$sError=t("class-project-error-delete-project-deletion-failed-data");
$this->_logaction(t('aborted')." ". $sError, __FUNCTION__);
return $sError;
}
}
}
......@@ -1590,10 +1666,13 @@ class project {
if (file_exists($sCfgfile)) {
// echo "Delete ${sCfgfile}<br>";
if (!unlink($sCfgfile)) {
return t("class-project-error-delete-project-deletion-failed-configfile");
$sError=t("class-project-error-delete-project-deletion-failed-configfile");
$this->_logaction(t('aborted')." ". $sError, __FUNCTION__);
return $sError;
}
}
}
$this->_logaction(t('finished')." delete()", __FUNCTION__, "success");
return false;
}
......@@ -1941,8 +2020,8 @@ class project {
switch ($this->_aPrjConfig["build"]["type"]) {
case "git":
$sKeyfile = dirname(dirname(__file__)) . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = dirname(dirname(dirname(dirname(__file__)))) . "/shellscripts/gitsshwrapper.sh";
$sKeyfile = $this->_aConfig["appRootDir"] . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = $this->_aConfig["appRootDir"] . "/shellscripts/gitsshwrapper.sh";
$aRepodata = $this->getRepoRevision();
if (array_key_exists("revision", $aRepodata)) {
$sRevision = $aRepodata["revision"];
......
......@@ -57,6 +57,16 @@ if (!@include($sActionFile)) {
$sPhpOut = ob_get_contents();
ob_end_clean();
require_once("./classes/actionlog.class.php");
$oLog=new Actionlog($sPrj);
$sPhpOut.=$oLog->renderLogs(array(
'project'=>$sPrj,
'limit'=>'0, 10',
)
);
$sPhpOut = '
<div id="header" style="display: none;">
IML DEPLOYMENT GUI
......@@ -72,6 +82,7 @@ $sPhpOut = '
</div>
';
$oPage = new Page();
$oPage->addResponseHeader("Pragma: no-cache");
$oPage->setOutputtype('html');
......
......@@ -185,3 +185,9 @@ input[type="radio"], input[type="checkbox"] {
input[type="radio"]:checked+label, input[type="checkbox"]:checked+label{
color:#000;background: #f8f8d0 !important;
}
/* ----- log table ----- */
.loglevel-info{}
.loglevel-warning{ background: #fea;}
.loglevel-error{ background: #fcc;}
.loglevel-success{ color: #080;}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment