Code

Updated loading of kernel packages
[gosa.git] / gosa-plugins / goto / admin / systems / goto / Device / class_InstallRecipe.inc
index 9fc2272b07f48d6321af139a415b7119f8456f51..c3908a4054b6a7e992bd51c7ebdc854fa0e0dd19 100644 (file)
 class InstallRecipe extends plugin
 {
 
-    /* This has to be replaced by valid attributes, currently they are just 
-     *  fake variables. #FIXME: I do not know the real attribute names yet.
-     */
-    public $installBootstrapMethod = '';
-    public $installBootstrapMethodList = NULL;
+    public $rpcErrorMessage = "";
+    public $deviceUUID = "";
+
+    // Template options
+    public $installTemplate = "";
+    public $installationTemplateNames = array();
+    public $templateToRelease = array();
+    public $installationTemplates = array();
+    
+    // The selected installation release
+    public $installRelease = "";
 
+    // Selected config management variant
     public $installConfigManagement = '';
-    public $installConfigManagementList = NULL;
+    public $installConfigManagementList = array();
 
-    /* Plugin attributes
-     */
-    public $installTemplateDN = "";
-    public $installTemplateDNList = array();
+    // Bootstrap method
+    public $installBootstrapMethod = '';
+    public $installBootstrapMethodList = array();
 
-    public $installMirrorDN = "";
-    public $installMirrorDNList = array();
+    // Timezone settings
+    public $installTimezone = "";
+    public $installTimeUTC = "";
 
+    // Kernel packages
     public $installKernelPackage = "";
     public $installKernelPackageList = array();
 
-    public $installKeyboardlayout = "";
-    public $installKeyboardlayoutList = array();
-
+    // System Locale
     public $installSystemLocale = "";
     public $installSystemLocaleList = array();
 
-    public $installTimezone = "";
-    public $installTimeUTC = "";
-
+    // Selected NTP Server
     public $installNTPServer = array();
+    public $installNTPServerList = NULL;
+
+    // Root password
     public $installRootEnabled = "";
     public $installRootPasswordHash = "";
+    public $setPasswordHash = FALSE;
 
-    public $setKickstartRootPasswordHash = FALSE;
+    // Partition table variables
     public $installPartitionTable = "";
-    private $installNTPServerList = NULL;
+    private $partitionEdit = NULL;
+
+    // Keyboard-layout attribute
+    public $installKeyboardlayout = "";
+    public $installKeyboardlayoutList = array();
+
+    // Mirror related attribute
+    public $installMirror = "";
+    public $installMirrorList = array();
 
-    public $objectclasses = array('installRecipe');
-    public $attributes = array("installTemplateDN","installKeyboardlayout","installSystemLocale",
-            "installTimezone","installTimeUTC","installNTPServer","installMirrorDN",
+    public $objectclasses = array();
+    public $attributes = array("installRelease", "installTemplate","installKeyboardlayout","installSystemLocale",
+            "installTimezone","installTimeUTC","installNTPServer","installMirror",
             "installRootEnabled","installRootPasswordHash","installKernelPackage",
             "installPartitionTable","installConfigManagement","installBootstrapMethod");
 
-    private $map = array('puppet' => array('objectClass' => 'puppetClient', 'type' => 'puppet', 'bootstrap' => 'preseed'));
 
     /* Some plugin management related attributes 
      * See class plugin for details.
      */
     public $view_logged = FALSE;
     public $ignore_account = FALSE;
-
+    public $parent = NULL;
 
     /*! \brief  Initialize the plugin and its widgets. 
      *          Finally call init() to load values from the backend.
      */ 
-    function __construct(&$config, $dn)
+    function __construct(&$config, $dn, $parent)
     {
         plugin::plugin($config, $dn);
 
-        // Set default password hash
-        $this->hash = $this->config->get_cfg_value("core","passwordDefaultHash"); 
-
-        // Prepare NTP servers list 
-        $this->installNTPServerList= new sortableListing($this->installNTPServer);
-        $this->installNTPServerList->setDeleteable(true);
-        $this->installNTPServerList->setEditable(false);
-        $this->installNTPServerList->setColspecs(array('*'));
-        $this->installNTPServerList->setWidth("100%");
-        $this->installNTPServerList->setHeight("70px");
-
-        // Init the object values.
-        $this->init();
-    }
-
-   
-    /*! \brief   Load attribute values from the GOsa-backend using jsonRPC 
-     */ 
-    function init()
-    {
-        // Detect account status by checking the used objectClasses
-        $this->is_account = FALSE;
-        foreach($this->map as $type){
-            if(in_array($type['objectClass'], $this->attrs['objectClass'])){
-                $this->installBootstrapMethod = $type['bootstrap'];
-                $this->installConfigManagement = $type['type'];
-                $this->is_account = TRUE;
-            }
-        }
+        $this->is_account = $this->initially_was_account = FALSE;
 
-        // Start without error.
-        $this->initFailed = FALSE;
+        $this->_device = &$parent;
+        $this->deviceUUID = $parent->deviceUUID;
 
-        // Prepare list of timezones
-        $this->timezones = $this->getTimezones();
-
-        // Get list of NTP servers
-        $this->installNTPServer = array();
-        if(isset($this->attrs['installNTPServer']['count'])){
-            for($i = 0; $i < $this->attrs['installNTPServer']['count']; $i++){
-                $this->installNTPServer[] = $this->attrs['installNTPServer'][$i];
-            }
-        }
+        // Set default password hash
+        $this->hash = $this->config->get_cfg_value("core","passwordDefaultHash"); 
 
         // Get list of password hashes
         $tmp = passwordMethod::get_available_methods();
@@ -113,177 +92,206 @@ class InstallRecipe extends plugin
             $this->hashes[$name] = $name;
         }
 
-        // Load list of bootstrap methods.
-        $res = $this->loadInstallationMethods();
-        if($res == NULL){
-            $this->initFailed = TRUE;
-            msg_dialog(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
-            return;
-        }
-        $this->installBootstrapMethodList = $res['installBootstrapMethodList'];
-        $this->installConfigManagementList = $res['installConfigManagementList'];
-
-        // Load system locales 
-        $locales = $this->getSystemLocales();
-        if($locales == NULL){
-            $this->initFailed = TRUE;
-            msg_dialog(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
-            return;
-        }
-        $this->installSystemLocaleList = $locales;
-
-        // Load installation templates
-        $res = $this->loadInstallationTemplates();
-        if($res == NULL){
-            $this->initFailed = TRUE;
-            msg_dialog(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
-            return;
-        }
-        $this->installTemplateDNList = $res;
+        // Initialize plugin
+        $this->init_static_info();
+        $this->init($initially = TRUE); 
+    }
 
+    function init($initially = FALSE)
+    {
+        // Init the object values.
+        $this->init_client_info();
 
-        // Load installation keyboard layouts
-        $res = $this->loadInstallationKeyboardLayouts();
-        if($res == NULL){
-            $this->initFailed = TRUE;
-            msg_dialog(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
-            return;
-        }
-        $this->installKeyboardlayoutList = $res;
+        // Prepare NTP servers list 
+        $this->installNTPServerList= new sortableListing($this->installNTPServer);
+        $this->installNTPServerList->setDeleteable(true);
+        $this->installNTPServerList->setEditable(false);
+        $this->installNTPServerList->setColspecs(array('*'));
+        $this->installNTPServerList->setWidth("100%");
+        $this->installNTPServerList->setHeight("70px");
 
+        // Preset values for new devices
+        if(!$this->is_account){
+            $this->installTemplate = key($this->installationTemplates);
+            $this->installRelease = key($this->templateToRelease[$this->installTemplate]);
+        }else{
 
-        // Load kernel package list
-        $res = $this->loadInstallationKernelPackages();
-        if($res == NULL){
-            $this->initFailed = TRUE;
-            msg_dialog(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
-            return;
-        }
-        $this->installKernelPackageList = $res;
+            if(!isset($this->installationTemplates[$this->installTemplate])){
 
+                // The selected template is no longer available, select the next selectable template.
+                $new = key($this->installationTemplates);
 
-        // Load installation mirrors
-        $res = $this->loadInstallationMirrors();
-        if($res == NULL){
-            $this->initFailed = TRUE;
-            msg_dialog(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
-            return;
-        }
-        $this->installMirrorDNList = $res;
+                if($initially){
+                    $message = sprintf(_("The selected template '%s' is no longer available. Selecting '%s' as replacement!"), 
+                            $this->installTemplate, $new);
+                    msg_dialog::display(_("Warning"), $message, WARNING_DIALOG);
+                }
+                $this->installTemplate = $new;
+                $installRelease = key($this->templateToRelease[$this->installTemplate]); 
 
+            }elseif(!isset($this->installationTemplates[$this->installTemplate]['method'])){
 
-        // Preset some values for new accounts
-        if(!$this->is_account){
+                // Not necessary to warn the user here, the input fields will be empty and thus
+                //  avoid saving.
 
-            // Preset the device timezone
-            $tz = timezone::get_default_timezone();
-            $this->installTimezone = $tz['name'];
+            }elseif(!in_array($this->installRelease, $this->templateToRelease[$this->installTemplate])){
 
-            // Set initial bootstrap and install method.
-            $this->installBootstrapMethod = key($this->installBootstrapMethodList);
-            $this->installConfigManagement = key($this->installConfigManagementList[$this->installBootstrapMethod]);
-        }
+                // The selected release is no longer available for the current template
+                // Warn the user and select the next selectable release.
+                $new = key($this->templateToRelease[$this->installTemplate]); 
+                if($initially){
+                    $message = sprintf(_("The selected release '%s' is no longer available. Selecting '%s' as replacement!"),
+                            $this->installRelease, $new);
+                }
+                $this->installRelease = $new;
+                msg_dialog::display(_("Warning"), $message, WARNING_DIALOG);
+            }
+        } 
 
+        // Update selectable items like kernels and mirrors depending on the current setup (relase)
+        $this->installBootstrapMethod = $this->installationTemplates[$this->installTemplate]['method'];
+        $this->reloadInstallationKernelPackages($initially);
+        $this->reloadInstallationMirrors($initially);
 
-        // Check if we've a valid bootstrap and configMangement method selected
-        if(!isset($this->installConfigManagementList[$this->installBootstrapMethod])){
-            $newMethod = key($this->installBootstrapMethodList);
-            msg_dialog::display(_("Error"), 
-                sprintf(_("The selected bootstrap method '%s' is invalid! Using '%s' instead!"),
-                $this->installBootstrapMethod,$newMethod), ERROR_DIALOG);
-            $this->installBootstrapMethod = $newMethod;
-        }
+        // Preset the config management method.
         if(!isset($this->installConfigManagementList[$this->installBootstrapMethod][$this->installConfigManagement])){
-            $newMethod = key($this->installConfigManagementList[$this->installBootstrapMethod]);
-            msg_dialog::display(_("Error"), 
-                sprintf(_("The selected config management method '%s' is invalid! Using '%s' instead!"),
-                $this->installConfigManagement,$newMethod), ERROR_DIALOG);
-            $this->installConfigManagement = $newMethod;
-        }
-    }
-
-
-    function getTimezones()
-    {
-        $tmp = timezone::_get_tz_zones();
-        $list = array();
-        foreach($tmp['TIMEZONES'] as $name => $offset){
-            if($offset >= 0){
-                $list[$name] = $name." ( + ".sprintf("%0.2f",$offset/(60*60))." "._("hours").")";
-            }else{
-                $offset = $offset * -1;
-                $list[$name] = $name." ( - ".sprintf("%0.2f",($offset/(60*60)))." "._("hours").")";
+            if(isset($this->installConfigManagementList[$this->installBootstrapMethod]) && 
+                count($this->installConfigManagementList[$this->installBootstrapMethod])){
+                $this->installConfigManagement = key($this->installConfigManagementList[$this->installBootstrapMethod]);
             }
-        }  
-        uksort($list, 'strnatcasecmp'); 
-        return($list);
-    }
-    
-    function loadInstallationKernelPackages()
-    {
-        return(array('kernel1','kk1'));
-    }
-    
-
-    function loadInstallationMirrors()
-    {
-        $res = array(
-                'dc=intranet,dc=gonicus,dc=de' => 'Intranet',
-                'ou=systems,dc=intranet,dc=gonicus,dc=de' => 'System');
-        return($res);
+        }
     }
 
-    function loadInstallationTemplates()
-    {
-        $res = array(
-                'dc=intranet,dc=gonicus,dc=de' => 'Intranet-Tpl',
-                'ou=systems,dc=intranet,dc=gonicus,dc=de' => 'System-Tpl');
-        return($res);
-    } 
-
-    function loadInstallationKeyboardLayouts()
-    {
-        return(array('104','105'));
-    } 
-
-    function getSystemLocales()
+   
+    /*! \brief   Loads client-information values from the GOsa-backend using jsonRPC 
+     */ 
+    function init_client_info()
     {
-        $locales = json_decode('{"hu_HU.UTF-8": "Hungarian", 
-                "es_DO.UTF-8": "Spanish (Dominican Republic)", 
-                "es_CL.UTF-8": "Spanish (Chile)"}');
-
-        return($locales);
-    }
+        if(empty($this->deviceUUID)){
+            return;
+        }
 
-    /*! \brief  Try to load install and bootstrap methods from the GOsa-backend
-     *          This is done via jsonRPC, if calling the backend method fails,
-     *           this method returns FALSE, in case of success it return TRUE; 
-     */ 
-    function loadInstallationMethods()
-    { 
         $rpc = $this->config->getRpcHandle();
-        $res = $rpc->getSupportedBaseInstallMethods();
+        $res = $rpc->systemGetBaseInstallParameters($this->deviceUUID);
        
         // Failed to load backend values, keep reported error and return with FALSE; 
         $this->rpcError = !$rpc->success();
         if(!$rpc->success()){
             $this->rpcErrorMessage = $rpc->get_error();
+            msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
             return(NULL);
         }
+   
+        // Apply received options
+        $this->is_account = $res == True;
+        if($this->is_account){
+
+            $map = array(
+                    'ntp-servers' => "installNTPServer", 
+                    'template' => "installTemplate", 
+                    'keyboard-layout' => "installKeyboardlayout");
+
+            // We receive an array for these attributes, but require a string instead
+            //  we just use the first element of the array.
+            $mapArray = array(
+                    'release' => "installRelease", 
+                    'timezone' => "installTimezone", 
+                    'utc' => "installTimeUTC", 
+                    'kernel' => "installKernelPackage", 
+                    'system-locale' => "installSystemLocale", 
+                    'root-user' => "installRootEnabled", 
+                    'root-hash' => "installRootPasswordHash", 
+                    'disk-setup' => "installPartitionTable");
+            foreach($res as $name => $data){
+                if(isset($map[$name])){
+                    $target = $map[$name];
+                    $value = $res[$name];
+                }elseif(isset($mapArray[$name])){
+                    $target = $mapArray[$name];
+                    $value = $res[$name][0];
+                }
+                $this->$target = $value;
+            }
 
-        // Walk through result and set bootstrap methods.
-        foreach($res as $name => $method){
-            $res['installBootstrapMethodList'][$name] = $method['name'];
-            foreach($method['methods'] as $m){
-                $res['installConfigManagementList'][$name][$m] = $m; 
+            // Convert Bool values to Bool.
+            $boolean = array("installRootEnabled", "installTimeUTC");
+            foreach($boolean as $attr){
+                $this->$attr = ($this->$attr != FALSE && !preg_match("/false/i", $this->$attr));
             }
         }
-        return($res);
+
+        return;
     }
-    
 
+
+    function init_static_info()
+    { 
+        // Load static values.
+        foreach(array(
+                "timeozones" => "getTimezones",
+                "distributions" => "loadDistributions",
+                "keyboardLayouts" => "loadInstallationKeyboardLayouts",
+                "installationTemplates" => "loadInstallationTemplates",
+                "installationMethods" => "loadInstallationMethods",
+                "locales" => "getSystemLocales"    ) as $target => $func){
+            $$target = $this->$func();
+            if($$target == NULL){
+                $this->initFailed = TRUE;
+                msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
+                return;
+            }
+        }
+
+        // Assign fetchted values
+        $this->timezones = $timeozones;
+        $this->installBootstrapMethodList = $installationMethods['installBootstrapMethodList'];
+        $this->installConfigManagementList = $installationMethods['installConfigManagementList'];
+        $this->installSystemLocaleList = $locales;
+        $this->installKeyboardlayoutList = $keyboardLayouts;
+        $this->distributions = $distributions;
+
+        # Create template to relase map
+        $this->templateToRelease = array();
+
+        // Walk through installation templates and use the 'repositories' attribute
+        // to supported releases.
+        foreach($installationTemplates as $name => $tdata){
+            
+            $mName = isset($this->installBootstrapMethodList[$tdata['method']]) ? 
+                $this->installBootstrapMethodList[$tdata['method']]: $tdata['method'];
+
+            $this->installationTemplateNames[$name] = $tdata['description']." (".$mName.")";
+            $this->installationTemplates[$name] = $tdata;
+            $this->templateToRelease[$name] = array();
+
+            // Check if the 'repository'-category of the template can be found in any 
+            // received release list.
+            if(isset($installationMethods[$tdata['method']]['repositories'])){
+                $repos = $installationMethods[$tdata['method']]['repositories'];
+                foreach($distributions as $dist){
+                    if(in_array($dist['type']['name'],$repos) && isset($dist['releases'])){
+                        foreach($dist['releases'] as $release){
+                            $rname = $dist['name'].'/'.$release['name'];
+                            $this->templateToRelease[$name][$rname] = $rname;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    function check()
+    {
+            // Check if the parents deviceUUID has changed
+            if($this->deviceUUID != $this->_device->deviceUUID){
+                $this->deviceUUID = $this->_device->deviceUUID;
+                print "The device uuid has changed.";
+            }
+    }
+    
+    
     function execute()
     {
         // Log account access
@@ -309,11 +317,11 @@ class InstallRecipe extends plugin
         $display = "";
         if ($this->parent !== NULL){
             if ($this->is_account){
-                $display= $this->show_disable_header(_("Remove instal profile"),
-                        msgPool::featuresEnabled(_("Install profile")));
+                $display= $this->show_disable_header(_("Remove base installation"),
+                        msgPool::featuresEnabled(_("Base installation")));
             } else {
-                $display= $this->show_enable_header(_("Add install profile"),
-                        msgPool::featuresDisabled(_("Install profile")));
+                $display= $this->show_enable_header(_("Add base installation"),
+                        msgPool::featuresDisabled(_("Base installation")));
                 return ($display);
             }
         }
@@ -322,7 +330,8 @@ class InstallRecipe extends plugin
           Root password hash dialog
          ***************/
 
-        if($this->setKickstartRootPasswordHash){
+        $this->dialog = FALSE;
+        if($this->setPasswordHash){
             $this->dialog = TRUE;
             $smarty = get_smarty();
             $smarty->assign('hashes', set_post($this->hashes));
@@ -330,6 +339,28 @@ class InstallRecipe extends plugin
             return($smarty->fetch(get_template_path('goto/Device/SetPassword.tpl', TRUE)));
         }
 
+        /***************
+          Partition dialog
+         ***************/
+
+        if(isset($_POST['partition_finish']) && $this->partitionEdit){
+            $this->installPartitionTable = $this->partitionEdit->save();
+            $this->partitionEdit = NULL;
+        }
+        if(isset($_POST['partition_cancel']) && $this->partitionEdit){
+            $this->partitionEdit = NULL;
+        }
+        if(isset($_POST['edit_installPartitionTable'])){
+            $this->partitionEdit = new DevicePartition($this->config, $this->installPartitionTable);
+        }
+        if($this->partitionEdit){
+            $this->partitionEdit->save_object();
+            $this->dialog = TRUE;
+            return($this->partitionEdit->execute());
+        }
+
+
+
         /***************
           Generate HTML content
          ***************/
@@ -339,11 +370,18 @@ class InstallRecipe extends plugin
 
         plugin::execute();    
         $smarty = get_smarty();
+
+        // Assign ACLs
+        foreach($this->attributes as $attr){
+            $smarty->assign("{$attr}ACL", $this->getacl($attr));
+        }
+
+        $smarty->assign('installTemplateList', $this->installationTemplateNames);
+        $smarty->assign('installReleaseList', $this->templateToRelease[$this->installTemplate]);
         $smarty->assign('timezones', $this->timezones);
         $smarty->assign('installKeyboardlayoutList', $this->installKeyboardlayoutList);
         $smarty->assign('installKernelPackageList', $this->installKernelPackageList);
-        $smarty->assign('installTemplateDNList', $this->installTemplateDNList);
-        $smarty->assign('installMirrorDNList', $this->installMirrorDNList);
+        $smarty->assign('installMirrorList', $this->installMirrorList);
         $smarty->assign('installSystemLocaleList', $this->installSystemLocaleList);
         $smarty->assign('installNTPServerList', $this->installNTPServerList->render());
 
@@ -351,8 +389,13 @@ class InstallRecipe extends plugin
         $smarty->assign('installBootstrapMethodList', $this->installBootstrapMethodList);
         $smarty->assign('installConfigManagement', $this->installConfigManagement);
 
-        $cfgList = $this->installConfigManagementList[$this->installBootstrapMethod];
-        $smarty->assign('installConfigManagementList', $cfgList);
+        // Assign list of available config-management types.
+        if(isset($this->installConfigManagementList[$this->installBootstrapMethod])){ 
+            $smarty->assign('installConfigManagementList', $this->installConfigManagementList[$this->installBootstrapMethod]);
+        }else{
+            $smarty->assign('installConfigManagementList', array());
+        }
+
         foreach($this->attributes as $attr){
             $smarty->assign($attr, $this->$attr);
         }
@@ -366,13 +409,15 @@ class InstallRecipe extends plugin
         if(isset($_POST['InstallRecipePosted'])){
 
             $currentInstallMethod = $this->installConfigManagement;
+
+            $oldRelease = $this->installRelease;
             plugin::save_object();
             $this->installRootEnabled = isset($_POST['installRootEnabled']);
             $this->installTimeUTC = isset($_POST['installTimeUTC']);
 
 
-            if(isset($_POST['setKickstartRootPasswordHash'])){
-                $this->setKickstartRootPasswordHash = true;
+            if(isset($_POST['setPasswordHash'])){
+                $this->setPasswordHash = true;
             }
 
             $this->installNTPServerList->save_object();
@@ -384,10 +429,23 @@ class InstallRecipe extends plugin
                 }
             }
             $this->installNTPServerList->setListData($this->installNTPServer);
+            $this->installBootstrapMethod = $this->installationTemplates[$this->installTemplate]['method'];
+
+            // The selected release is no longer available for the current template
+            if(!in_array($this->installRelease, $this->templateToRelease[$this->installTemplate])){
+                $this->installRelease = key($this->templateToRelease[$this->installTemplate]);
+            }
+
+            // Reload list of kernel packages and mirrors
+            if($oldRelease != $this->installRelease){
+                $this->reloadInstallationKernelPackages();
+                $this->reloadInstallationMirrors();
+            }
         }
-        if(isset($_POST['cancelPassword'])) $this->setKickstartRootPasswordHash =false;
+
+        if(isset($_POST['cancelPassword'])) $this->setPasswordHash =false;
         if(isset($_POST['setPassword'])) {
-            $this->setKickstartRootPasswordHash =false;
+            $this->setPasswordHash =false;
             $hash = get_post('passwordHash');
 
             // Not sure, why this is here, but maybe some encryption methods require it.
@@ -399,64 +457,234 @@ class InstallRecipe extends plugin
             $test = new $available[$hash]($this->config,$this->dn);
             $this->installRootPasswordHash = @$test->generate_hash(get_post('rootPassword'));
         }
-
     }
 
 
     function save()
     {
-        // 
         if(!$this->installRootEnabled) $this->installRootPasswordHash = "";
-        $this->installRootEnabled = ($this->installRootEnabled)?'TRUE':'FALSE';
-        $this->installTimeUTC = ($this->installTimeUTC)?'TRUE':'FALSE';
-        
-        plugin::save();
-
-        unset($this->attrs['installConfigManagement']);
-        unset($this->attrs['installBootstrapMethod']);
-        echo "Skipp saving of 'installConfigManagement' and 'installBootstrapMethod', i've no idea where to store them.";
-
-        // Remove all objectClasses which belongs to a bootstrap method, 
-        //  and then add the selected one.
-        foreach($this->map as $type){
-            $this->attrs['objectClass'] = array_remove_entries_ics(array($type['objectClass']), $this->attrs['objectClass']);
-        }
-        $this->attrs['objectClass'][] = $this->map[$this->installConfigManagement]['objectClass'];
-        
-        print_a($this->attrs);
-
-        $this->cleanup();
-        $ldap=$this->config->get_ldap_link();
-        $ldap->cd($this->config->current['BASE']);
-        $ldap->cd($this->dn);
-        $ldap->modify($this->attrs);
-        new log("modify","Device/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-        if (!$ldap->success()){
-            msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
-        }else{
-            $this->handle_post_events("modify");
+
+        $map = array(
+            "installNTPServer"=>'ntp-servers',
+            "installTemplate"=>'template',
+            "installRelease"=>'release',
+            "installTimezone"=>'timezone',
+            "installTimeUTC"=>'utc',
+            "installKernelPackage"=>'kernel',
+            "installSystemLocale"=>'system-locale',
+            "installRootEnabled"=>'root-user',
+            "installRootPasswordHash"=>'root-hash',
+            "installPartitionTable"=>'disk-setup',
+            "installKeyboardlayout"=>'keyboard-layout',
+            );
+
+        // Collect values to be saved.
+        $data = array();
+        foreach($map as $source => $dest){
+            if(!empty($this->$source)){
+                $data[$dest] = $this->$source;
+             }
+        } 
+
+        // Enforce an array for ntp-servers
+        $data['ntp-servers'] = array_values($data['ntp-servers']);
+
+        // Save Boolean like a String 
+        $boolean = array("root-user" => "installRootEnabled", "utc" => "installTimeUTC");
+        foreach($boolean as $attr => $source){
+            $data[$attr] = ($this->$source) ? $data[$attr] = "TRUE" : $data[$attr] = "FALSE";
+        }
+
+        $rpc = $this->config->getRpcHandle();
+        $res = $rpc->systemSetBaseInstallParameters($this->deviceUUID, $data);
+       
+        // Failed to load backend values, keep reported error and return with FALSE; 
+        $this->rpcError = !$rpc->success();
+        if(!$rpc->success()){
+            $this->rpcErrorMessage = $rpc->get_error();
+            msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
+            return(NULL);
         }
+
     }
 
     
     function remove_from_parent()
     {
-        plugin::remove_from_parent();
-        unset($this->attrs['installConfigManagement']);
-        unset($this->attrs['installBootstrapMethod']);
-        echo "Skipp saving of 'installConfigManagement' and 'installBootstrapMethod', i've no idea where to store them.";
-
-        $ldap=$this->config->get_ldap_link();
-        $ldap->cd($this->config->current['BASE']);
-        $ldap->cd($this->dn);
-        $ldap->modify($this->attrs);
-        new log("remove","Device/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-        if (!$ldap->success()){
-            msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+       print "Missing"; 
+    }
+    
+    /*! \brief  Refreshes the list of selectable kernel packages.
+     */
+    function reloadInstallationKernelPackages($initially = FALSE)
+    {
+        // Do nothing if no release is given.
+        if(empty($this->installRelease)){
+            $this->installKernelPackageList = array();
+            return;
+        }
+
+        $release = preg_replace("/^[^\/]*\//","", $this->installRelease);
+        $rpc = $this->config->getRpcHandle();
+        $res = $rpc->getKernelPackages($release);
+     
+        // Failed to load backend values, keep reported error and return with FALSE; 
+        $this->rpcError = !$rpc->success();
+        if(!$rpc->success()){
+            $this->rpcErrorMessage = $rpc->get_error();
+            msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
         }else{
-            $this->handle_post_events("remove");
+            $this->installKernelPackageList = array();
+            foreach($res as $data){
+                $name = $data['name'];
+                $this->installKernelPackageList[$name] = $name;
+            }
+
+            if(!isset($this->installKernelPackageList[$this->installKernelPackage])){
+                $new = key($this->installKernelPackageList);
+                if($initially){
+                    msg_dialog::display(_("Warning"), sprintf(_("The selected kernel package '%s' is no longer available! The kernel package '%s' was selected as replacement!"), $this->installKernelPackage, $new), WARNING_DIALOG);
+                }
+                $this->installKernelPackage = $new;
+            }
+        }
+    }
+
+
+    /*! \brief  Returns a list of distributions on success.
+     *          In case of an error, it returns NULL.
+     */
+    function loadDistributions()
+    {
+        $rpc = $this->config->getRpcHandle();
+        $res = $rpc->getDistributions();
+       
+        // Failed to load backend values, keep reported error and return with FALSE; 
+        $this->rpcError = !$rpc->success();
+        if(!$rpc->success()){
+            $this->rpcErrorMessage = $rpc->get_error();
+            return(NULL);
         }
-        
+        return($res);
+    }
+
+
+    /*! \brief  Returns a list of timezones on success.
+     *          In case of an error, it returns NULL.
+     */
+    function getTimezones()
+    {
+        $rpc = $this->config->getRpcHandle();
+        $res = $rpc->getTimezones();
+       
+        // Failed to load backend values, keep reported error and return with FALSE; 
+        $this->rpcError = !$rpc->success();
+        if(!$rpc->success()){
+            $this->rpcErrorMessage = $rpc->get_error();
+            return(NULL);
+        }
+        return($res);
+    }
+    
+
+    /*! \brief  Returns a list of installation mirrors on success.
+     *          In case of an error, it returns NULL.
+     */
+    function reloadInstallationMirrors($initially = FALSE)
+    {
+        $res = array(
+                'dc=intranet,dc=gonicus,dc=de' => 'Intranet',
+                'ou=systems,dc=intranet,dc=gonicus,dc=de' => 'System');
+        $this->installMirrorList =$res;
+    }
+
+
+    /*! \brief  Returns a list of installation templates on success.
+     *          In case of an error, it returns NULL.
+     */
+    function loadInstallationTemplates()
+    {
+        $rpc = $this->config->getRpcHandle();
+        $res = $rpc->installListTemplates();
+       
+        // Failed to load backend values, keep reported error and return with FALSE; 
+        $this->rpcError = !$rpc->success();
+        if(!$rpc->success()){
+            $this->rpcErrorMessage = $rpc->get_error();
+            return(NULL);
+        }
+        return($res);
+    } 
+
+
+    /*! \brief  Returns a list of keyboard layouts on success.
+     *          In case of an error, it returns NULL.
+     */
+    function loadInstallationKeyboardLayouts()
+    {
+        $rpc = $this->config->getRpcHandle();
+        $res = $rpc->getKeyboardModels();
+       
+        // Failed to load backend values, keep reported error and return with FALSE; 
+        $this->rpcError = !$rpc->success();
+        if(!$rpc->success()){
+            $this->rpcErrorMessage = $rpc->get_error();
+            return(NULL);
+        }
+        $lay = array();
+        foreach($res as $key => $data){
+            $lay[$key] = "{$data[0]} - {$data[2]}";
+        }
+        asort($lay);
+        return($lay);
+    } 
+
+    
+    /*! \brief  Returns a list of system locales on success.
+     *          In case of an error, it returns NULL.
+     */
+    function getSystemLocales()
+    {
+        $rpc = $this->config->getRpcHandle();
+        $res = $rpc->getSystemLocales();
+      
+        // Failed to load backend values, keep reported error and return with FALSE; 
+        $this->rpcError = !$rpc->success();
+        if(!$rpc->success()){
+            $this->rpcErrorMessage = $rpc->get_error();
+            msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
+            return(NULL);
+        }
+
+        return($res);
+    }
+
+    /*! \brief  Try to load install and bootstrap methods from the GOsa-backend
+     *          This is done via jsonRPC, if calling the backend method fails,
+     *           this method returns FALSE, in case of success it return TRUE; 
+     */ 
+    function loadInstallationMethods()
+    { 
+        $rpc = $this->config->getRpcHandle();
+        $res = $rpc->getSupportedBaseInstallMethods();
+      
+        // Failed to load backend values, keep reported error and return with FALSE; 
+        $this->rpcError = !$rpc->success();
+        if(!$rpc->success()){
+            $this->rpcErrorMessage = $rpc->get_error();
+            return(NULL);
+        }
+
+        // Walk through result and set bootstrap methods.
+        foreach($res as $name => $method){
+            $res['installBootstrapMethodList'][$name] = $method['name'];
+            foreach($method['methods'] as $m){
+                $res['installConfigManagementList'][$name][$m] = $m; 
+            }
+        }
+        return($res);
     }
     
 
@@ -471,24 +699,24 @@ class InstallRecipe extends plugin
                     "plSection"     => array("administration"),
                     "plCategory"    => array("Device"),
                     "plProvidedAcls" => array(
-                        "member" => _("Member"),
-                        "installTemplateDN" => _("Template"),
-                        "installBootstrapMethod" => _("Bootstrap method"),
-                        "installConfigManagement" => _("Config management"),
+
+                        "installRelease" => _("Release"),
+                        "installTemplate" => _("Template"),
                         "installKeyboardlayout" => _("Keyboard layout"),
-                        "installSystemLocale" => _("System locale"),
+                        "installSystemLocale" => _("Locale"),
                         "installTimezone" => _("Timezone"),
-                        "installTimeUTC" => _("Time"),
-                        "installNTPServer" => _("NTP-Server"),
-                        "installMirrorDN" => _("Kickstart mirror"),
+                        "installTimeUTC" => _("Utc"),
+                        "installNTPServer" => _("Ntp server"),
+                        "installMirror" => _("Mirror"),
                         "installRootEnabled" => _("Root login enabled"),
                         "installRootPasswordHash" => _("Root password hash"),
-                        "installKernelPackage" => _("Kernal package"),
+                        "installKernelPackage" => _("Kernel package"),
+                        "installConfigManagement" => _("Config mangement"),
+                        "installBootstrapMethod" => _("Bootstrap method"),
                         "installPartitionTable" => _("Partition table")
                         )
                         )
                         );
     }
 }
-
 ?>