diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_InstallRecipe.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_InstallRecipe.inc
index 3718329c3fa3bd9b28fd0d4153b8a80161e54fef..c3908a4054b6a7e992bd51c7ebdc854fa0e0dd19 100644 (file)
class InstallRecipe extends plugin
{
- public $kickstartBootstrapMethod = '';
- public $kickstartBootstrapMethodList = NULL;
-
- public $kickstartConfigManagement = '';
- public $kickstartConfigManagementList = NULL;
-
- public $kickstartTemplateDN = "";
- public $kickstartTemplateDNList = array(
- 'dc=intranet,dc=gonicus,dc=de' => 'Intranet-Tpl',
- 'ou=systems,dc=intranet,dc=gonicus,dc=de' => 'System-Tpl');
-
- public $kickstartMirrorDN = "";
- public $kickstartMirrorDNList = array(
- 'dc=intranet,dc=gonicus,dc=de' => 'Intranet',
- 'ou=systems,dc=intranet,dc=gonicus,dc=de' => 'System');
- public $kickstartKernelPackage = "";
- public $kickstartKernelPackageList = array('kernel1','kk1');
- public $kickstartKeyboardlayout = "";
- public $kickstartKeyboardlayoutList = array("104","105");
- public $kickstartSystemLocale = "";
- public $kickstartSystemLocaleList = array('de','en_EN.UTF-8');
- public $kickstartTimezone = "";
- public $kickstartTimeUTC = "";
- public $kickstartNTPServer = array();
- public $kickstartRootEnabled = "";
- public $kickstartRootPasswordHash = "";
- public $kickstartPartitionTable = "";
-
- public $objectclasses = array('installRecipe');
- public $attributes = array("kickstartTemplateDN","kickstartKeyboardlayout","kickstartSystemLocale",
- "kickstartTimezone","kickstartTimeUTC","kickstartNTPServer","kickstartMirrorDN",
- "kickstartRootEnabled","kickstartRootPasswordHash","kickstartKernelPackage",
- "kickstartPartitionTable","kickstartConfigManagement","kickstartBootstrapMethod");
-
- public $setKickstartRootPasswordHash = FALSE;
-
- private $kickstartNTPServerList = NULL;
-
- function __construct(&$config, $dn)
+ 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 = array();
+
+ // Bootstrap method
+ public $installBootstrapMethod = '';
+ public $installBootstrapMethodList = array();
+
+ // Timezone settings
+ public $installTimezone = "";
+ public $installTimeUTC = "";
+
+ // Kernel packages
+ public $installKernelPackage = "";
+ public $installKernelPackageList = array();
+
+ // System Locale
+ public $installSystemLocale = "";
+ public $installSystemLocaleList = array();
+
+ // Selected NTP Server
+ public $installNTPServer = array();
+ public $installNTPServerList = NULL;
+
+ // Root password
+ public $installRootEnabled = "";
+ public $installRootPasswordHash = "";
+ public $setPasswordHash = FALSE;
+
+ // Partition table variables
+ public $installPartitionTable = "";
+ private $partitionEdit = NULL;
+
+ // Keyboard-layout attribute
+ public $installKeyboardlayout = "";
+ public $installKeyboardlayoutList = array();
+
+ // Mirror related attribute
+ public $installMirror = "";
+ public $installMirrorList = array();
+
+ public $objectclasses = array();
+ public $attributes = array("installRelease", "installTemplate","installKeyboardlayout","installSystemLocale",
+ "installTimezone","installTimeUTC","installNTPServer","installMirror",
+ "installRootEnabled","installRootPasswordHash","installKernelPackage",
+ "installPartitionTable","installConfigManagement","installBootstrapMethod");
+
+
+ /* 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, $parent)
{
plugin::plugin($config, $dn);
- // Preset some values for new accounts
- if(!$this->is_account){
+ $this->is_account = $this->initially_was_account = FALSE;
- // Preset the device timezone
- $tz = timezone::get_default_timezone();
- $this->kickstartTimezone = $tz['name'];
- }
+ $this->_device = &$parent;
+ $this->deviceUUID = $parent->deviceUUID;
- // Prepare list of timezones
- $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").")";
- }
- }
- uksort($list, 'strnatcasecmp');
- $this->timezones = $list;
+ // Set default password hash
+ $this->hash = $this->config->get_cfg_value("core","passwordDefaultHash");
// Get list of password hashes
$tmp = passwordMethod::get_available_methods();
foreach($tmp['name'] as $name){
$this->hashes[$name] = $name;
}
- $this->hash = $this->config->get_cfg_value("core","passwordDefaultHash");
- // Get list of NTP servers
- $this->kickstartNTPServer = array();
- if(isset($this->attrs['kickstartNTPServer']['count'])){
- for($i = 0; $i < $this->attrs['kickstartNTPServer']['count']; $i++){
- $this->kickstartNTPServer[] = $this->attrs['kickstartNTPServer'][$i];
- }
- }
+ // Initialize plugin
+ $this->init_static_info();
+ $this->init($initially = TRUE);
+ }
+
+ function init($initially = FALSE)
+ {
+ // Init the object values.
+ $this->init_client_info();
// Prepare NTP servers list
- $this->kickstartNTPServerList= new sortableListing($this->kickstartNTPServer);
- $this->kickstartNTPServerList->setDeleteable(true);
- $this->kickstartNTPServerList->setEditable(false);
- $this->kickstartNTPServerList->setColspecs(array('*'));
- $this->kickstartNTPServerList->setWidth("100%");
- $this->kickstartNTPServerList->setHeight("70px");
-
- // Load list of bootstrap methods.
- $this->loadInstallationMethods();
+ $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{
+
+ if(!isset($this->installationTemplates[$this->installTemplate])){
+
+ // The selected template is no longer available, select the next selectable template.
+ $new = key($this->installationTemplates);
+
+ 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'])){
+
+ // Not necessary to warn the user here, the input fields will be empty and thus
+ // avoid saving.
+
+ }elseif(!in_array($this->installRelease, $this->templateToRelease[$this->installTemplate])){
+
+ // 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);
+
+ // Preset the config management method.
+ if(!isset($this->installConfigManagementList[$this->installBootstrapMethod][$this->installConfigManagement])){
+ if(isset($this->installConfigManagementList[$this->installBootstrapMethod]) &&
+ count($this->installConfigManagementList[$this->installBootstrapMethod])){
+ $this->installConfigManagement = key($this->installConfigManagementList[$this->installBootstrapMethod]);
+ }
+ }
}
-
- function loadInstallationMethods()
- {
- $this->kickstartBootstrapMethodList = array();
- $this->kickstartConfigManagementList = array();
+
+ /*! \brief Loads client-information values from the GOsa-backend using jsonRPC
+ */
+ function init_client_info()
+ {
+ if(empty($this->deviceUUID)){
+ return;
+ }
+
$rpc = $this->config->getRpcHandle();
- $res = $rpc->getSupportedBaseInstallMethods();
- foreach($res as $name => $method){
- $this->kickstartBootstrapMethodList[$name] = $method['name'];
- foreach($method['methods'] as $m){
- $this->kickstartConfigManagementList[$name][$m] = $m;
+ $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;
+ }
+
+ // Convert Bool values to Bool.
+ $boolean = array("installRootEnabled", "installTimeUTC");
+ foreach($boolean as $attr){
+ $this->$attr = ($this->$attr != FALSE && !preg_match("/false/i", $this->$attr));
}
}
-
- if(empty($this->kickstartBootstrapMethod)){
- $this->kickstartBootstrapMethod = key($this->kickstartBootstrapMethodList);
+
+ 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;
+ }
}
- if(empty($this->kickstartConfigManagement)){
- $this->kickstartConfigManagement = key($this->kickstartConfigManagementList[$this->kickstartBootstrapMethod]);
+
+ // 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()
{
- if($this->setKickstartRootPasswordHash){
+ // Log account access
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","Device/".get_class($this),$this->dn);
+ }
+
+ /***************
+ Handle account state
+ ***************/
+
+ // Allow to add or remove the distribution list extension
+ if(isset($_POST['modify_state'])){
+ if($this->is_account && $this->acl_is_removeable()){
+ $this->is_account= FALSE;
+ }elseif(!$this->is_account && $this->acl_is_createable()){
+ $this->is_account= TRUE;
+ }
+ }
+
+ // Show account status-changer
+ $display = "";
+ if ($this->parent !== NULL){
+ if ($this->is_account){
+ $display= $this->show_disable_header(_("Remove base installation"),
+ msgPool::featuresEnabled(_("Base installation")));
+ } else {
+ $display= $this->show_enable_header(_("Add base installation"),
+ msgPool::featuresDisabled(_("Base installation")));
+ return ($display);
+ }
+ }
+
+ /***************
+ Root password hash dialog
+ ***************/
+
+ $this->dialog = FALSE;
+ if($this->setPasswordHash){
$this->dialog = TRUE;
$smarty = get_smarty();
$smarty->assign('hashes', set_post($this->hashes));
return($smarty->fetch(get_template_path('goto/Device/SetPassword.tpl', TRUE)));
}
- $this->kickstartNTPServerList->setAcl($this->getacl('kickstartNTPServer'));
- $this->kickstartNTPServerList->update();
+ /***************
+ 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
+ ***************/
+
+ $this->installNTPServerList->setAcl($this->getacl('installNTPServer'));
+ $this->installNTPServerList->update();
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('kickstartKeyboardlayoutList', $this->kickstartKeyboardlayoutList);
- $smarty->assign('kickstartKernelPackageList', $this->kickstartKernelPackageList);
- $smarty->assign('kickstartTemplateDNList', $this->kickstartTemplateDNList);
- $smarty->assign('kickstartMirrorDNList', $this->kickstartMirrorDNList);
- $smarty->assign('kickstartSystemLocaleList', $this->kickstartSystemLocaleList);
- $smarty->assign('kickstartNTPServerList', $this->kickstartNTPServerList->render());
-
- $smarty->assign('kickstartBootstrapMethod', $this->kickstartBootstrapMethod);
- $smarty->assign('kickstartBootstrapMethodList', $this->kickstartBootstrapMethodList);
- $smarty->assign('kickstartConfigManagement', $this->kickstartConfigManagement);
-
- $cfgList = $this->kickstartConfigManagementList[$this->kickstartBootstrapMethod];
- $smarty->assign('kickstartConfigManagementList', $cfgList);
+ $smarty->assign('installKeyboardlayoutList', $this->installKeyboardlayoutList);
+ $smarty->assign('installKernelPackageList', $this->installKernelPackageList);
+ $smarty->assign('installMirrorList', $this->installMirrorList);
+ $smarty->assign('installSystemLocaleList', $this->installSystemLocaleList);
+ $smarty->assign('installNTPServerList', $this->installNTPServerList->render());
+
+ $smarty->assign('installBootstrapMethod', $this->installBootstrapMethod);
+ $smarty->assign('installBootstrapMethodList', $this->installBootstrapMethodList);
+ $smarty->assign('installConfigManagement', $this->installConfigManagement);
+
+ // 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);
}
$this->dialog = false;
- return($smarty->fetch(get_template_path('goto/Device/InstallRecipe.tpl', TRUE)));
+ return($display.$smarty->fetch(get_template_path('goto/Device/InstallRecipe.tpl', TRUE)));
}
function save_object()
{
-
-
if(isset($_POST['InstallRecipePosted'])){
- $currentInstallMethod = $this->kickstartConfigManagement;
+ $currentInstallMethod = $this->installConfigManagement;
+
+ $oldRelease = $this->installRelease;
plugin::save_object();
- $this->kickstartRootEnabled = isset($_POST['kickstartRootEnabled']);
- $this->kickstartTimeUTC = isset($_POST['kickstartTimeUTC']);
+ $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->kickstartNTPServerList->save_object();
- $this->kickstartNTPServer = $this->kickstartNTPServerList->getMaintainedData();
- if(isset($_POST['kickstartNTPServer_Input']) && isset($_POST['kickstartNTPServer_Add'])){
- $add = get_post('kickstartNTPServer_Input');
- if(!in_array($add, $this->kickstartNTPServer) && !empty($add)){
- $this->kickstartNTPServer[] = $add;
+ $this->installNTPServerList->save_object();
+ $this->installNTPServer = $this->installNTPServerList->getMaintainedData();
+ if(isset($_POST['installNTPServer_Input']) && isset($_POST['installNTPServer_Add'])){
+ $add = get_post('installNTPServer_Input');
+ if(!in_array($add, $this->installNTPServer) && !empty($add)){
+ $this->installNTPServer[] = $add;
}
}
- $this->kickstartNTPServerList->setListData($this->kickstartNTPServer);
+ $this->installNTPServerList->setListData($this->installNTPServer);
+ $this->installBootstrapMethod = $this->installationTemplates[$this->installTemplate]['method'];
- if($currentInstallMethod != $this->kickstartConfigManagement){
- $this->updateRecipeTab();
+ // 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.
$methods = new passwordMethod($this->config, $this->dn);
$available = $methods->get_available_methods();
$test = new $available[$hash]($this->config,$this->dn);
- $this->kickstartRootPasswordHash = @$test->generate_hash(get_post('rootPassword'));
+ $this->installRootPasswordHash = @$test->generate_hash(get_post('rootPassword'));
}
-
}
- function updateRecipeTab()
+ function save()
{
- $mode = $this->kickstartConfigManagement;
- if(!isset($this->recipeTabs[$mode])){
- $this->recipeTabs[$mode] = new DeviceConfig($this->config, $this->dn);
- $this->recipeTabs[$mode]->parent = &$this->parent;
-
- if($this->recipeTabs[$mode]->setInstallMethod($mode)){
-
- $class= &$this->recipeTabs[$mode];
-
- // Add some dummy entries for testing.
- if($mode == 'puppet'){
- $id = $class->addItem('PuppetModule','test1',
- array(
- 'dependency' => array('stulle','Wurst'),
- 'version' => '2.4-f',
- 'name' => 'Thundebird',
- 'description' => 'Mozilla mail client')
- );
- $id = $class->addItem('PuppetModule','test2',
- array(
- 'dependency' => array('Leipnitz','Dose'),
- 'version' => 1,
- 'name' => 'Firefox',
- 'description' => 'Test Module')
- );
- $class->setCurrentItem($id);
- $id = $class->addItem('PuppetTemplate','temp1',
- array(
- 'name' => 'temp1',
- 'data' => 'kekse.tpl')
- );
- $class->setCurrentItem($id);
- $id = $class->addItem('PuppetTemplate','tep1',
- array(
- 'name' => 'tep1',
- 'data' => 'kekse.tpl')
- );
-
- $class->setCurrentItem($class->getRootItemID());
- }
- }else{
- unset($this->recipeTabs[$mode]);
- }
+ if(!$this->installRootEnabled) $this->installRootPasswordHash = "";
+
+ $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";
}
- // Update the recipe tab to match the selected installation method.
- if($this->is_account && isset($this->recipeTabs[$mode])){
+ $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);
+ }
- if(isset($this->parent->by_object['DeviceConfig']) &&
- $this->recipeTabs[$mode] === $this->parent->by_object['DeviceConfig']){
- return;
- }
+ }
- $this->parent->by_name['DeviceConfig'] = $mode ;
- $this->parent->by_object['DeviceConfig'] = &$this->recipeTabs[$mode];
+
+ function remove_from_parent()
+ {
+ 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{
- if(isset($this->parent->by_name['DeviceConfig'])){
- unset($this->parent->by_name['DeviceConfig']);
- unset($this->parent->by_object['DeviceConfig']);
+ $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;
}
}
}
- function save()
+ /*! \brief Returns a list of distributions on success.
+ * In case of an error, it returns NULL.
+ */
+ function loadDistributions()
{
- //
- if(!$this->kickstartRootEnabled) $this->kickstartRootPasswordHash = "";
- $this->kickstartRootEnabled = ($this->kickstartRootEnabled)?'TRUE':'FALSE';
- $this->kickstartTimeUTC = ($this->kickstartTimeUTC)?'TRUE':'FALSE';
-
-
- plugin::save();
-
- $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");
+ $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);
+ }
+
static function plInfo()
{
"plSection" => array("administration"),
"plCategory" => array("Device"),
"plProvidedAcls" => array(
- "member" => _("Member"),
- "kickstartTemplateDN" => _("Template"),
- "kickstartBootstrapMethod" => _("Bootstrap method"),
- "kickstartConfigManagement" => _("Config management"),
- "kickstartKeyboardlayout" => _("Keyboard layout"),
- "kickstartSystemLocale" => _("System locale"),
- "kickstartTimezone" => _("Timezone"),
- "kickstartTimeUTC" => _("Time"),
- "kickstartNTPServer" => _("NTP-Server"),
- "kickstartMirrorDN" => _("Kickstart mirror"),
- "kickstartRootEnabled" => _("Root login enabled"),
- "kickstartRootPasswordHash" => _("Root password hash"),
- "kickstartKernelPackage" => _("Kernal package"),
- "kickstartPartitionTable" => _("Partition table")
+
+ "installRelease" => _("Release"),
+ "installTemplate" => _("Template"),
+ "installKeyboardlayout" => _("Keyboard layout"),
+ "installSystemLocale" => _("Locale"),
+ "installTimezone" => _("Timezone"),
+ "installTimeUTC" => _("Utc"),
+ "installNTPServer" => _("Ntp server"),
+ "installMirror" => _("Mirror"),
+ "installRootEnabled" => _("Root login enabled"),
+ "installRootPasswordHash" => _("Root password hash"),
+ "installKernelPackage" => _("Kernel package"),
+ "installConfigManagement" => _("Config mangement"),
+ "installBootstrapMethod" => _("Bootstrap method"),
+ "installPartitionTable" => _("Partition table")
)
)
);
}
}
-
?>