diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc
index 6e3c553018d2a95818e76e005a6897064b6b5a25..fc29543b07e6e34eb6ff4f57dfb75e50cec0f1b2 100644 (file)
/* FAI class selection */
var $FAIclass = array(); // The currently selected classes
- var $FAIrelease = "";
- var $FAIdebianMirror = "auto";
+ var $FAIrelease = "";
+ var $FAIdebianMirror = "auto";
+ var $si_active = FALSE;
+ var $si_fai_action_failed = FALSE;
var $cache = array(); // Used as cache in fai mehtods
plugin::plugin ($config, $dn, $parent);
+ /* Check for si daemon */
+ $this->si_active = isset($this->config->current['GOSA_SI']) && !empty($this->config->current['GOSA_SI']);
+
/* Check object group membership */
if(!isset($this->parent->by_object['ogroup'])){
$ldap = $this->config->get_ldap_link();
foreach($this->attrs['gotoLdapServer'] as $value){
$this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value);
}
- }
+ }
+ natcasesort($this->gotoLdapServerList);
+
if(!count($this->gotoLdapServers) && $this->member_of_ogroup){
$this->gotoLdap_inherit = TRUE;
}
}
- if($this->fai_activated){
+ if($this->fai_activated && !$this->si_fai_action_failed && $this->si_active){
/* Check if the current mirror is available
*/
if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
$new_release = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
if(count($this->FAIclass)){
- msg_dialog::display(_("Error"), sprintf(_("FAI release '%s' is not available on mirror '%s' - setting to release '%s'!"), $this->FAIrelease, $this->FAIdebianmirror), ERROR_DIALOG);
+ msg_dialog::display(_("Error"), sprintf(_("FAI release '%s' is not available on mirror '%s' - setting to release '%s'!"), $this->FAIrelease, $this->FAIdebianMirror,$new_release), ERROR_DIALOG);
}
$this->FAIrelease = $new_release;
$this->cache =array();
}
}
- /* Get list of boot kernels */
- if (isset($this->config->data['TABS'])){
- $command= $this->config->search(get_class($this), "KERNELS",array('tabs'));
- if (!check_command($command)){
- $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command,
- get_class($this));
- } else {
- $fh= popen($command, "r");
- while (!feof($fh)) {
- $buffer= trim(fgets($fh, 256));
- if(!empty($buffer)){
- $name=$value = $buffer;
- if(preg_match("/:/",$buffer)){
- $name = preg_replace("/:.*$/","",$buffer);
- $value= preg_replace("/^.*:/","",$buffer);
- $this->gotoBootKernels[$name]= $name.":".$value;
- }else{
- $this->gotoBootKernels[$name]= $value;
- }
- }
- }
- pclose($fh);
- }
- }
-
- /* Turn to default, if we've nothing to inherit */
- if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){
- $this->gotoBootKernel= "default";
- }
+# /* Get list of boot kernels */
+# if (isset($this->config->data['TABS'])){
+# $command= $this->config->search(get_class($this), "KERNELS",array('tabs'));
+# if (!check_command($command)){
+# $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command,
+# get_class($this));
+# } else {
+# $fh= popen($command, "r");
+# while (!feof($fh)) {
+# $buffer= trim(fgets($fh, 256));
+# if(!empty($buffer)){
+# $name=$value = $buffer;
+# if(preg_match("/:/",$buffer)){
+# $name = preg_replace("/:.*$/","",$buffer);
+# $value= preg_replace("/^.*:/","",$buffer);
+# $this->gotoBootKernels[$name]= $name.":".$value;
+# }else{
+# $this->gotoBootKernels[$name]= $value;
+# }
+# }
+# }
+# pclose($fh);
+# }
+# }
+#
+# /* Turn to default, if we've nothing to inherit */
+# if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){
+# $this->gotoBootKernel= "default";
+# }
}
/* Do we represent a valid terminal? */
if (!$this->is_account && $this->parent === NULL){
- $display= "<img alt=\"\" src=\"images/stop.png\" align=middle> <b>".
+ $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle> <b>".
msgPool::noValidExtension(_("workstation"))."</b>";
return ($display);
}
}
if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
- msg_dialog(_("Error"), _("There is already a profile containing a partition table in your configuration!") , ERROR_DIALOG);
+ msg_dialog::display(_("Error"), _("There is already a profile containing a partition table in your configuration!") , ERROR_DIALOG);
}else{
$this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
}
if((isset($_POST['gotoShareAdd'])) && ($this->acl_is_writeable("gotoShare"))) {
/* We assign a share to this user, if we don't know where to mount the share */
if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
- msg_dialog(_("Error"), msgPool::required(_("Mount point")), ERROR_DIALOG);
+ msg_dialog::display(_("Error"), msgPool::required(_("Mount point")), ERROR_DIALOG);
}else{
if(count($this->gotoAvailableShares)){
$a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
}
/* Convert old style entry */
- if (!preg_match('%:ldap://%', $server)){
+ if (!preg_match('%:ldaps?://%', $server)){
$server= "ldap://".preg_replace('/^([^:]+):/', '\1/', $server);
/* Beautify new style entries */
$SelectBoxLdapServer->AddEntry(
array(array("string" => $server),
array("string" =>
- "<input class='center' type='image' src='images/sort_up.png' name='sort_ldap_up_".$key."'> ".
- "<input class='center' type='image' src='images/sort_down.png' name='sort_ldap_down_".$key."'> ".
- "<input class='center' type='image' src='images/edittrash.png' name='gotoLdapRemove_".$key."'>",
+ "<input class='center' type='image' src='images/lists/sort-up.png' name='sort_ldap_up_".$key."'> ".
+ "<input class='center' type='image' src='images/lists/sort-down.png' name='sort_ldap_down_".$key."'> ".
+ "<input class='center' type='image' src='images/lists/trash.png' name='gotoLdapRemove_".$key."'>",
"attach" => "style='text-align:right;width:40px;border-right:0px;'")));
}
if(!in_array($entry,$this->gotoLdapServers)){
/* Convert old style entry */
- if (!preg_match('%:ldap://%', $entry)){
+ if (!preg_match('%:ldap[s]*://%', $entry)){
$entry= "ldap://".preg_replace('/^([^:]+):/', '\1/', $entry);
/* Beautify new style entries */
$smarty->assign("fai_activated",$this->fai_activated);
/* Create FAI output */
- if($this->fai_activated){
-
- $this->update_fai_cache();
+ $this->update_fai_cache();
+ $smarty->assign("si_fai_action_failed",$this->si_fai_action_failed);
+ $smarty->assign("si_active",$this->si_active);
+
+ if(!$this->si_fai_action_failed && $this->si_active && $this->fai_activated){
$smarty->assign("FAIservers" , $this->cache['SERVERS']);
$smarty->assign("FAIdebianMirror",$this->FAIdebianMirror);
$smarty->assign("FAIrelease" , $this->FAIrelease);
$smarty->assign("FAIclasses" , $this->selectable_classes());
+ /* Get classes for release from cache.
+ * Or build cache
+ */
+ if($this->FAIdebianMirror == "inherited"){
+ $release = $this->InheritedFAIrelease;
+ }else{
+ $release = $this->FAIrelease;
+ }
+
+ $smarty->assign("gotoBootKernels",$this->cache['KERNELS'][$release]);
$smarty->assign("InheritedFAIrelease",$this->InheritedFAIrelease);
$div = new divSelectBox("WSFAIscriptClasses");
$div -> SetHeight("110");
- $str_up = " <input type='image' src='images/sort_up.png' name='sort_up_%s' value='%s'>";
- $str_down = " <input type='image' src='images/sort_down.png' name='sort_down_%s' value='%s'>";
- $str_remove = " <input type='image' src='images/edittrash.png' name='fai_remove_%s' value='%s'>";
+ $str_up = " <input type='image' src='images/lists/sort-up.png' name='sort_up_%s' value='%s'>";
+ $str_down = " <input type='image' src='images/lists/sort-down.png' name='sort_down_%s' value='%s'>";
+ $str_remove = " <input type='image' src='images/lists/trash.png' name='fai_remove_%s' value='%s'>";
$str_empty = " <img src='images/empty.png' alt=\"\" width='7'>";
/* Get classes */
plugin::save();
unset( $this->attrs['FAIrelease'] );
-
$str = "";
/* Skip FAI attribute handling if not necessary */
- if($this->fai_activated){
+ if($this->fai_activated && !$this->si_fai_action_failed){
if($this->FAIdebianMirror == "inherited"){
- $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] = $this->attrs['FAIdebianMirror'] = array();
+ $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] = $this->attrs['FAIdebianMirror'] = array();
}else{
foreach($this->FAIclass as $class){
$str .= $class." ";
}
- $str .= ":" . $this->FAIrelease;
- $this->attrs['FAIclass']= "";
- $this->attrs['FAIclass']= trim($str);
-
+ $str = trim($str);
if(empty($this->attrs['FAIclass'])){
$this->attrs['FAIclass'] = array();
+ }else{
+ $this->attrs['FAIclass']= $str." :".$this->FAIrelease;
}
}
}
-
+
/* Add missing arrays */
foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
if (isset ($this->$val) && count ($this->$val) != 0){
}
}
- /* Check if LDAP server has changed */
- $ldap_changed= false;
- if (isset($this->saved_attributes['gotoLdapServer'])){
- if (isset($this->attrs['gotoLdapServer']) && $this->attrs['gotoLdapServer'] != $this->saved_attributes['gotoLdapServer']){
- $ldap_changed= true;
- }
- } else {
- if (isset($this->attrs['gotoLdapServer'])){
- $ldap_changed= true;
- }
- }
-
- if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){
+ if ($this->attrs['gotoBootKernel'] == "default-inherited"){
$this->attrs['gotoBootKernel']= array();
}
/* Skip FAI attribute handling if not necessary */
- if($this->fai_activated){
+ if($this->fai_activated && !$this->si_fai_action_failed && $this->si_active){
$ldap->cat($this->dn,array("FAIstate"));
$checkFAIstate = $ldap->fetch();
$this->attrs['FAIclass'] = array();
$this->attrs['FAIdebianMirror'] = array();
}
- }
+ }else{
+ /* Don't touch FAI objects if something went wrong with the si daemon.
+ */
+ if(isset($this->attrs['FAIclass'])) unset($this->attrs['FAIclass']);
+ if(isset($this->attrs['FAIdebianMirror'])) unset($this->attrs['FAIdebianMirror']);
+ }
/* prepare share settings */
$tmp = array();
$tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
}
$this->attrs['gotoShare']=$tmp;
-
$this->cleanup();
$ldap->modify ($this->attrs);
new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
$this->handle_post_events("modify");
/* Check if LDAP server has changed */
- if ($ldap_changed && class_available("DaemonEvent")){
+ if ((isset($this->attrs['gotoLdapServer']) && class_available("DaemonEvent")) || $this->gotoLdap_inherit){
$events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
$o_queue = new gosaSupportDaemon();
if(isset($events['TRIGGERED']['DaemonEvent_reload_ldap_config'])){
if(!empty($mac)){
$macs[] = $mac;
}
+ }elseif(isset($this->parent->by_object['servgeneric']->netConfigDNS->macAddress)){
+
+ /* We are a server. Add current mac.
+ */
+ $mac = $this->parent->by_object['servgeneric']->netConfigDNS->macAddress;
+ if(!empty($mac)){
+ $macs[] = $mac;
+ }
}
/* Trigger event for all member objects
*/
function update_fai_cache($first_call = FALSE)
{
- $force = TRUE;
-
+ $force = FALSE;
+ if(!$this->si_active) return;
$start = microtime(TRUE);
+ if($this->si_fai_action_failed && !isset($_POST['fai_si_retry'])) return;
+
+ $this->si_fai_action_failed = FALSE;
+
/* Get the list of available servers and their releases.
*/
if($force || !isset($this->cache['SERVERS'])){
$tmp = $o_queue->FAI_get_server();
if($o_queue->is_error()){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+ $this->si_fai_action_failed = TRUE;
+ $this->cache = array();
+ return;
}else{
foreach($tmp as $entry){
$rel = $entry['RELEASE'];
*/
$o_queue = new gosaSupportDaemon();
$tmp = $o_queue->FAI_get_classes($release);
+ $this->cache['CLASSES'][$release] = array();
if($o_queue->is_error()){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+ $this->si_fai_action_failed = TRUE;
+ $this->cache=array();
+ return;
}else{
foreach($tmp as $entry){
- $this->cache['CLASSES'][$release][$entry['CLASS']] = $this->analyse_fai_object($entry);
+ $class = $entry['CLASS'];
+ $this->cache['CLASSES'][$release][$class] = $this->analyse_fai_object($entry);
}
}
-
/* Add object caught from external hook
*/
$lines= $this->GetHookElements();
if($release_c == $release){
$this->cache['SERVERS'][$url][$release_c]=$release_c;
$this->cache['SERVERS']['auto'][$release_c]=$release_c;
- foreach ($classes as $class){
+ foreach ($classes_c as $class){
if ($class != ""){
$this->cache['CLASSES'][$release_c][$class]= array();
}
}
}
}
+
+ /* Get list of available kernel for this release
+ */
+ if($force || !isset($this->cache['KERNELS'][$release])){
+ $o_queue = new gosaSupportDaemon();
+ $tmp = $o_queue->FAI_get_kernels($release);
+ $this->cache['KERNELS'][$release] = array();
+ foreach($this->gotoBootKernels as $name => $default){
+ $this->cache['KERNELS'][$release][$name] = $default;
+ }
+ foreach($tmp as $kernel){
+ if(empty($kernel)) continue;
+ $this->cache['KERNELS'][$release][$kernel]=$kernel;
+ }
+ }
+ ksort($this->cache['KERNELS'][$release]);
}
$res = shell_exec($cmd);
$res2 = trim($res);
if((!$res)){
- msg_dialog(_("Configuration error"), msgPool::cmdexecfailed("REPOSITORY_HOOK", $cmd), ERROR_DIALOG);
+ msg_dialog::display(_("Configuration error"), msgPool::cmdexecfailed("REPOSITORY_HOOK", $cmd), ERROR_DIALOG);
}elseif(empty($res2)){
- msg_dialog(_("Configuration error"), _("REPOSITORY_HOOK returned no result!"), ERROR_DIALOG);
+ msg_dialog::display(_("Configuration error"), _("REPOSITORY_HOOK returned no result!"), ERROR_DIALOG);
}else{
$tmp = split("\n",$res);
foreach($tmp as $line){