home *** CD-ROM | disk | FTP | other *** search
Wrap
/** * Module: inst_vm_options.ycp * * Authors: Ladislav Slezak <lslezak@suse.cz> * Michael G. Fritch <mgfritch@novell.com> * * Purpose: Ask the user for various options for the virtual machine. * * $Id: inst_vm_options.ycp 30722 2006-05-05 22:59:43Z mgfritch $ * */ { textdomain "vm"; import "VM"; import "VM_Common"; import "Wizard"; import "Popup"; import "String"; import "Report"; // screen title for virtual machine options string title = _("VM Properties"); list<term> event_options = [ // combobox item `item(`id("destroy"), _("Destroy")), // combobox item `item(`id("restart"), _("Restart")), // combobox item `item(`id("preserve"), _("Preserve")), // combobox item `item(`id("rename-restart"), _("Rename and restart")), ]; // build and show dialog Wizard::OpenAcceptDialog (); term contents = `MarginBox(15, 1, `HBox( `VBox( // textbox label `TextEntry(`id(`vmname), `opt(`hstretch), _("&Name of Virtual Machine"), VM::GetConfigName()), (VM_Common::proposal_type != "install") ? `VBox( `VSpacing(0.5), `ComboBox(`id(`startmode), `opt(`hstretch), // combobox label _("Start the VM"), [ // combobox item `item(`id("manual"), _("Manually")), // combobox item `item(`id("onboot"), _("Automatically")), ] ), `VSpacing(0.5), `ComboBox(`id(`on_poweroff), `opt(`hstretch), // combobox label _("When the VM is Powered Off"), event_options ), `VSpacing(0.5), `ComboBox(`id(`on_reboot), `opt(`hstretch), // combobox label _("When the VM is Rebooted"), event_options ), `VSpacing(0.5), `ComboBox(`id(`on_crash), `opt(`hstretch), // combobox label _("When the VM Crashes"), event_options ) ) : `Empty() ) ) ); // virtual machine options - help text title string help_text = sformat(_("<p><b><big>%1</big></b></p>"), title); if (VM_Common::proposal_type != "boot") // virtual machine options (boot) - help text 1/1 help_text = help_text + _("<p>Each virtual machine must have a unique name. The <b>name of virtual machine</b> entered here will be used as the name of the VM configuration file.</p>"); if (VM_Common::proposal_type != "install") { help_text = help_text // virtual machine options (install) - help text 1/8 + _("<p>The VM can be started <b>automatically</b> when the VM Server starts, or <b>manually</b> via YaST or the command line.</p>") // virtual machine options (install) - help text 2/8 + _("<p>When various lifecycle events occur (<b>power off</b>, <b>reboot</b>, or <b>crash</b> of the VM), an action can automatically be taken. These actions are:</p>") // virtual machine options (install) - help text 3/8 + _("<ul>") + sformat("<li><p><b>%1</b>: %2</p></li>", _("Destroy"), // virtual machine options (install) - help text 4/8 _("The VM is cleaned up as normal.")) + sformat("<li><p><b>%1</b>: %2</p></li>", _("Restart"), // virtual machine options (install) - help text 5/8 _("A new VM is started in place of the old one.")) + sformat("<li><p><b>%1</b>: %2</p></li>", _("Preserve"), // virtual machine options (install) - help text 6/8 _("The VM will remain in memory until it is destroyed manually.")) + sformat("<li><p><b>%1</b>: %2</p></li>", _("Rename and restart"), // virtual machine options (install) - help text 7/8 _("The VM is renamed and will remain in memory until it is destroyed manually, and a new VM is started.")) // virtual machine options (install) - help text 8/8 + _("</ul>"); } Wizard::SetContents (title, contents, help_text, (boolean) WFM::Args(0), (boolean) WFM::Args(1)); if (VM_Common::proposal_type == "boot") UI::ChangeWidget(`id(`vmname), `Enabled, false); else { // allow only 0-9, a-z, A-Z, and the characters _-.:+ in domain name UI::ChangeWidget (`id(`vmname), `ValidChars, String::CAlnum() + "_-:+"); // only allow string length of 255 chars max UI::ChangeWidget (`id(`vmname), `InputMaxLength, 255); } if (VM_Common::proposal_type != "install") { UI::ChangeWidget(`id(`startmode), `Value, VM::GetStartMode()); UI::ChangeWidget(`id(`on_poweroff), `Value, VM::GetOnPowerOff()); UI::ChangeWidget(`id(`on_reboot), `Value, VM::GetOnReboot()); UI::ChangeWidget(`id(`on_crash), `Value, VM::GetOnCrash()); } any ret = nil; while (true) { ret = Wizard::UserInput (); if (ret == `abort || ret == `cancel) { if (Popup::ReallyAbort(true)) break; } else if (ret == `back) { break; } if (ret == `next) { if (VM_Common::proposal_type != "boot") { string vmname = (string) UI::QueryWidget (`id(`vmname), `Value); if (vmname == nil || vmname == "") { // error message: do not allow empty name of virtual machine Report::Error(_("Name of Virtual Machine cannot be left empty. Please, specify a Name of Virtual Machine.")); continue; } if ( VM::ValidateConfigName(vmname) == false ) { // error message: name of virtual machine must be unique, entered name is already in use Report::Error(_("Name of Virtual Machine is already used. Enter another name. ")); continue; } // do not allow machine names of '.' or '..' if (vmname == "." || vmname == "..") { // popup error message Report::Error(_("Name of Virtual Machine cannot be exactly '.' or '..'")); continue; } // do not allow the vmname to start with a number if (findfirstof(vmname, String::CDigit()) == 0) { // popup error message Report::Error(_("Name of Virtual Machine cannot begin with a number.")); continue; } VM::SetConfigName(vmname); } if (VM_Common::proposal_type != "install") { string startmode = (string) UI::QueryWidget (`id(`startmode), `Value); y2milestone("startmode: %1", startmode); VM::SetStartMode(startmode); string on_poweroff = (string) UI::QueryWidget (`id(`on_poweroff), `Value); y2milestone("on_poweroff: %1", on_poweroff); VM::SetOnPowerOff(on_poweroff); string on_reboot = (string) UI::QueryWidget (`id(`on_reboot), `Value); y2milestone("on_reboot: %1", on_reboot); VM::SetOnReboot(on_reboot); string on_crash = (string) UI::QueryWidget (`id(`on_crash), `Value); y2milestone("on_crash: %1", on_crash); VM::SetOnCrash(on_crash); } break; } else { y2error("unexpected retcode: %1", ret); continue; } } Wizard::CloseDialog (); return ret; /* EOF */ }