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
/
modules
/
VM.ycp
< prev
next >
Wrap
Text File
|
2006-11-29
|
23KB
|
1,086 lines
/**
* File: modules/VM.ycp
* Package: VM configuration - generic module
* Authors: Ladislav Slezak <lslezak@suse.cz>
* Michael G. Fritch <mgfritch@novell.com>
*
* $Id: VM.ycp 32320 2006-08-10 18:08:16Z mgfritch $
*/
{
module "VM";
textdomain "vm";
import "VM_Common";
map functions = $[];
string vmmtype = "";
boolean CallBooleanFunction(string name) {
boolean() toEval = (boolean())functions[name]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("%1() function is missing!", name);
return nil;
}
}
boolean CallBooleanStringFunction(string name, string arg) {
boolean(string) toEval = (boolean(string))functions[name]:nil;
if (toEval != nil)
{
return toEval(arg);
}
else
{
y2error("%1() function is missing!", name);
return nil;
}
}
boolean CallBooleanBooleanFunction(string name, boolean arg) {
boolean(boolean) toEval = (boolean(boolean))functions[name]:nil;
if (toEval != nil)
{
return toEval(arg);
}
else
{
y2error("%1() function is missing!", name);
return nil;
}
}
string CallStringFunction(string name) {
string() toEval = (string())functions[name]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("%1() function is missing!", name);
return nil;
}
}
// initializes the module, must be called as the first function
global boolean SetVMMtype(string vmm) {
if (vmm == "xen")
{
import "VM_XEN";
functions = VM_XEN::GetFunctions();
vmmtype = vmm;
}
else
{
y2error("unsupported VMM type: %1", vmm);
return false;
}
return true;
}
global string GetVMMtype() {
return vmmtype;
}
global string GetConfigFilePath() {
string() toEval = (string())functions["getConfigFilePath"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getConfigFilePath() function is missing!");
return nil;
}
}
global integer GetMemorySize() {
integer() toEval = (integer())functions["getMemorySize"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getMemorySize() function is missing!");
return nil;
}
}
global boolean SetMemorySize(integer msize) {
boolean(integer) toEval = (boolean(integer))functions["setMemorySize"]:nil;
if (toEval != nil)
{
return toEval(msize);
}
else
{
y2error("setMemorySize() function is missing!");
return nil;
}
}
global boolean ResetMemorySize() {
return CallBooleanFunction("resetMemorySize");
}
global boolean IsXendRunning() {
return CallBooleanFunction("isXendRunning");
}
global string GetXMInfo(string key) {
string(string) toEval = (string(string))functions["getXMInfo"]:nil;
if (toEval != nil)
{
return toEval(key);
}
else
{
y2error("getXMInfo() function is missing!");
return nil;
}
}
global integer GetMaxFreeMemory() {
integer() toEval = (integer())functions["getMaxFreeMemory"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getMaxFreeMemory() function is missing!");
return nil;
}
}
global integer GetMaxParaMemory() {
integer() toEval = (integer())functions["getMaxParaMemory"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getMaxParaMemory() function is missing!");
return nil;
}
}
global integer GetMaxHVMMemory() {
integer() toEval = (integer())functions["getMaxHVMMemory"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getMaxHVMMemory() function is missing!");
return nil;
}
}
global integer GetNumberOfCpus() {
integer() toEval = (integer())functions["getNumberOfCpus"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getNumberOfCpus() function is missing!");
return nil;
}
}
global boolean SetNumberOfCpus(integer msize) {
boolean(integer) toEval = (boolean(integer))functions["setNumberOfCpus"]:nil;
if (toEval != nil)
{
return toEval(msize);
}
else
{
y2error("setNumberOfCpus() function is missing!");
return nil;
}
}
global boolean ResetNumberOfCpus() {
return CallBooleanFunction("resetNumberOfCpus");
}
global integer GetNE2000() {
integer() toEval = (integer())functions["getNE2000"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getNE2000() function is missing!");
return nil;
}
}
global boolean SetNE2000(integer msize) {
boolean(integer) toEval = (boolean(integer))functions["setNE2000"]:nil;
if (toEval != nil)
{
return toEval(msize);
}
else
{
y2error("setNE2000() function is missing!");
return nil;
}
}
global boolean ResetNE2000() {
return CallBooleanFunction("resetNE2000");
}
global integer GetStdVga() {
integer() toEval = (integer())functions["getStdVga"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getStdVga() function is missing!");
return nil;
}
}
global boolean SetStdVga(integer msize) {
boolean(integer) toEval = (boolean(integer))functions["setStdVga"]:nil;
if (toEval != nil)
{
return toEval(msize);
}
else
{
y2error("setStdVga() function is missing!");
return nil;
}
}
global boolean ResetStdVga() {
return CallBooleanFunction("resetStdVga");
}
global integer GetSdl() {
integer() toEval = (integer())functions["getSdl"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getSdl() function is missing!");
return nil;
}
}
global boolean SetSdl(integer msize) {
boolean(integer) toEval = (boolean(integer))functions["setSdl"]:nil;
if (toEval != nil)
{
return toEval(msize);
}
else
{
y2error("setSdl() function is missing!");
return nil;
}
}
global boolean ResetSdl() {
return CallBooleanFunction("resetSdl");
}
global integer GetLocaltime() {
integer() toEval = (integer())functions["getLocaltime"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getLocaltime() function is missing!");
return nil;
}
}
global boolean SetLocaltime(integer msize) {
boolean(integer) toEval = (boolean(integer))functions["setLocaltime"]:nil;
if (toEval != nil)
{
return toEval(msize);
}
else
{
y2error("setLocaltime() function is missing!");
return nil;
}
}
global boolean ResetLocaltime() {
return CallBooleanFunction("resetLocaltime");
}
global boolean ResetNetworkProposal() {
return CallBooleanFunction("resetNetworkConfig");
}
global string GetStartMode() {
return CallStringFunction("getStartMode");
}
global list<string> GetNetworkProposal() {
list<string>() toEval = (list<string>())functions["getNetworkProposal"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getNetworkProposal() function is missing!");
return nil;
}
}
global boolean SetStartMode(string smode) {
return CallBooleanStringFunction("setStartMode", smode);
}
global boolean ResetStartMode() {
return CallBooleanFunction("resetStartMode");
}
global string GetOnPowerOff() {
return CallStringFunction("getOnPowerOff");
}
global boolean SetOnPowerOff(string smode) {
return CallBooleanStringFunction("setOnPowerOff", smode);
}
global string GetOnReboot() {
return CallStringFunction("getOnReboot");
}
global boolean SetOnReboot(string smode) {
return CallBooleanStringFunction("setOnReboot", smode);
}
global string GetOnCrash() {
return CallStringFunction("getOnCrash");
}
global boolean SetOnCrash(string smode) {
return CallBooleanStringFunction("setOnCrash", smode);
}
global string GetExtraArgs() {
return CallStringFunction("getExtraArgs");
}
global boolean SetExtraArgs(string args) {
return CallBooleanStringFunction("setExtraArgs", args);
}
global boolean ResetExtraArgs() {
return CallBooleanFunction("resetExtraArgs");
}
global boolean ResetHiddenArgs() {
return CallBooleanFunction("resetHiddenArgs");
}
global string GetConfigName() {
return CallStringFunction("getConfigName");
}
global boolean SetConfigName(string name) {
return CallBooleanStringFunction("setConfigName", name);
}
global boolean ResetConfigName() {
return CallBooleanFunction("resetConfigName");
}
global boolean ValidateConfigName(string name) {
return CallBooleanStringFunction("ValidateConfigName", name);
}
global string GetMAC() {
return CallStringFunction("getMAC");
}
global boolean SetMAC(string mac) {
return CallBooleanStringFunction("setMAC", mac);
}
global boolean ResetMAC() {
return CallBooleanFunction("resetMAC");
}
global boolean SetHomeDir(string home) {
return CallBooleanStringFunction("setHomeDir", home);
}
global string GetHomeDir() {
return CallStringFunction("getHomeDir");
}
global boolean SetUserName(string user) {
return CallBooleanStringFunction("setUserName", user);
}
global string GetUserName() {
return CallStringFunction("getUserName");
}
global boolean ResetUserName() {
return CallBooleanFunction("resetUserName");
}
global list<map<string,any> > GetDiskConfig() {
list<map<string,any> >() toEval = (list<map<string,any> >())functions["getDiskConfig"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getDiskConfig() function is missing!");
return nil;
}
}
global boolean SetDiskConfig(list<map<string,any> > smode) {
boolean(list<map<string,any> >) toEval = (boolean(list<map<string,any> >))functions["setDiskConfig"]:nil;
if (toEval != nil)
{
return toEval(smode);
}
else
{
y2error("setDiskConfig() function is missing!");
return nil;
}
}
global boolean ResetDiskConfig() {
return CallBooleanFunction("resetDiskConfig");
}
global list<string> GetConfiguredDiskTargets(list<map<string,any> > disks_list) {
list<string>(list<map<string,any> >) toEval = (list<string>(list<map<string,any> >))functions["getConfiguredDiskTargets"]:nil;
if (toEval != nil)
{
return toEval(disks_list);
}
else
{
y2error("getConfiguredDiskTargets() function is missing!");
return nil;
}
}
global list<string> GetConfiguredDiskSources(list<map<string,any> > disks_list) {
list<string>(list<map<string,any> >) toEval = (list<string>(list<map<string,any> >))functions["getConfiguredDiskSources"]:nil;
if (toEval != nil)
{
return toEval(disks_list);
}
else
{
y2error("getConfiguredDiskSources() function is missing!");
return nil;
}
}
global list<string> GetValidVirtualDevices(list<string> used_devices) {
list<string>(list<string>) toEval = (list<string>(list<string>))functions["getValidVirtualDevices"]:nil;
if (toEval != nil)
{
return toEval(used_devices);
}
else
{
y2error("getValidVirtualDevices() function is missing!");
return nil;
}
}
global list<map<string,string> > GetNetworkConfig() {
list<map<string,string> >() toEval = (list<map<string,string> >())functions["getNetworkConfig"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getNetworkConfig() function is missing!");
return nil;
}
}
global boolean SetNetworkConfig(list<map<string,string> > net) {
boolean(list<map<string,string> >) toEval = (boolean(list<map<string,string> >))functions["setNetworkConfig"]:nil;
if (toEval != nil)
{
return toEval(net);
}
else
{
y2error("setNetworkConfig() function is missing!");
return nil;
}
}
global boolean ResetNetworkConfig() {
return CallBooleanFunction("resetNetworkConfig");
}
global list<string> GetDiskProposal() {
list<string>() toEval = (list<string>())functions["getDiskProposal"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getDiskProposal() function is missing!");
return nil;
}
}
global list<string> GetSourceProposal() {
list<string>() toEval = (list<string>())functions["getSourceProposal"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("GetSourceProposal() function is missing!");
return nil;
}
}
global map GetSourceProposalWarning()
{
map() toEval = (map())functions["getSourceProposalWarning"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("GetSourceProposalWarning() function is missing!");
return nil;
}
}
global map GetNetworkProposalWarning()
{
map() toEval = (map())functions["getNetworkProposalWarning"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("GetNetworkProposalWarning() function is missing!");
return nil;
}
}
global boolean ResetSource() {
return CallBooleanFunction("resetSourceConfig");
}
global map<string,any> GetSourceConfig() {
map<string,any>() toEval = (map<string,any>())functions["getSourceConfig"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getSourceConfig() function is missing!");
return nil;
}
}
global boolean SetSourceConfig(integer sid, symbol type, string custom) {
boolean(integer, symbol, string) toEval = (boolean(integer, symbol, string))functions["setSourceConfig"]:nil;
if (toEval != nil)
{
return toEval(sid, type, custom);
}
else
{
y2error("setSourceConfig() function is missing!");
return nil;
}
}
global map getOptionsProposal()
{
map<string,any>() toEval = (map<string,any>())functions["getOptionsProposal"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getOptionsProposal() function is missing!");
return nil;
}
}
global map getHardwareProposal()
{
map<string,any>() toEval = (map<string,any>())functions["getHardwareProposal"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getHardwareProposal() function is missing!");
return nil;
}
}
global boolean Write() {
return CallBooleanFunction("Write");
}
global boolean Prepare() {
return CallBooleanFunction("Prepare");
}
global boolean Prepare2() {
return CallBooleanFunction("Prepare2");
}
global list<map<string,any> > ParseDiskConfig(string diskstr) {
list<map<string,any> >(string) toEval = (list<map<string,any> >(string))functions["parseDiskConfig"]:nil;
if (toEval != nil)
{
return toEval(diskstr);
}
else
{
y2error("parseDiskConfig() function is missing!");
return nil;
}
}
global boolean UpdateDiskConfig(string old_source, string new_source, string type) {
boolean(string, string, string) toEval = (boolean (string, string, string))functions["updateDiskConfig"]:nil;
if (toEval != nil)
{
return toEval(old_source, new_source, type);
}
else
{
y2error("updateDiskConfig() function is missing!");
return nil;
}
}
global string GetDiskSource(list<map<string,any> > disks_list, string source) {
string(list<map<string,any> >, string) toEval = (string (list<map<string,any> >, string))functions["getDiskSource"]:nil;
if (toEval != nil)
{
return toEval(disks_list, source);
}
else
{
y2error("getDiskSource() function is missing!");
return nil;
}
}
global string GetDiskTarget(list<map<string,any> > disks_list, string target) {
string(list<map<string,any> >, string) toEval = (string (list<map<string,any> >, string))functions["getDiskTarget"]:nil;
if (toEval != nil)
{
return toEval(disks_list, target);
}
else
{
y2error("getDiskTarget() function is missing!");
return nil;
}
}
global string GetAutoYastProfile() {
return VM_Common::GetAutoYastProfile();
}
global boolean SetAutoYastProfile(string profile) {
return VM_Common::SetAutoYastProfile(profile);
}
global string GetAutoYastProposal() {
return VM_Common::GetAutoYastProposal();
}
global map<string,any> GetAutoYastProposalWarning()
{
return VM_Common::GetAutoYastProposalWarning();
}
global boolean ResetAutoYastProfile() {
// clear out the stored autoyast settings
VM_Common::autoyast_profile_settings = $[];
// remove any old image
string old_autoyast_image = VM::GetDiskSource(VM::GetDiskConfig(), "hdt63");
if (old_autoyast_image != nil && old_autoyast_image != "") {
VM::UpdateDiskConfig(old_autoyast_image, "", "");
}
return VM_Common::SetAutoYastProfile("");
}
global map ReadConfigFileSettings(string cfg_file) {
map(string) toEval = (map(string))functions["ReadConfigFileSettings"]:nil;
if (toEval != nil)
{
return toEval(cfg_file);
}
else
{
y2error("ReadConfigFileSettings() function is missing!");
return nil;
}
}
global list<map> ReadAllConfigFileSettings() {
list<map>() toEval = (list<map>())functions["ReadAllConfigFileSettings"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("ReadAllConfigFileSettings() function is missing!");
return nil;
}
}
global symbol GetVirtualMachineState(string state) {
symbol(string) toEval = (symbol(string))functions["GetVirtualMachineState"]:nil;
if (toEval != nil)
{
return toEval(state);
}
else
{
y2error("GetVirtualMachineState() function is missing!");
return nil;
}
}
global boolean ViewVirtualMachineConsole(string DomName, boolean isFullVirtualization, boolean isNetWare, boolean background, boolean displayError) {
boolean(string, boolean, boolean, boolean, boolean) toEval = (boolean(string, boolean, boolean, boolean, boolean))functions["ViewVirtualMachineConsole"]:nil;
if (toEval != nil)
{
return toEval(DomName, isFullVirtualization, isNetWare, background, displayError);
}
else
{
y2error("ViewVirtualMachineConsole() function is missing!");
return nil;
}
}
global boolean ShutdownVirtualMachine(string DomName, boolean displayError) {
boolean(string, boolean) toEval = (boolean(string, boolean))functions["ShutdownVirtualMachine"]:nil;
if (toEval != nil)
{
return toEval(DomName, displayError);
}
else
{
y2error("ShutdownVirtualMachine() function is missing!");
return nil;
}
}
global boolean TerminateVirtualMachine(string DomName, boolean displayError) {
boolean(string, boolean) toEval = (boolean(string, boolean))functions["TerminateVirtualMachine"]:nil;
if (toEval != nil)
{
return toEval(DomName, displayError);
}
else
{
y2error("TerminateVirtualMachine() function is missing!");
return nil;
}
}
global boolean StartVirtualMachine(string DomName, boolean displayError) {
boolean(string, boolean) toEval = (boolean(string, boolean))functions["StartVirtualMachine"]:nil;
if (toEval != nil)
{
return toEval(DomName, displayError);
}
else
{
y2error("StartVirtualMachine() function is missing!");
return nil;
}
}
global boolean InstallPackages() {
return CallBooleanFunction("InstallPackages");
}
global string GetTapDevice() {
return CallStringFunction("getTapDevice");
}
global boolean SetTapDevice(string tap) {
return CallBooleanStringFunction("setTapDevice", tap);
}
global string GetNetDevice() {
return CallStringFunction("getNetDevice");
}
global boolean SetNetDevice(string net) {
return CallBooleanStringFunction("setNetDevice", net);
}
global string GetRestart() {
return CallStringFunction("getRestart");
}
global boolean SetRestart(string mode) {
return CallBooleanStringFunction("setRestart", mode);
}
global boolean ResetRestart() {
return CallBooleanFunction("resetRestart");
}
global string GetKernelImage() {
return CallStringFunction("getKernelImage");
}
global boolean SetKernelImage(string img) {
return CallBooleanStringFunction("setKernelImage", img);
}
global string GetInitrdImage() {
return CallStringFunction("getInitrdImage");
}
global boolean SetInitrdImage(string img) {
return CallBooleanStringFunction("setInitrdImage", img);
}
global boolean GetCustomKernel() {
return CallBooleanFunction("getCustomKernel");
}
global boolean SetCustomKernel(boolean use_custom) {
return CallBooleanBooleanFunction("setCustomKernel", use_custom);
}
global boolean Import(map input) {
boolean(map) toEval = (boolean(map))functions["import"]:nil;
if (toEval != nil)
{
return toEval(input);
}
else
{
y2error("import() function is missing!");
return nil;
}
}
global map Export() {
map() toEval = (map())functions["export"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("export() function is missing!");
return nil;
}
}
global map SubExport() {
map() toEval = (map())functions["subexport"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("subexport() function is missing!");
return nil;
}
}
global string GetVirtualizationType() {
return CallStringFunction("getVirtualizationType");
}
global boolean SetVirtualizationType(string type) {
return CallBooleanStringFunction("setVirtualizationType", type);
}
global boolean ResetVirtualizationType() {
return CallBooleanFunction("resetVirtualizationType");
}
global string GetVirtualizationProposal() {
return CallStringFunction("virtualizationTypeProposal");
}
/* global boolean UpdateRoot(string root) {
return CallBooleanStringFunction("updateRoot", root);
}*/
global string GetBootDevice()
{
return CallStringFunction("getBootDevice");
}
global map<string,any> GetDiskProposalWarning()
{
map<string,any>() toEval = (map<string,any>())functions["getDiskProposalWarning"]:nil;
if (toEval != nil)
{
return toEval();
}
else
{
y2error("getDiskProposalWarning() function is missing!");
return nil;
}
}
global string GetImgPrefix()
{
return CallStringFunction("getImgPrefix");
}
global boolean SetImgPrefix(string p) {
return CallBooleanStringFunction("setImgPrefix", p);
}
global boolean ResetAllSettings() {
// must reset all values back to their defaults removing the settings from the last vm
ResetHiddenArgs();
ResetDiskConfig();
ResetSource();
ResetExtraArgs();
ResetConfigName();
// ResetMAC();
// ResetUserName();
ResetNetworkConfig();
// ResetVirtualizationType(); // NOTE: reseting this value causes strange settings since most are calculated based on virtualization type.
ResetAutoYastProfile();
ResetMemorySize();
ResetNumberOfCpus();
ResetNE2000();
ResetStdVga();
ResetSdl();
ResetLocaltime();
ResetNetworkProposal();
ResetStartMode();
VM_Common::SetModified(false);
return true;
}
/* EOF */
}