diff --git a/shellscripts/convert_projects_2_rollout-plugins.php b/shellscripts/convert_projects_2_rollout-plugins.php index 2fddfad1136935afd29ac285c5a5684c00d3fc3e..18be679db35d1154739b2e8d7e1e0e5dcbd6f4fd 100644 --- a/shellscripts/convert_projects_2_rollout-plugins.php +++ b/shellscripts/convert_projects_2_rollout-plugins.php @@ -22,6 +22,22 @@ require_once("$sDocroot/../config/inc_projects_config.php"); require_once("$sDocroot/deployment/inc_functions.php"); require_once("$sDocroot/deployment/classes/project.class.php"); +$aSkipped=array(); +$aUntouched=array(); + +// ---------------------------------------------------------------------- +// FUNCTIONS +// ---------------------------------------------------------------------- + +function getUrl($s){ + return 'https://ci.iml.unibe.ch/deployment/'.$s.'/setup/'; +} + + +// ---------------------------------------------------------------------- +// MAIN +// ---------------------------------------------------------------------- + echo "\n"; echo "===== IMLDEPLOYMENT - converter for rollout plugins\n"; echo "\n"; @@ -38,9 +54,48 @@ foreach ($oPrj1->getProjects() as $sPrj) { if(isset($aCfg['deploy']['enabled_rollout_plugin'])){ echo "SKIP: Project uses rollout plugin [".$aCfg['deploy']['enabled_rollout_plugin']."]\n"; } else { - echo "TODO: Project needs to be converted...\n"; - print_r($aCfg['phases']['preview']['hosts']); - /* + + echo "INFO: No rollout plugin is set - Project needs to be converted...\n"; + $bSave=false; + + if (preg_match('/_se$/', $aCfg['label'])){ + echo "UNTOUCHED: project ending with _se\n"; + $aUntouched[]=$sPrj.' - SE project - '.getUrl($sPrj); + /* + if ($aCfg['deploy']['enabled_rollout_plugin']){ + $bSave=false; + echo " CONFLICT: rollout plugin was set to [".$aCfg['deploy']['enabled_rollout_plugin']."]\n"; + echo " \n"; + } + * + */ + } else { + foreach (array_keys($aCfg['phases']) as $sPhase){ + echo "--- phase $sPhase \n"; + if ($aCfg['phases'][$sPhase]['hosts']){ + $bSave=true; + echo " TASK: target hosts detected: phases -> $sPhase -> hosts = " . $aCfg['phases'][$sPhase]['hosts'] . "\n"; + echo " - set plugin [ssh] for rollout\n"; + $aCfg['deploy']['enabled_rollout_plugin']='ssh'; + echo " - set hosts for ssh plugin phases -> $sPhase -> plugins -> rollout -> ssh -> hosts = ".$aCfg['phases'][$sPhase]['hosts']."\n"; + $aCfg['phases'][$sPhase]['plugins']['rollout']['ssh']['hosts']=$aCfg['phases'][$sPhase]['hosts']; + } + } + if(!$bSave){ + echo "UNTOUCHED: No Deploy host was found.\n"; + $aUntouched[]=$sPrj.' - no deploy host in any phase - '.getUrl($sPrj); + } + } + + if($bSave){ + echo "TODO: save new config\n"; + } else { + echo "SKIP: do NOT saving config.\n"; + $aSkipped[]=$sPrj; + } + + // print_r($aCfg); exit; + /* // convert // ... and save @@ -57,4 +112,10 @@ foreach ($oPrj1->getProjects() as $sPrj) { echo "\n"; } + +echo "----------------------------------------------------------------------\n"; +echo "processed: ".count($oPrj1->getProjects())."\n"; +echo "skipped : ".count($aSkipped)."\n"; +echo "untouched: ".count($aUntouched)." (watch them manually):\n"; +print_r($aUntouched); echo "done\n";