home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / root / usr / share / YaST2 / clients / xen_auto.ycp < prev    next >
Text File  |  2006-11-29  |  11KB  |  257 lines

  1. /**
  2.  * File:
  3.  *   xen_auto.ycp
  4.  *
  5.  * Package:
  6.  *   Configuration of Xen virtual machine - AutoYaST client
  7.  *
  8.  * Summary:
  9.  *   Client for autoinstallation
  10.  *
  11.  * Authors:
  12.  *   Ladislav Slez├ík <lslezak@suse.cz>
  13.  *   Michael G. Fritch <mgfritch@novell.com>
  14.  *
  15.  * $Id$
  16.  *
  17.  * This is a client for autoinstallation. It takes its arguments,
  18.  * goes through the configuration and return the setting.
  19.  * Does not do any changes to the configuration.
  20.  */
  21.  
  22. {
  23.     textdomain "vm";
  24.  
  25.     y2milestone("----------------------------------------");
  26.     y2milestone("Xen auto started");
  27.  
  28.     import "Summary";
  29.     import "VM";
  30.     import "VM_Common";
  31.  
  32.     // set virtualization type here
  33.     VM::SetVMMtype("xen");
  34.  
  35.     any ret = nil;
  36.     string func = "";
  37.     map param = $[];
  38.  
  39.     /* Check arguments */
  40.     if (size(WFM::Args()) > 0 && is(WFM::Args(0), string)) {
  41.     func = (string) WFM::Args(0);
  42.     if(size(WFM::Args()) > 1 && is(WFM::Args(1), map))
  43.         param = (map) WFM::Args(1);
  44.     }
  45.     y2debug("func=%1", func);
  46.     y2debug("param=%1", param);
  47.  
  48.  
  49.  
  50.     /* Create a  summary*/
  51.     if (func == "Import") {
  52.     ret = VM::Import(param);
  53.     }
  54.     /* Create a  summary*/
  55.     else if (func == "Summary") {
  56.     string summary_ret = "";
  57.  
  58.     if (VM_Common::autoyast_profile_settings == nil || size(VM_Common::autoyast_profile_settings) <= 0) {
  59.         summary_ret = Summary::NotConfigured();
  60.     }
  61.     else {
  62.  
  63.         // Generate the "Virtual Machine (Installation Settings)" proposal - proposal_mode == "install"
  64.         if ( VM_Common::autoyast_profile_settings["install"]:nil != nil && size(VM_Common::autoyast_profile_settings["install"]:$[]) > 0 ) {
  65.  
  66.             //load the saved AutoYaST profile settings
  67.             VM_Common::proposal_type = "install";
  68.             VM::Import(VM_Common::autoyast_profile_settings);
  69.     
  70.             // NOTE: don't show AutoYaST in the summary, in AutoYaST config mode it doesn't make sense
  71.             map proposal = (map)WFM::CallFunction("xen_mode_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  72.             string xen_mode = proposal["preformatted_proposal"]:"";
  73.             proposal = (map)WFM::CallFunction("xen_mode_proposal", ["Description", $[]]);
  74.             string xen_mode_title = proposal["rich_text_title"]:"";
  75.     
  76.             proposal = (map)WFM::CallFunction("vm_options_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  77.             string vm_options = proposal["preformatted_proposal"]:"";
  78.             proposal = (map)WFM::CallFunction("vm_options_proposal", ["Description", $[]]);
  79.             string vm_options_title = proposal["rich_text_title"]:"";
  80.     
  81.             proposal = (map)WFM::CallFunction("vm_hardware_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  82.             string vm_hardware = proposal["preformatted_proposal"]:"";
  83.             proposal = (map)WFM::CallFunction("vm_hardware_proposal", ["Description", $[]]);
  84.             string vm_hardware_title = proposal["rich_text_title"]:"";
  85.     
  86.             proposal = (map)WFM::CallFunction("vm_disks_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  87.             string vm_disks = proposal["preformatted_proposal"]:"";
  88.             proposal = (map)WFM::CallFunction("vm_disks_proposal", ["Description", $[]]);
  89.             string vm_disks_title = proposal["rich_text_title"]:"";
  90.     
  91.             proposal = (map)WFM::CallFunction("vm_network_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  92.             string vm_network = proposal["preformatted_proposal"]:"";
  93.             proposal = (map)WFM::CallFunction("vm_network_proposal", ["Description", $[]]);
  94.             string vm_network_title = proposal["rich_text_title"]:"";
  95.     
  96.             proposal = (map)WFM::CallFunction("vm_source_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  97.             string vm_source = proposal["preformatted_proposal"]:"";
  98.             proposal = (map)WFM::CallFunction("vm_source_proposal", ["Description", $[]]);
  99.             string vm_source_title = proposal["rich_text_title"]:"";
  100.     
  101.     
  102.             summary_ret = summary_ret + "<p><h2><b>" + _("Virtual Machine (Installation Settings)") + "</b></h2></p>"
  103.                 + "<p><h3><b>" + xen_mode_title    + "</b></h3></p>" + xen_mode
  104.                 + "<p><h3><b>" + vm_options_title  + "</b></h3></p>" + vm_options
  105.                 + "<p><h3><b>" + vm_hardware_title + "</b></h3></p>" + vm_hardware
  106.                 + "<p><h3><b>" + vm_disks_title    + "</b></h3></p>" + vm_disks
  107.                 + "<p><h3><b>" + vm_network_title  + "</b></h3></p>" + vm_network
  108.                 + "<p><h3><b>" + vm_source_title   + "</b></h3></p>" + vm_source;
  109.         }
  110.     
  111.         // Generate the "Virtual Machine (Final Settings)" proposal - proposal_mode == "boot"
  112.         if (VM_Common::autoyast_profile_settings != nil && VM_Common::autoyast_profile_settings["boot"]:nil != nil && size(VM_Common::autoyast_profile_settings["boot"]:$[]) > 0) {
  113.     
  114.             //load the saved AutoYaST profile settings
  115.             VM_Common::proposal_type = "boot";
  116.             VM::Import(VM_Common::autoyast_profile_settings);
  117.     
  118.             // NOTE: don't show AutoYaST in the summary, in AutoYaST config mode it doesn't make sense
  119.             map proposal = (map)WFM::CallFunction("vm_options_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  120.             string vm_options = proposal["preformatted_proposal"]:"";
  121.             proposal = (map)WFM::CallFunction("vm_options_proposal", ["Description", $[]]);
  122.             string vm_options_title = proposal["rich_text_title"]:"";
  123.     
  124.             proposal = (map)WFM::CallFunction("vm_hardware_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  125.             string vm_hardware = proposal["preformatted_proposal"]:"";
  126.             proposal = (map)WFM::CallFunction("vm_hardware_proposal", ["Description", $[]]);
  127.             string vm_hardware_title = proposal["rich_text_title"]:"";
  128.  
  129.             // FIXME: disk proposal should not show when in proposal_type "boot".  Why is it in the control.xml???    
  130. //            proposal = (map)WFM::CallFunction("vm_disks_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  131. //            string vm_disks = proposal["preformatted_proposal"]:"";
  132. //            proposal = (map)WFM::CallFunction("vm_disks_proposal", ["Description", $[]]);
  133. //            string vm_disks_title = proposal["rich_text_title"]:"";
  134.     
  135.             proposal = (map)WFM::CallFunction("vm_network_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  136.             string vm_network = proposal["preformatted_proposal"]:"";
  137.             proposal = (map)WFM::CallFunction("vm_network_proposal", ["Description", $[]]);
  138.             string vm_network_title = proposal["rich_text_title"]:"";
  139.     
  140.             proposal = (map)WFM::CallFunction("vm_source_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  141.             string vm_source = proposal["preformatted_proposal"]:"";
  142.             proposal = (map)WFM::CallFunction("vm_source_proposal", ["Description", $[]]);
  143.             string vm_source_title = proposal["rich_text_title"]:"";
  144.     
  145.     
  146.             summary_ret = summary_ret + "<br><p><h2><b>" + _("Virtual Machine (Final Settings)") + "</b></h2></p>"
  147.                 + "<p><h3><b>" + vm_options_title  + "</b></h3></p>" + vm_options
  148.                 + "<p><h3><b>" + vm_hardware_title + "</b></h3></p>" + vm_hardware
  149. //                + "<p><h3><b>" + vm_disks_title    + "</b></h3></p>" + vm_disks
  150.                 + "<p><h3><b>" + vm_network_title  + "</b></h3></p>" + vm_network
  151.                 + "<p><h3><b>" + vm_source_title   + "</b></h3></p>" + vm_source;
  152.         }
  153.     
  154.         // Generate the "Virtual Machine (Final Settings)" proposal - proposal_mode == "existing"
  155.         if (VM_Common::autoyast_profile_settings != nil && VM_Common::autoyast_profile_settings["existing"]:nil != nil && size(VM_Common::autoyast_profile_settings["existing"]:$[]) > 0) {
  156.     
  157.             //load the saved AutoYaST profile settings
  158.             VM_Common::proposal_type = "existing";
  159.             VM::Import(VM_Common::autoyast_profile_settings);
  160.     
  161.             // NOTE: don't show AutoYaST in the summary, in AutoYaST config mode it doesn't make sense
  162.             map proposal = (map)WFM::CallFunction("xen_mode_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  163.             string xen_mode = proposal["preformatted_proposal"]:"";
  164.             proposal = (map)WFM::CallFunction("xen_mode_proposal", ["Description", $[]]);
  165.             string xen_mode_title = proposal["rich_text_title"]:"";
  166.     
  167.             proposal = (map)WFM::CallFunction("vm_options_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  168.             string vm_options = proposal["preformatted_proposal"]:"";
  169.             proposal = (map)WFM::CallFunction("vm_options_proposal", ["Description", $[]]);
  170.             string vm_options_title = proposal["rich_text_title"]:"";
  171.     
  172.             proposal = (map)WFM::CallFunction("vm_hardware_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  173.             string vm_hardware = proposal["preformatted_proposal"]:"";
  174.             proposal = (map)WFM::CallFunction("vm_hardware_proposal", ["Description", $[]]);
  175.             string vm_hardware_title = proposal["rich_text_title"]:"";
  176.     
  177.             proposal = (map)WFM::CallFunction("vm_disks_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  178.             string vm_disks = proposal["preformatted_proposal"]:"";
  179.             proposal = (map)WFM::CallFunction("vm_disks_proposal", ["Description", $[]]);
  180.             string vm_disks_title = proposal["rich_text_title"]:"";
  181.     
  182.             proposal = (map)WFM::CallFunction("vm_network_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  183.             string vm_network = proposal["preformatted_proposal"]:"";
  184.             proposal = (map)WFM::CallFunction("vm_network_proposal", ["Description", $[]]);
  185.             string vm_network_title = proposal["rich_text_title"]:"";
  186.     
  187.             proposal = (map)WFM::CallFunction("vm_source_proposal", ["MakeProposal", $["force_reset":false, "language_changed":false]]);
  188.             string vm_source = proposal["preformatted_proposal"]:"";
  189.             proposal = (map)WFM::CallFunction("vm_source_proposal", ["Description", $[]]);
  190.             string vm_source_title = proposal["rich_text_title"]:"";
  191.     
  192.     
  193.             summary_ret = summary_ret + "<p><h2><b>" + _("Virtual Machine (Final Settings)") + "</b></h2></p>"
  194.                 + "<p><h3><b>" + xen_mode_title    + "</b></h3></p>" + xen_mode
  195.                 + "<p><h3><b>" + vm_options_title  + "</b></h3></p>" + vm_options
  196.                 + "<p><h3><b>" + vm_hardware_title + "</b></h3></p>" + vm_hardware
  197.                 + "<p><h3><b>" + vm_disks_title    + "</b></h3></p>" + vm_disks
  198.                 + "<p><h3><b>" + vm_network_title  + "</b></h3></p>" + vm_network
  199.                 + "<p><h3><b>" + vm_source_title   + "</b></h3></p>" + vm_source;
  200.         }
  201.     }
  202.  
  203.     y2milestone("proposal: %1", summary_ret);
  204.     ret = summary_ret;
  205.     }
  206.     else if (func == "GetModified") {
  207.     ret = VM_Common::GetModified();
  208.     }
  209.     else if (func == "SetModified") {
  210.     VM_Common::SetModified(true);
  211.     ret = true;
  212.     }
  213.     /* Reset configuration */
  214.     else if (func == "Reset") {
  215.     // reset the configuration (propose new config)
  216.     VM_Common::proposal_type = "install";
  217.     VM_Common::autoyast_profile_settings = $[];
  218.     VM::ResetAllSettings();
  219.  
  220.     ret = $[];
  221.     }
  222.     /* Change the configuration */
  223.     else if (func == "Change") {
  224.     ret = WFM::CallFunction("xen", [] );
  225.     }
  226.     /* Return required package list */
  227.     else if (func == "Packages") {
  228.     ret = $[];
  229.     }
  230.     /* Return actual state */
  231.     else if (func == "Export") {
  232.     ret = VM::Export();
  233.     }
  234.     else if (func == "Read") {
  235.     ret = false;
  236.     y2warning("Read handler is not implemented");
  237.     }
  238.     /* Write given settings */
  239.     else if (func == "Write") {
  240.     ret = false;
  241.     y2warning("Write handler is not implemented");
  242.     }
  243.     /* Unknown function */
  244.     else {
  245.     y2error("Unknown function: %1", func);
  246.     ret = false;
  247.     }
  248.  
  249.     y2debug("ret=%1", ret);
  250.     y2milestone("Xen auto finished");
  251.     y2milestone("----------------------------------------");
  252.  
  253.     return ret;
  254.  
  255.     /* EOF */
  256. }
  257.