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 9ed86671d31a8a1df505b6c342f4d5bd6f2fbf28..c3908a4054b6a7e992bd51c7ebdc854fa0e0dd19 100644 (file)
{
public $rpcErrorMessage = "";
{
public $rpcErrorMessage = "";
+ public $deviceUUID = "";
// Template options
public $installTemplate = "";
// Template options
public $installTemplate = "";
// Partition table variables
public $installPartitionTable = "";
// Partition table variables
public $installPartitionTable = "";
+ private $partitionEdit = NULL;
// Keyboard-layout attribute
public $installKeyboardlayout = "";
// Keyboard-layout attribute
public $installKeyboardlayout = "";
*/
public $view_logged = FALSE;
public $ignore_account = FALSE;
*/
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");
$this->hashes[$name] = $name;
}
$this->hashes[$name] = $name;
}
- // Init the object values.
+ // Initialize plugin
$this->init_static_info();
$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->init_client_info();
// Prepare NTP servers list
$this->installTemplate = key($this->installationTemplates);
$this->installRelease = key($this->templateToRelease[$this->installTemplate]);
}else{
$this->installTemplate = key($this->installationTemplates);
$this->installRelease = key($this->templateToRelease[$this->installTemplate]);
}else{
+
if(!isset($this->installationTemplates[$this->installTemplate])){
if(!isset($this->installationTemplates[$this->installTemplate])){
- print "<br>Invalid template selected {$this->installTemplate}";
- $this->installTemplate = key($this->installationTemplates);
+
+ // 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'])){
}elseif(!isset($this->installationTemplates[$this->installTemplate]['method'])){
- print "<br>No bootstrap method found!";
-
+
+ // 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])){
}elseif(!in_array($this->installRelease, $this->templateToRelease[$this->installTemplate])){
- print "<br>Invalid release selected {$this->installRelease}";
- $this->installRelease = key($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->installBootstrapMethod = $this->installationTemplates[$this->installTemplate]['method'];
- $this->reloadInstallationKernelPackages();
- $this->reloadInstallationMirrors();
+ $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]);
+ }
+ }
}
}
- /*! \brief Load attribute values from the GOsa-backend using jsonRPC
+ /*! \brief Loads client-information values from the GOsa-backend using jsonRPC
*/
function init_client_info()
{
*/
function init_client_info()
{
- $uuid = "a0d17918-cfb2-11df-acbd-5452005f1250";
+ if(empty($this->deviceUUID)){
+ return;
+ }
+
$rpc = $this->config->getRpcHandle();
$rpc = $this->config->getRpcHandle();
- $res = $rpc->systemGetBaseInstallParameters($uuid);
+ $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();
+ msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
return(NULL);
}
return(NULL);
}
-
+
// Apply received options
$this->is_account = $res == True;
if($this->is_account){
// Apply received options
$this->is_account = $res == True;
if($this->is_account){
- $this->installNTPServer = $res['ntp-servers'];
- $this->installTemplate = $res['template'];
- $this->installRelease = $res['release'][0];
- $this->installTimezone = array_search($res['timezone'][0], $this->timezones);
- $this->installTimeUTC = $res['utc'][0];
- $this->installKernelPackage = $res['kernel'][0];;
- $this->installSystemLocale = $res['system-locale'][0];
- $this->installRootEnabled = $res['root-user'][0];
- $this->installRootPasswordHash = $res['root-hash'][0];
- $this->installPartitionTable = $res['disk-setup'][0];
- $this->installKeyboardlayout = $res['keyboard-layout'];
+
+ $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));
+ }
}
return;
}
return;
}
}
}
}
+
+ 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()
{
function execute()
{
$display = "";
if ($this->parent !== NULL){
if ($this->is_account){
$display = "";
if ($this->parent !== NULL){
if ($this->is_account){
- $display= $this->show_disable_header(_("Remove install 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
***************/
+ $this->dialog = FALSE;
if($this->setPasswordHash){
$this->dialog = TRUE;
$smarty = get_smarty();
if($this->setPasswordHash){
$this->dialog = TRUE;
$smarty = get_smarty();
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();
- $smarty->assign('installTemplateList', $this->installationTemplateNames);
- $smarty->assign('installReleaseList', $this->templateToRelease[$this->installTemplate]);
+ // 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);
$this->installNTPServerList->setListData($this->installNTPServer);
$this->installBootstrapMethod = $this->installationTemplates[$this->installTemplate]['method'];
$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();
// Reload list of kernel packages and mirrors
if($oldRelease != $this->installRelease){
$this->reloadInstallationKernelPackages();
function save()
{
if(!$this->installRootEnabled) $this->installRootPasswordHash = "";
function save()
{
if(!$this->installRootEnabled) $this->installRootPasswordHash = "";
-
- $uuid = "a0d17918-cfb2-11df-acbd-5452005f1250";
- $rpc = $this->config->getRpcHandle();
+ $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();
$data = array();
- $res = $rpc->systemSetBaseInstallParameters($uuid, $data);
+ 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();
// 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(NULL);
}
- return($res);
}
}
/*! \brief Refreshes the list of selectable kernel packages.
*/
/*! \brief Refreshes the list of selectable kernel packages.
*/
- function reloadInstallationKernelPackages()
+ 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();
$rpc = $this->config->getRpcHandle();
- $res = $rpc->getKernelPackages($this->installRelease);
-
+ $res = $rpc->getKernelPackages($release);
+
// Failed to load backend values, keep reported error and return with FALSE;
$this->rpcError = !$rpc->success();
if(!$rpc->success()){
// Failed to load backend values, keep reported error and return with FALSE;
$this->rpcError = !$rpc->success();
if(!$rpc->success()){
msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
}else{
$this->installKernelPackageList = array();
msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
}else{
$this->installKernelPackageList = array();
- foreach($res as $name){
+ foreach($res as $data){
+ $name = $data['name'];
$this->installKernelPackageList[$name] = $name;
}
if(!isset($this->installKernelPackageList[$this->installKernelPackage])){
$new = key($this->installKernelPackageList);
$this->installKernelPackageList[$name] = $name;
}
if(!isset($this->installKernelPackageList[$this->installKernelPackage])){
$new = key($this->installKernelPackageList);
- 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);
+ 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;
}
}
$this->installKernelPackage = $new;
}
}
/*! \brief Returns a list of installation mirrors on success.
* In case of an error, it returns NULL.
*/
/*! \brief Returns a list of installation mirrors on success.
* In case of an error, it returns NULL.
*/
- function reloadInstallationMirrors()
+ function reloadInstallationMirrors($initially = FALSE)
{
$res = array(
'dc=intranet,dc=gonicus,dc=de' => 'Intranet',
{
$res = array(
'dc=intranet,dc=gonicus,dc=de' => 'Intranet',
$this->rpcError = !$rpc->success();
if(!$rpc->success()){
$this->rpcErrorMessage = $rpc->get_error();
$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(NULL);
}
"plSection" => array("administration"),
"plCategory" => array("Device"),
"plProvidedAcls" => array(
"plSection" => array("administration"),
"plCategory" => array("Device"),
"plProvidedAcls" => array(
- "member" => _("Member"),
- "installTemplate" => _("Installation template"),
- "installRelease" => _("Installation release"),
- "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"),
+ "installTimeUTC" => _("Utc"),
+ "installNTPServer" => _("Ntp server"),
"installMirror" => _("Mirror"),
"installRootEnabled" => _("Root login enabled"),
"installRootPasswordHash" => _("Root password hash"),
"installKernelPackage" => _("Kernel package"),
"installMirror" => _("Mirror"),
"installRootEnabled" => _("Root login enabled"),
"installRootPasswordHash" => _("Root password hash"),
"installKernelPackage" => _("Kernel package"),
+ "installConfigManagement" => _("Config mangement"),
+ "installBootstrapMethod" => _("Bootstrap method"),
"installPartitionTable" => _("Partition table")
)
)
"installPartitionTable" => _("Partition table")
)
)