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 43a93b36d33600955870bd952f7f9fa519c990c2..2b3d9a6b59ed5c06b6668c5ab4b8cf80ae765ea4 100644 (file)
class InstallRecipe extends plugin
{
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 $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 $installKernelPackage = "";
- public $installKernelPackageList = array('kernel1','kk1');
-
- public $installKeyboardlayout = "";
- public $installKeyboardlayoutList = array("104","105");
+ public $installKernelPackageList = array();
+ // System Locale
public $installSystemLocale = "";
public $installSystemLocale = "";
- public $installSystemLocaleList = array('de','en_EN.UTF-8');
-
- public $installTimezone = "";
- public $installTimeUTC = "";
+ public $installSystemLocaleList = array();
+ // Selected NTP Server
public $installNTPServer = array();
public $installNTPServer = array();
+ public $installNTPServerList = NULL;
+
+ // Root password
public $installRootEnabled = "";
public $installRootPasswordHash = "";
public $installRootEnabled = "";
public $installRootPasswordHash = "";
+ public $setPasswordHash = FALSE;
- public $setKickstartRootPasswordHash = FALSE;
+ // Partition table variables
public $installPartitionTable = "";
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");
"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;
/* 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.
*/
/*! \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);
{
plugin::plugin($config, $dn);
+ $this->is_account = $this->initially_was_account = FALSE;
+
+ $this->_device = &$parent;
+ $this->deviceUUID = $parent->deviceUUID;
+
// Set default password hash
$this->hash = $this->config->get_cfg_value("core","passwordDefaultHash");
// Set default password hash
$this->hash = $this->config->get_cfg_value("core","passwordDefaultHash");
+ // Get list of password hashes
+ $tmp = passwordMethod::get_available_methods();
+ $this->hashes = array();
+ foreach($tmp['name'] as $name){
+ $this->hashes[$name] = $name;
+ }
+
+ // 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->installNTPServerList= new sortableListing($this->installNTPServer);
$this->installNTPServerList->setDeleteable(true);
// Prepare NTP servers list
$this->installNTPServerList= new sortableListing($this->installNTPServer);
$this->installNTPServerList->setDeleteable(true);
$this->installNTPServerList->setWidth("100%");
$this->installNTPServerList->setHeight("70px");
$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;
- }
- }
-
- // Start without error.
- $this->initFailed = FALSE;
-
+ // Preset values for new devices
+ if(!$this->is_account){
+ $this->installTemplate = key($this->installationTemplates);
+ $this->installRelease = key($this->templateToRelease[$this->installTemplate]);
+ }else{
- // Prepare list of timezones
- $this->timezones = $this->getTimezones();
+ if(!isset($this->installationTemplates[$this->installTemplate])){
- // 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];
- }
- }
+ // The selected template is no longer available, select the next selectable template.
+ $new = key($this->installationTemplates);
- // Get list of password hashes
- $tmp = passwordMethod::get_available_methods();
- $this->hashes = array();
- foreach($tmp['name'] as $name){
- $this->hashes[$name] = $name;
- }
-
- // Load list of bootstrap methods.
- if(!$this->loadInstallationMethods()){
- $this->initFailed = TRUE;
- msg_dialog(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
- return;
- }
-
+ 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]);
- $this->installTemplateDNList = array(
- 'dc=intranet,dc=gonicus,dc=de' => 'Intranet-Tpl',
- 'ou=systems,dc=intranet,dc=gonicus,dc=de' => 'System-Tpl');
+ }elseif(!isset($this->installationTemplates[$this->installTemplate]['method'])){
- $this->installMirrorDNList = array(
- 'dc=intranet,dc=gonicus,dc=de' => 'Intranet',
- 'ou=systems,dc=intranet,dc=gonicus,dc=de' => 'System');
+ // Not necessary to warn the user here, the input fields will be empty and thus
+ // avoid saving.
- // Preset some values for new accounts
- if(!$this->is_account){
+ }elseif(!in_array($this->installRelease, $this->templateToRelease[$this->installTemplate])){
- // Preset the device timezone
- $tz = timezone::get_default_timezone();
- $this->installTimezone = $tz['name'];
+ // 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);
+ }
+ }
- // Set initial bootstrap and install method.
- $this->installBootstrapMethod = key($this->installBootstrapMethodList);
- $this->installConfigManagement = key($this->installConfigManagementList[$this->installBootstrapMethod]);
- }
+
+ // 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])){
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;
+ if(isset($this->installConfigManagementList[$this->installBootstrapMethod]) &&
+ count($this->installConfigManagementList[$this->installBootstrapMethod])){
+ $this->installConfigManagement = key($this->installConfigManagementList[$this->installBootstrapMethod]);
+ }
}
}
}
}
-
- 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").")";
- }
- }
- uksort($list, 'strnatcasecmp');
- return($list);
- }
-
- /*! \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;
+ /*! \brief Loads client-information values from the GOsa-backend using jsonRPC
*/
*/
- function loadInstallationMethods()
- {
- $this->installBootstrapMethodList = array();
- $this->installConfigManagementList = array();
+ function init_client_info()
+ {
+ if(empty($this->deviceUUID)){
+ return;
+ }
+
+ // Load base install Method
$rpc = $this->config->getRpcHandle();
$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();
// 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(FALSE);
+ 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){
- $this->installBootstrapMethodList[$name] = $method['name'];
- foreach($method['methods'] as $m){
- $this->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(TRUE);
+
+ 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
function execute()
{
// Log account access
$display = "";
if ($this->parent !== NULL){
if ($this->is_account){
$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 {
} 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);
}
}
return ($display);
}
}
Root password hash dialog
***************/
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));
$this->dialog = TRUE;
$smarty = get_smarty();
$smarty->assign('hashes', set_post($this->hashes));
return($smarty->fetch(get_template_path('goto/Device/SetPassword.tpl', TRUE)));
}
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
***************/
/***************
Generate HTML content
***************/
plugin::execute();
$smarty = get_smarty();
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('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());
$smarty->assign('installSystemLocaleList', $this->installSystemLocaleList);
$smarty->assign('installNTPServerList', $this->installNTPServerList->render());
$smarty->assign('installBootstrapMethodList', $this->installBootstrapMethodList);
$smarty->assign('installConfigManagement', $this->installConfigManagement);
$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);
}
foreach($this->attributes as $attr){
$smarty->assign($attr, $this->$attr);
}
if(isset($_POST['InstallRecipePosted'])){
$currentInstallMethod = $this->installConfigManagement;
if(isset($_POST['InstallRecipePosted'])){
$currentInstallMethod = $this->installConfigManagement;
+
+ $oldRelease = $this->installRelease;
plugin::save_object();
$this->installRootEnabled = isset($_POST['installRootEnabled']);
$this->installTimeUTC = isset($_POST['installTimeUTC']);
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();
}
$this->installNTPServerList->save_object();
}
}
$this->installNTPServerList->setListData($this->installNTPServer);
}
}
$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'])) {
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.
$hash = get_post('passwordHash');
// Not sure, why this is here, but maybe some encryption methods require it.
$test = new $available[$hash]($this->config,$this->dn);
$this->installRootPasswordHash = @$test->generate_hash(get_post('rootPassword'));
}
$test = new $available[$hash]($this->config,$this->dn);
$this->installRootPasswordHash = @$test->generate_hash(get_post('rootPassword'));
}
-
}
function save()
{
}
function save()
{
- //
if(!$this->installRootEnabled) $this->installRootPasswordHash = "";
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.";
+ $map = array(
+ "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',
+ "installBootstrapMethod"=>'method',
+ );
+
+ // 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
+ if(!empty($this->installNTPServer)){
+ $data['ntp-servers'] = array_values($this->installNTPServer);
+ }
- // 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']);
+ // 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";
}
}
- $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");
+
+ // Set the base installation parameters
+ $rpc = $this->config->getRpcHandle();
+ $res = $rpc->systemSetBaseInstallParameters($this->deviceUUID, $data);
+
+ // Handle errors
+ $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()
{
}
}
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{
}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 && $this->is_account){
+ 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);
}
}
"plSection" => array("administration"),
"plCategory" => array("Device"),
"plProvidedAcls" => array(
"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"),
"installKeyboardlayout" => _("Keyboard layout"),
- "installSystemLocale" => _("System locale"),
+ "installSystemLocale" => _("Locale"),
"installTimezone" => _("Timezone"),
"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"),
"installRootEnabled" => _("Root login enabled"),
"installRootPasswordHash" => _("Root password hash"),
- "installKernelPackage" => _("Kernal package"),
+ "installKernelPackage" => _("Kernel package"),
+ "installConfigManagement" => _("Config mangement"),
+ "installBootstrapMethod" => _("Bootstrap method"),
"installPartitionTable" => _("Partition table")
)
)
);
}
}
"installPartitionTable" => _("Partition table")
)
)
);
}
}
-
?>
?>