Author: lidongyang
Date: Fri Jun 10 08:54:17 2011
New Revision: 64301
URL: http://svn.opensuse.org/viewcvs/yast?rev=64301&view=rev
Log:
add relocation-server stuffs to yast2-vm
Added:
trunk/vm/agents/
trunk/vm/agents/Makefile.am
trunk/vm/agents/xend.scr
trunk/vm/src/RelocationServer.ycp
trunk/vm/src/complex.ycp
trunk/vm/src/dialogs.ycp
trunk/vm/src/helps.ycp
trunk/vm/src/relocation-server.desktop
trunk/vm/src/relocation-server.ycp
trunk/vm/src/wizards.ycp
Modified:
trunk/vm/MAINTAINER
trunk/vm/src/Makefile.am
trunk/vm/yast2-vm.spec.in
Modified: trunk/vm/MAINTAINER
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/MAINTAINER?rev=64301&r1=64300&r2=64301&view=diff
==============================================================================
--- trunk/vm/MAINTAINER (original)
+++ trunk/vm/MAINTAINER Fri Jun 10 08:54:17 2011
@@ -1 +1,2 @@
Ladislav Slezak
+Li Dongyang
Added: trunk/vm/agents/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/agents/Makefile.am?rev=64301&view=auto
==============================================================================
--- trunk/vm/agents/Makefile.am (added)
+++ trunk/vm/agents/Makefile.am Fri Jun 10 08:54:17 2011
@@ -0,0 +1,7 @@
+# Makefile.am for vm/agents
+
+agent_SCRIPTS =
+
+scrconf_DATA = xend.scr
+
+EXTRA_DIST = $(agent_SCRIPTS) $(scrconf_DATA)
Added: trunk/vm/agents/xend.scr
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/agents/xend.scr?rev=64301&view=auto
==============================================================================
--- trunk/vm/agents/xend.scr (added)
+++ trunk/vm/agents/xend.scr Fri Jun 10 08:54:17 2011
@@ -0,0 +1,27 @@
+/**
+ * File:
+ * xend.scr
+ * Summary:
+ * SCR Agent for reading/writing /etc/xen/xend-config.sxp
+ * using the ini-agent
+ * Access:
+ * read/write
+ * Authors:
+ * Li Dongyang
+ */
+
+.etc.xen.xend-config
+
+`ag_ini (
+ `IniAgent ( "/etc/xen/xend-config.sxp",
+ $[
+ "options" : [ "global_values", "flat" ],
+ "comments" : [ "^[ \t]*#.*$", "^[ \t]*$" ],
+ "params" : [
+ $[ "match" : [ "\\(([^ ]+) +([^']*)\\)", "(%s %s)" ]],
+ $[ "match" : [ "\\(([^ ]+) +'?([^']*)'?\\)", "(%s '%s')" ]],
+ ],
+ ]
+ )
+)
+
Modified: trunk/vm/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/src/Makefile.am?rev=64301&r1=64300&r2=64301&view=diff
==============================================================================
--- trunk/vm/src/Makefile.am (original)
+++ trunk/vm/src/Makefile.am Fri Jun 10 08:54:17 2011
@@ -2,18 +2,29 @@
# Makefile.am for vm/src
#
+yncludedir = @yncludedir@/relocation-server
+
groupdir = @desktopdir@/groups
client_DATA = \
- vm_finish.ycp
+ vm_finish.ycp \
+ relocation-server.ycp
+
+ynclude_DATA = \
+ helps.ycp \
+ wizards.ycp \
+ dialogs.ycp \
+ complex.ycp
group_DATA = \
virtualization.desktop
desktop_DATA = \
+ relocation-server.desktop
module_DATA = \
- VM_XEN.ycp
+ VM_XEN.ycp \
+ RelocationServer.ycp
EXTRA_DIST = $(client_DATA) $(module_DATA) $(group_DATA) $(desktop_DATA)
Added: trunk/vm/src/RelocationServer.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/src/RelocationServer.ycp?rev=64301&view=auto
==============================================================================
--- trunk/vm/src/RelocationServer.ycp (added)
+++ trunk/vm/src/RelocationServer.ycp Fri Jun 10 08:54:17 2011
@@ -0,0 +1,479 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: modules/RelocationServer.ycp
+ * Package: Configuration of relocation-server
+ * Summary: RelocationServer settings, input and output functions
+ * Authors: Li Dongyang
+ *
+ * $Id: RelocationServer.ycp 41350 2007-10-10 16:59:00Z dfiser $
+ *
+ * Representation of the configuration of relocation-server.
+ * Input and output routines.
+ */
+
+{
+
+module "RelocationServer";
+textdomain "relocation-server";
+
+import "Arch";
+import "SCR";
+import "Progress";
+import "Report";
+import "Popup";
+import "Summary";
+import "Message";
+import "Service";
+import "SuSEFirewall";
+import "SuSEFirewallServices";
+
+/**
+ * Data was modified?
+ */
+boolean modified = false;
+
+/**
+ * Returns whether the configuration has been modified.
+ */
+global boolean GetModified() {
+ return modified;
+}
+
+/**
+ * Sets that the configuration has been modified.
+ */
+global void SetModified() {
+ modified = true;
+}
+
+/**
+ Returns a confirmation popup dialog whether user wants to really abort.
+ */
+global boolean Abort() {
+ return Popup::ReallyAbort(GetModified());
+}
+
+/**
+ * Checks whether an Abort button has been pressed.
+ * If so, calls function to confirm the abort call.
+ *
+ * @return boolean true if abort confirmed
+ */
+global boolean PollAbort() {
+ if (UI::PollInput() == `abort)
+ return Abort();
+
+ return false;
+}
+
+/**
+* map of xend settings
+*/
+ map SETTINGS = $[];
+
+ map DEFAULT_CONFIG = $[
+ "xend-relocation-server" : "no",
+ "xend-relocation-ssl-server" : "no",
+ "xend-relocation-port" : "8002",
+ "xend-relocation-ssl-port" : "8003",
+ "xend-relocation-server-ssl-key-file" : "xmlrpc.key",
+ "xend-relocation-server-ssl-cert-file" : "xmlrpc.cert",
+ "xend-relocation-ssl" : "no",
+ "xend-relocation-address" : "",
+ "xend-relocation-hosts-allow" : "^localhost$ ^localhost\\.localdomain$",
+ ];
+
+/**
+ * Returns the Xend Option as a list of strings.
+ *
+ * @param string option_key of the xend configuration
+ * @return string with option_values
+ */
+global string GetXendOption (string option_key) {
+ return SETTINGS[option_key]:DEFAULT_CONFIG[option_key]:"";
+}
+
+/**
+ * Returns default Xend Option as a list of strings.
+ *
+ * @param string option_key of the Xend configuration
+ * @return string with option_values
+ */
+
+global string GetDefaultXendOption (string option_key) {
+ return DEFAULT_CONFIG[option_key]:"";
+}
+
+/**
+ * Sets values for an option.
+ *
+ * @param string option_key with the Xend configuration key
+ * @param string option_values with the Xend configuration values
+ */
+global void SetXendOption (string option_key, string option_vals) {
+ SETTINGS[option_key] = option_vals;
+}
+
+/**
+ * Reads current xend configuration
+ */
+boolean ReadXendSettings () {
+ foreach (string key, (list <string>) SCR::Dir(.etc.xen.xend-config), {
+ string val = (string) SCR::Read(add(.etc.xen.xend-config, key));
+ if (val != nil) SETTINGS[key] = val;
+ });
+
+ y2milestone("Xend configuration has been read: %1", SETTINGS);
+ return true;
+}
+
+/**
+ * Writes current xend configuration
+ */
+boolean WriteXendSettings () {
+ y2milestone("Writing Xend configuration: %1", SETTINGS);
+
+ foreach (string option_key, string option_val, SETTINGS, {
+ SCR::Write(add(.etc.xen.xend-config, option_key), option_val);
+ });
+ // This is very important
+ // it flushes the cache, and stores the configuration on the disk
+ SCR::Write(.etc.xen.xend-config, nil);
+
+ string port = GetXendOption("xend-relocation-port");
+ string ssl_port = GetXendOption("xend-relocation-ssl-port");
+ list <string> ports_list = [port, ssl_port];
+ SuSEFirewallServices::SetNeededPortsAndProtocols(
+ "service:xend-relocation-server",
+ $[ "tcp_ports" : ports_list,]
+ );
+
+ return true;
+}
+
+/**
+ * Describes whether the daemon is running
+ */
+boolean xend_is_running = false;
+
+/**
+ * Reads current xend status
+ */
+boolean ReadXendService () {
+ if (Service::Status("xend") == 0) {
+ xend_is_running = true;
+ } else {
+ xend_is_running = false;
+ }
+
+ y2milestone((xend_is_running ? "Xend is running":"Xend is not running"));
+
+ return true;
+}
+
+/**
+ * Restarts the xend when the daemon was running when starting the configuration
+ */
+boolean WriteXendService () {
+ boolean all_ok = true;
+
+ if (xend_is_running) {
+ y2milestone("Restarting xend daemon");
+ all_ok = Service::Restart("xend");
+ } else {
+ y2milestone("Xend is not running - leaving...");
+ }
+
+ return all_ok;
+}
+
+string libvirtd_default_ports = "49152:49215";
+list <string> libvirtd_ports = [];
+
+global list <string> GetLibVirtdPorts() {
+ return libvirtd_ports;
+}
+
+global void SetLibvirtdPorts(list <string> ports) {
+ libvirtd_ports = ports;
+}
+
+boolean libvirtd_enabled = false;
+boolean sshd_enabled = false;
+boolean libvirtd_is_running = false;
+boolean sshd_is_running = false;
+
+map LibvirtdOptions = $[
+ "tunneled_migration" : false,
+ "plain_migration" : false,
+ "default_port_range" : false,
+];
+
+global boolean GetLibvirtdOption(string key) {
+ return LibvirtdOptions[key]:false;
+}
+
+global void SetLibvirtdOption(string key, boolean val) {
+ LibvirtdOptions[key] = val;
+}
+
+boolean ReadKVMServices () {
+ libvirtd_enabled = Service::Enabled("libvirtd");
+ sshd_enabled = Service::Enabled("sshd");
+
+ if (Service::Status("libvirtd") == 0) {
+ libvirtd_is_running = true;
+ } else {
+ libvirtd_is_running = false;
+ }
+ if (Service::Status("sshd") == 0) {
+ sshd_is_running = true;
+ } else {
+ sshd_is_running = false;
+ }
+
+ list <string> ports = SuSEFirewallServices::GetNeededTCPPorts("service:libvirtd-relocation-server");
+ libvirtd_ports = filter(string s, ports, {return (s != libvirtd_default_ports);});
+
+ y2milestone((libvirtd_is_running ? "libvirtd is running":"libvirtd is not running"));
+ y2milestone((sshd_is_running ? "sshd is running":"sshd is not running"));
+
+ return true;
+}
+
+boolean WriteKVMServices () {
+ boolean all_ok = true;
+
+ if (GetLibvirtdOption("tunneled_migration") || GetLibvirtdOption("plain_migration")) {
+ if (!libvirtd_is_running)
+ all_ok = Service::Start("libvirtd") && all_ok;
+ if (!libvirtd_enabled)
+ all_ok = Service::Enable("libvirtd") && all_ok;
+ }
+ if (GetLibvirtdOption("tunneled_migration")) {
+ if (!sshd_is_running)
+ all_ok = Service::Start("sshd") && all_ok;
+ if (!sshd_enabled)
+ all_ok = Service::Enable("sshd") && all_ok;
+ }
+ if (GetLibvirtdOption("plain_migration")) {
+ if (GetLibvirtdOption("default_port_range"))
+ if (!contains(libvirtd_ports, libvirtd_default_ports))
+ libvirtd_ports = add(libvirtd_ports, libvirtd_default_ports);
+ SuSEFirewallServices::SetNeededPortsAndProtocols(
+ "service:libvirtd-relocation-server",
+ $[ "tcp_ports" : libvirtd_ports,]
+ );
+ }
+
+ return all_ok;
+}
+
+/**
+ * Read all relocation-server settings
+ * @return true on success
+ */
+global boolean Read() {
+
+ /* RelocationServer read dialog caption */
+ string caption = _("Initializing relocation-server Configuration");
+
+ integer xen_steps = 3;
+ integer kvm_steps = 2;
+
+ integer sl = 500;
+ sleep(sl);
+
+ list<string> xen_stg = [
+ /* Progress stage 1/3 */
+ _("Read the current xend configuration"),
+ /* Progress stage 2/3 */
+ _("Read the current xend state"),
+ /* Progress stage 3/3 */
+ _("Read firewall settings")
+ ];
+
+ list<string> xen_tits = [
+ /* Progress step 1/3 */
+ _("Reading the current xend configuration..."),
+ /* Progress step 2/3 */
+ _("Reading the current xend state..."),
+ /* Progress step 3/3 */
+ _("Reading firewall settings..."),
+ /* Progress finished */
+ Message::Finished()
+ ];
+
+ list<string> kvm_stg = [
+ /* Progress stage 1/2 */
+ _("Read firewall settings"),
+ /* Progress stage 2/2 */
+ _("Read the current libvirtd/sshd state")
+ ];
+
+ list<string> kvm_tits = [
+ /* Progress step 1/2 */
+ _("Reading firewall settings..."),
+ /* Progress stage 2/2 */
+ _("Reading the current libvirtd/sshd state..."),
+ /* Progress finished */
+ Message::Finished()
+ ];
+
+ if (Arch::is_xen0())
+ Progress::New( caption, " ", xen_steps, xen_stg, xen_tits,"");
+ else
+ Progress::New( caption, " ", kvm_steps, kvm_stg, kvm_tits,"");
+
+ if (Arch::is_xen0()) {
+ if(PollAbort()) return false;
+ Progress::NextStage();
+ /* Error message */
+ if(!ReadXendSettings()) Report::Error(Message::CannotReadCurrentSettings());
+ sleep(sl);
+
+ if(PollAbort()) return false;
+ Progress::NextStage();
+ /* Error message */
+ if(!ReadXendService()) Report::Error(_("Cannot read the current Xend state."));
+ sleep(sl);
+ }
+
+ if(PollAbort()) return false;
+ Progress::NextStage();
+ boolean progress_state = Progress::set (false);
+ /* Error message */
+ if(!SuSEFirewall::Read()) Report::Warning(_("Cannot read firewall settings."));
+ Progress::set (progress_state);
+ sleep(sl);
+
+ if (Arch::is_kvm()) {
+ if(PollAbort()) return false;
+ Progress::NextStage();
+ /* Error message */
+ if(!ReadKVMServices()) Report::Error(_("Cannot read the current libvirtd/sshd state."));
+ sleep(sl);
+ }
+
+ if(PollAbort()) return false;
+ /* Progress finished */
+ Progress::NextStage();
+ sleep(sl);
+
+ if(PollAbort()) return false;
+ modified = false;
+ return true;
+}
+
+/**
+ * Write all relocation-server settings
+ * @return true on success
+ */
+global boolean Write() {
+
+ /* RelocationServer read dialog caption */
+ string caption = _("Saving relocation-server Configuration");
+
+ integer xen_steps = 3;
+ integer kvm_steps = 2;
+
+ integer sl = 500;
+ sleep(sl);
+
+ list<string> xen_stg = [
+ /* Progress stage 1 */
+ _("Write the Xend settings"),
+ /* Progress stage 2 */
+ _("Adjust the Xend service"),
+ /* Progress stage 3 */
+ _("Write firewall settings")
+ ];
+
+ list<string> xen_tits = [
+ /* Progress step 1 */
+ _("Writing the Xend settings..."),
+ /* Progress step 2 */
+ _("Adjusting the Xend service..."),
+ /* Progress step 3 */
+ _("Writing firewall settings..."),
+ Message::Finished()
+ ];
+
+ list<string> kvm_stg = [
+ /* Progress stage 1 */
+ _("Adjust the libvirtd/sshd service"),
+ /* Progress stage 2 */
+ _("Write firewall settings")
+ ];
+
+ list<string> kvm_tits = [
+ /* Progress step 1 */
+ _("Adjusting the libvirtd/sshd service"),
+ /* Progress stage 2 */
+ _("Writing firewall settings..."),
+ Message::Finished()
+ ];
+
+ if (Arch::is_xen0())
+ Progress::New(caption, " ", xen_steps, xen_stg, xen_tits ,"");
+ else
+ Progress::New(caption, " ", kvm_steps, kvm_stg, kvm_tits ,"");
+
+ if (Arch::is_xen0()) {
+ if(PollAbort()) return false;
+ Progress::NextStage();
+ /* Error message */
+ if(!WriteXendSettings()) Report::Error (_("Cannot write the xend settings."));
+ sleep(sl);
+
+ if(PollAbort()) return false;
+ Progress::NextStage();
+ /* Error message */
+ if(!WriteXendService()) Report::Error (Message::CannotAdjustService("xend"));
+ sleep(sl);
+ } else {
+ if(PollAbort()) return false;
+ Progress::NextStage();
+ /* Error message */
+ if(!WriteKVMServices()) Report::Error (Message::CannotAdjustService("xend"));
+ sleep(sl);
+ }
+
+ if(PollAbort()) return false;
+ Progress::NextStage ();
+ boolean progress_state = Progress::set (false);
+ /* Error message */
+ if(!SuSEFirewall::Write()) Report::Error (_("Cannot write firewall settings."));
+ Progress::set (progress_state);
+ sleep(sl);
+
+ if(PollAbort()) return false;
+ /* Progress finished */
+ Progress::NextStage();
+ sleep(sl);
+
+ if(PollAbort()) return false;
+ return true;
+}
+
+/* EOF */
+}
Added: trunk/vm/src/complex.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/src/complex.ycp?rev=64301&view=auto
==============================================================================
--- trunk/vm/src/complex.ycp (added)
+++ trunk/vm/src/complex.ycp Fri Jun 10 08:54:17 2011
@@ -0,0 +1,318 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/relocation-server/complex.ycp
+ * Package: Configuration of relocation-server
+ * Summary: Dialogs definitions
+ * Authors: Li Dongyang
+ *
+ * $Id: complex.ycp 41350 2007-10-10 16:59:00Z dfiser $
+ */
+
+{
+
+textdomain "relocation-server";
+
+import "Label";
+import "Popup";
+import "Wizard";
+import "Wizard_hw";
+import "Confirm";
+import "CWMFirewallInterfaces";
+import "RelocationServer";
+
+
+include "relocation-server/helps.ycp";
+
+boolean ReallyExit () {
+ // yes-no popup
+ return Popup::YesNo (_("Really exit?
+All changes will be lost."));
+}
+
+/**
+ * Read settings dialog
+ * @return `abort if aborted and `next otherwise
+ */
+symbol ReadDialog() {
+ Wizard::RestoreHelp(HELPS["read"]:"");
+ Wizard::SetTitleIcon("yast-vm-install");
+ // RelocationServer::SetAbortFunction(PollAbort);
+ if (!Confirm::MustBeRoot()) return `abort;
+ boolean ret = RelocationServer::Read();
+ return ret ? `next : `abort;
+}
+
+/**
+ * Write settings dialog
+ * @return `abort if aborted and `next otherwise
+ */
+symbol WriteDialog() {
+ Wizard::RestoreHelp(HELPS["write"]:"");
+ Wizard::SetTitleIcon("yast-vm-install");
+ // RelocationServer::SetAbortFunction(PollAbort);
+ boolean ret = RelocationServer::Write();
+ return ret ? `next : `abort;
+}
+
+void InitGlobalState() {
+ boolean server_stat = (boolean) UI::QueryWidget(`id("xend-relocation-server"), `Value);
+ boolean ssl_server_stat = (boolean) UI::QueryWidget(`id("xend-relocation-ssl-server"), `Value);
+ boolean stat = server_stat || ssl_server_stat;
+ UI::ChangeWidget (`id("xend-relocation-address"), `Enabled, stat);
+ UI::ChangeWidget (`id("xend-relocation-hosts-allow"), `Enabled, stat);
+ if (stat)
+ CWMFirewallInterfaces::EnableOpenFirewallWidget ();
+ else
+ CWMFirewallInterfaces::DisableOpenFirewallWidget ();
+ stat = server_stat && ssl_server_stat;
+ UI::ChangeWidget (`id("xend-relocation-ssl"), `Enabled, stat);
+}
+
+void InitServerState() {
+ boolean stat = (boolean) UI::QueryWidget(`id("xend-relocation-server"), `Value);
+ UI::ChangeWidget (`id("xend-relocation-port"), `Enabled, stat);
+ InitGlobalState();
+}
+
+void InitSSLServerState() {
+ boolean stat = (boolean) UI::QueryWidget(`id("xend-relocation-ssl-server"), `Value);
+ UI::ChangeWidget (`id("xend-relocation-ssl-port"), `Enabled, stat);
+ UI::ChangeWidget (`id("xend-relocation-server-ssl-key-file"), `Enabled, stat);
+ UI::ChangeWidget (`id("xend-relocation-server-ssl-cert-file"), `Enabled, stat);
+ UI::ChangeWidget (`id("browse_ssl_key_file"), `Enabled, stat);
+ UI::ChangeWidget (`id("browse_ssl_cert_file"), `Enabled, stat);
+ InitGlobalState();
+}
+
+void InitXendConfigurationDialog (string id) {
+ foreach (string key, ["xend-relocation-server",
+ "xend-relocation-ssl-server",
+ "xend-relocation-ssl"], {
+ UI::ChangeWidget(`id(key), `Value, (RelocationServer::GetXendOption(key) == "yes"));
+ });
+
+ foreach (string key, ["xend-relocation-server-ssl-key-file",
+ "xend-relocation-server-ssl-cert-file",
+ "xend-relocation-address",
+ "xend-relocation-hosts-allow"], {
+ UI::ChangeWidget(`id(key), `Value, RelocationServer::GetXendOption(key));
+ });
+
+ foreach (string key, ["xend-relocation-port", "xend-relocation-ssl-port"], {
+ UI::ChangeWidget(`id(key), `Value, tointeger(RelocationServer::GetXendOption(key)));
+ });
+
+ InitServerState();
+ InitSSLServerState();
+}
+
+symbol HandleXendConfigurationDialog (string id, map event) {
+ any action = event["ID"]:nil;
+
+ if (action == "browse_ssl_key_file") {
+ string new_filename = UI::AskForExistingFile("", "", _("Select SSL Key File"));
+ if (new_filename != nil && new_filename != "") {
+ UI::ChangeWidget (`id("xend-relocation-server-ssl-key-file"), `Value, new_filename);
+ }
+ } else if (action == "browse_ssl_cert_file") {
+ string new_filename = UI::AskForExistingFile("", "", _("Select SSL Cert File"));
+ if (new_filename != nil && new_filename != "") {
+ UI::ChangeWidget (`id("xend-relocation-server-ssl-cert-file"), `Value, new_filename);
+ }
+ } else if (action == "xend-relocation-server") {
+ InitServerState();
+ } else if (action == "xend-relocation-ssl-server") {
+ InitSSLServerState();
+ }
+ return nil;
+}
+
+void StoreXendConfigurationDialog (string id, map event) {
+ RelocationServer::SetModified();
+
+ foreach (string key, ["xend-relocation-server",
+ "xend-relocation-ssl-server",
+ "xend-relocation-ssl"], {
+ string value = ((boolean)UI::QueryWidget(`id(key), `Value) == true) ? "yes":"no";
+ if (value != RelocationServer::GetXendOption(key))
+ RelocationServer::SetXendOption(key, value);
+ });
+
+ foreach (string key, ["xend-relocation-server-ssl-key-file",
+ "xend-relocation-server-ssl-cert-file",
+ "xend-relocation-address",
+ "xend-relocation-hosts-allow",
+ "xend-relocation-port",
+ "xend-relocation-ssl-port"], {
+ string value = tostring(UI::QueryWidget(`id(key), `Value));
+ if (value != RelocationServer::GetXendOption(key))
+ RelocationServer::SetXendOption(key, tostring(UI::QueryWidget(`id(key), `Value)));
+ });
+}
+
+void InitKVMFireWall() {
+ boolean tunneled_migration = (boolean) UI::QueryWidget(`id("tunneled_migration"), `Value);
+ boolean plain_migration = (boolean) UI::QueryWidget(`id("plain_migration"), `Value);
+ if (tunneled_migration || plain_migration)
+ CWMFirewallInterfaces::EnableOpenFirewallWidget ();
+ else
+ CWMFirewallInterfaces::DisableOpenFirewallWidget ();
+}
+
+void InitLibvirtdPortsTable () {
+ list <string> ports = RelocationServer::GetLibVirtdPorts();
+ boolean stat = (boolean) UI::QueryWidget(`id("plain_migration"), `Value);
+
+ if (ports != nil && ports != []) {
+ list <term> items = [];
+ foreach (string port, ports, {
+ items = add (items, `item(`id(port), port));
+ });
+
+ // Redraw table of ports and enable modification buttons
+ UI::ChangeWidget(`id("Port"), `Items, items);
+ UI::ChangeWidget(`id("edit_port"), `Enabled, true && stat);
+ UI::ChangeWidget(`id("delete_port"), `Enabled, true && stat);
+ } else {
+ // Redraw table of ports and disable modification buttons
+ UI::ChangeWidget(`id("Port"), `Items, []);
+ UI::ChangeWidget(`id("edit_port"), `Enabled, false);
+ UI::ChangeWidget(`id("delete_port"), `Enabled, false);
+ }
+
+ UI::ChangeWidget (`id("Port"), `Enabled, stat);
+ UI::ChangeWidget (`id("add_port"), `Enabled, stat);
+ UI::ChangeWidget (`id("default_port_range"), `Enabled, stat);
+}
+
+void InitKVMConfigurationDialog (string id) {
+ UI::ChangeWidget (`id("tunneled_migration"), `Value, false);
+ UI::ChangeWidget (`id("plain_migration"), `Value, false);
+ UI::ChangeWidget (`id("default_port_range"), `Value, true);
+ InitLibvirtdPortsTable();
+ InitKVMFireWall();
+}
+
+void DeletePort (string port) {
+ list <string> ports = RelocationServer::GetLibVirtdPorts();
+ ports = filter(string s, ports, {return (s != port);});
+ RelocationServer::SetLibvirtdPorts(ports);
+}
+
+void AddEditPortDialog (string current_port) {
+ UI::OpenDialog(`opt(`decorated), `VBox(
+ `MinWidth (30,
+ `HBox(
+ `HSpacing(1),
+ `Frame(
+ (current_port == nil ?
+ /* A popup dialog caption */
+ _("Add New Port")
+ :
+ /* A popup dialog caption */
+ _("Edit Current Port")),
+ /* A text entry */
+ `TextEntry(`id("port_number"), _("&Port"), (current_port == nil ? "":current_port))
+ ),
+ `HSpacing(1)
+ )
+ ),
+ `VSpacing(1),
+ `HBox(
+ `PushButton(`id(`ok), Label::OKButton()),
+ `HSpacing(1),
+ `PushButton(`id(`cancel), Label::CancelButton())
+ )
+ ));
+
+ UI::ChangeWidget( `id("port_number"), `ValidChars, "0123456789");
+
+ any ret = nil;
+ while (true) {
+ ret = UI::UserInput();
+ if (ret == `ok) {
+ string new_port = (string) UI::QueryWidget(`id("port_number"), `Value);
+
+ if (new_port == "") {
+ UI::SetFocus(`id("port_number"));
+ Report::Error(_("Port number must not be empty."));
+ continue;
+ }
+
+ if (tointeger(new_port) > 65535 || tointeger(new_port) < 1) {
+ UI::SetFocus(`id("port_number"));
+ Report::Error(_("Port number out of range."));
+ continue;
+ }
+
+ list <string> ports = RelocationServer::GetLibVirtdPorts();
+ if (contains(ports, new_port)) {
+ UI::SetFocus(`id("port_number"));
+ Report::Error(_("Port number already exists."));
+ continue;
+ }
+ ports = add(ports, new_port);
+ RelocationServer::SetLibvirtdPorts(ports);
+
+ if (current_port != nil) DeletePort(current_port);
+ }
+
+ break;
+ }
+
+ UI::CloseDialog();
+}
+
+symbol HandleKVMConfigurationDialog (string id, map event) {
+ any action = event["ID"]:nil;
+ string selected_port = (string) UI::QueryWidget (`id("Port"), `CurrentItem);
+
+ // Adding a new port
+ if (action == "add_port") {
+ AddEditPortDialog(nil);
+ // Editing current port
+ } else if (action == "edit_port") {
+ AddEditPortDialog(selected_port);
+ // Deleting current port
+ } else if (action == "delete_port") {
+ if (Confirm::DeleteSelected()) DeletePort (selected_port);
+ } else if (action == "tunneled_migration" || action == "plain_migration")
+ InitKVMFireWall();
+
+
+ InitLibvirtdPortsTable();
+ return nil;
+}
+
+void StoreKVMConfigurationDialog (string id, map event) {
+ RelocationServer::SetModified();
+
+ foreach (string key, ["tunneled_migration",
+ "plain_migration",
+ "default_port_range"], {
+ boolean value = (boolean)UI::QueryWidget(`id(key), `Value);
+ RelocationServer::SetLibvirtdOption(key, value);
+ });
+}
+
+/* EOF */
+}
Added: trunk/vm/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/src/dialogs.ycp?rev=64301&view=auto
==============================================================================
--- trunk/vm/src/dialogs.ycp (added)
+++ trunk/vm/src/dialogs.ycp Fri Jun 10 08:54:17 2011
@@ -0,0 +1,130 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/relocation-server/dialogs.ycp
+ * Package: Configuration of relocation-server
+ * Summary: Dialogs definitions
+ * Authors: Li Dongyang
+ *
+ * $Id: dialogs.ycp 27914 2006-02-13 14:32:08Z locilka $
+ */
+
+{
+
+textdomain "relocation-server";
+
+import "Label";
+import "Wizard";
+import "RelocationServer";
+
+include "relocation-server/helps.ycp";
+
+term XendConfigurationDialogContent () {
+ return `VBox(
+ `Frame(_("Global Settings"),
+ `VBox(
+ `Left(`InputField(`id("xend-relocation-address"), `opt(`hstretch), _("Relocation Address:"))),
+ `Left(`InputField(`id("xend-relocation-hosts-allow"), `opt(`hstretch), _("Allowed Hosts:"))),
+ `Left(`CheckBox(`id("xend-relocation-ssl"), _("Use SSL as Default"))),
+ `HStretch(),
+ `VStretch()
+ )
+ ),
+ `Frame(_("non-SSL Server"),
+ `VBox(
+ `Left(`HSquash(`IntField(`id("xend-relocation-port"), _("Port:"), 1, 65535, 1))),
+ `Left(`CheckBox(`id("xend-relocation-server"), `opt(`notify), _("Enable"))),
+ `VStretch()
+ )
+ ),
+ `Frame(_("SSL Server"),
+ `VBox(
+ `Left(`HSquash(`IntField(`id("xend-relocation-ssl-port"), _("Port:"), 1, 65535, 1))),
+ `Left(
+ `HBox(
+ `InputField(`id("xend-relocation-server-ssl-key-file"), `opt(`hstretch), _("SSL Key File:")),
+ `HSpacing(1),
+ `VBox(
+ `Label(""),
+ `PushButton(`id("browse_ssl_key_file"), Label::BrowseButton())
+ )
+ )
+ ),
+ `Left(
+ `HBox(
+ `InputField(`id("xend-relocation-server-ssl-cert-file"), `opt(`hstretch), _("SSL Cert File:")),
+ `HSpacing(1),
+ `VBox(
+ `Label(""),
+ `PushButton(`id("browse_ssl_cert_file"), Label::BrowseButton())
+ )
+ )
+ ),
+ `Left(`CheckBox(`id("xend-relocation-ssl-server"), `opt(`notify), _("Enable"))),
+ `VStretch()
+ )
+ ),
+ `Frame(_("Firewall"),
+ `VBox(
+ "fw-xend",
+ `VStretch()
+ )
+ )
+ );
+}
+
+term KVMConfigurationDialogContent () {
+ return `VBox(
+ `Frame(_("Tunneled migration"),
+ `VBox(
+ `Left(`CheckBox(`id("tunneled_migration"),`opt(`notify), _("Make sure tunneled migration works")))
+ )
+ ),
+ `Frame(_("Plain migration"),
+ `VBox(
+ `Left(`CheckBox(`id("plain_migration"), `opt(`notify), _("Make sure plain migration works"))),
+ `VSpacing(),
+ `Left(`Label(_("TCP Ports"))),
+ `Left(
+ `MinSize( 40, 5,
+ /* A table header */
+ `Table(`id("Port"), `header(_("Port")), [])
+ )),
+ `Left (`HBox (
+ /* a push button */
+ `PushButton(`id("add_port"), _("&Add...")),
+ /* a push button */
+ `PushButton(`id("edit_port"), _("&Edit...")),
+ /* a push button */
+ `PushButton(`id("delete_port"), _("&Delete"))
+ )),
+ `Left(`CheckBox(`id("default_port_range"), `opt(`notify), _("Include default port range")))
+ )
+ ),
+ `Frame(_("Firewall"),
+ `VBox(
+ "fw-kvm"
+ )
+ )
+ );
+}
+/* EOF */
+}
Added: trunk/vm/src/helps.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/src/helps.ycp?rev=64301&view=auto
==============================================================================
--- trunk/vm/src/helps.ycp (added)
+++ trunk/vm/src/helps.ycp Fri Jun 10 08:54:17 2011
@@ -0,0 +1,75 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/relocation-server/helps.ycp
+ * Package: Configuration of relocation-server
+ * Summary: Help texts of all the dialogs
+ * Authors: Li Dongyang
+ *
+ * $Id: helps.ycp 27914 2006-02-13 14:32:08Z locilka $
+ */
+
+{
+
+textdomain "relocation-server";
+
+/**
+ * All helps are here
+ */
+map HELPS = $[
+
+ /* Read dialog help 1/2 */
+ "read" : _("<p><b><big>Initializing relocation-server Configuration</big></b><br>
+Please wait...<br></p>
+") +
+
+ /* Read dialog help 2/2 */
+ _("<p><b><big>Aborting Initialization:</big></b><br>
+Safely abort the configuration utility by pressing <b>Abort</b> now.</p>
+"),
+
+ /* Write dialog help 1/2 */
+ "write" : _("<p><b><big>Saving relocation-server Configuration</big></b><br>
+Please wait...<br></p>
+") +
+
+ /* Write dialog help 2/2 */
+_("<p><b><big>Aborting Saving:</big></b><br>
+Abort the save procedure by pressing <b>Abort</b>.
+An additional dialog informs whether it is safe to do so.
+</p>
+"),
+
+ "xend_configuration" : _("<p><b>Relocation Address</b><br>
+Address xend should listen on for relocation-socket connections</p>
+<p><b>Allowed Hosts</b><br>
+The hosts allowed to talk to the relocation port. If this is empty, then all connections are allowed. Otherwise, this should be a space-separated sequence of regular expressions. Any host with a fully-qualified domain name or an IP address that matches one of these regular expressions will be accepted.</p>
+<p><b>SSL Key File/SSL Cert File</b><br>
+SSL key and certificate to use for the ssl relocation interface</p>"),
+
+ "kvm_configuration" : _("<p><b><big>Tunneled migration</big></b><br>
+The source host libvirtd opens a direct connection to the destination host libvirtd for sending migration data. This allows the option of encrypting the data stream.</p>
+<p><b><big>Plain migration</big></b><br>
+The source host VM opens a direct unencryptyed TCP connection to the destination host for sending the migration data. Unless a port is manually specified, libvirt will choose a migration port in the default range.</p>"),
+];
+
+/* EOF */
+}
Added: trunk/vm/src/relocation-server.desktop
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/src/relocation-server.desktop?rev=64301&view=auto
==============================================================================
--- trunk/vm/src/relocation-server.desktop (added)
+++ trunk/vm/src/relocation-server.desktop Fri Jun 10 08:54:17 2011
@@ -0,0 +1,25 @@
+[Desktop Entry]
+Type=Application
+Categories=Settings;System;Qt;X-SuSE-YaST;X-SuSE-YaST-Virtualization;
+
+X-KDE-ModuleType=Library
+X-KDE-RootOnly=true
+X-KDE-HasReadOnlyMode=true
+X-KDE-Library=yast2
+X-SuSE-YaST-Call=relocation-server
+
+X-SuSE-YaST-Group=Virtualization
+X-SuSE-YaST-Argument=
+X-SuSE-YaST-RootOnly=true
+X-SuSE-YaST-AutoInst=
+X-SuSE-YaST-Geometry=
+X-SuSE-YaST-SortKey=
+X-SuSE-YaST-AutoInstResource=
+
+Icon=yast-vm-install
+Exec=/sbin/yast2 relocation-server
+
+Name=Relocation Server Configuration
+GenericName=relocation-server
+X-KDE-SubstituteUID=true
+StartupNotify=true
Added: trunk/vm/src/relocation-server.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/src/relocation-server.ycp?rev=64301&view=auto
==============================================================================
--- trunk/vm/src/relocation-server.ycp (added)
+++ trunk/vm/src/relocation-server.ycp Fri Jun 10 08:54:17 2011
@@ -0,0 +1,101 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: clients/relocation-server.ycp
+ * Package: Configuration of relocation-server
+ * Summary: Main file
+ * Authors: Li Dongyang
+ *
+ * $Id: relocation-server.ycp 27914 2006-02-13 14:32:08Z locilka $
+ *
+ * Main file for relocation-server configuration. Uses all other files.
+ */
+
+{
+
+/***
+ * <h3>Configuration of relocation-server</h3>
+ */
+
+textdomain "relocation-server";
+
+/* The main () */
+y2milestone ("----------------------------------------");
+y2milestone ("RelocationServer module started");
+
+import "Progress";
+import "Report";
+import "Summary";
+import "VM_XEN";
+import "Arch";
+
+import "CommandLine";
+include "relocation-server/wizards.ycp";
+
+// check whether VM can be started
+boolean CheckConfiguration() {
+
+ boolean ret = true;
+
+ // check whether VM can be started (cannot start a vm using UML)
+ if ( VM_XEN::isUML() ) return false;
+
+ y2milestone("Checking for Xen installation");
+
+ // check the dom0 configuration...
+ ret = ret && VM_XEN::ConfigureDom0();
+ if (ret == false) return false;
+
+ y2milestone("CheckConfiguration returned: %1", ret);
+ return ret;
+}
+
+
+map cmdline_description = $[
+ "id" : "relocation-server",
+ /* Command line help text for the relocation-server module */
+ "help" : _("Configuration of relocation-server"),
+ "guihandler" : RelocationServerSequence,
+ "initialize" : RelocationServer::Read,
+ "finish" : RelocationServer::Write,
+];
+
+if ( !Arch::is_kvm() && !Arch::is_xen0() ) {
+ y2milestone("No hypervisor found, offer to install one");
+ cmdline_description["guihandler"] = CheckConfiguration;
+ remove(cmdline_description, "initialize");
+ remove(cmdline_description, "finish");
+}
+
+/* main ui function */
+any ret = nil;
+
+ret = CommandLine::Run(cmdline_description);
+y2debug("ret=%1", ret);
+
+/* Finish */
+y2milestone("RelocationServer module finished");
+y2milestone("----------------------------------------");
+
+return ret;
+
+/* EOF */
+}
Added: trunk/vm/src/wizards.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/vm/src/wizards.ycp?rev=64301&view=auto
==============================================================================
--- trunk/vm/src/wizards.ycp (added)
+++ trunk/vm/src/wizards.ycp Fri Jun 10 08:54:17 2011
@@ -0,0 +1,171 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/relocation-server/wizards.ycp
+ * Package: Configuration of relocation-server
+ * Summary: Wizards definitions
+ * Authors: Li Dongyang
+ *
+ * $Id: wizards.ycp 27914 2006-02-13 14:32:08Z locilka $
+ */
+
+{
+
+textdomain "relocation-server";
+
+import "Arch";
+import "Sequencer";
+import "Wizard";
+import "CWM";
+import "CWMTab";
+import "CWMServiceStart";
+import "CWMFirewallInterfaces";
+
+include "relocation-server/complex.ycp";
+include "relocation-server/dialogs.ycp";
+
+/**
+ * Main workflow of the relocation-server configuration
+ * @return sequence result
+ */
+any MainSequence() {
+
+ map > widgets = $[
+ "fw-xend" : CWMFirewallInterfaces::CreateOpenFirewallWidget ($[
+ "services" : [ "service:xend-relocation-server" ],
+ "display_details" : true,
+ ]),
+ "xend" : $[
+ "widget" : `custom,
+ "help" : HELPS["xend_configuration"]:"",
+ "custom_widget" : XendConfigurationDialogContent(),
+ "handle" : HandleXendConfigurationDialog,
+ "init" : InitXendConfigurationDialog,
+ "store" : StoreXendConfigurationDialog,
+ ],
+ "kvm" : $[
+ "widget" : `custom,
+ "help" : HELPS["kvm_configuration"]:"",
+ "custom_widget" : KVMConfigurationDialogContent(),
+ "handle" : HandleKVMConfigurationDialog,
+ "init" : InitKVMConfigurationDialog,
+ "store" : StoreKVMConfigurationDialog,
+ ],
+ "fw-kvm" : CWMFirewallInterfaces::CreateOpenFirewallWidget ($[
+ "services" : [ "service:libvirtd-relocation-server", "service:sshd" ],
+ "display_details" : true,
+ ]),
+ ];
+
+ map tabs = $[
+ "xend_configuration" : $[
+ "header" : _("&Xend"),
+ "widget_names" : ["xend", "fw-xend"],
+ "contents" : XendConfigurationDialogContent(),
+ ],
+ "kvm_configuration" : $[
+ "header" : _("&KVM"),
+ "widget_names" : ["kvm", "fw-kvm",],
+ "contents" : KVMConfigurationDialogContent(),
+ ],
+ ];
+
+ if ( !Arch::is_xen0() )
+ remove(tabs, "xend_configuration");
+ else
+ remove(tabs, "kvm_configuration");
+
+ map wd_arg = $[
+ "tab_order" : ["xend_configuration"],
+ "tabs" : tabs,
+ "widget_descr" : widgets,
+ "initial_tab" : "xend_configuration",
+ ];
+
+ if ( !Arch::is_xen0() ) {
+ wd_arg["tab_order"] = ["kvm_configuration"];
+ wd_arg["initial_tab"] = "kvm_configuration";
+ }
+
+ map wd = $[
+ "tab" : CWMTab::CreateWidget (wd_arg),
+ ];
+
+ term contents = `VBox("tab");
+
+ list