YaST2 Developers Documentation: Backup module

Backup module

functions.ycp
Functions used by backup module.

Imports

  • AutoinstClone
  • FileSystems
  • FileUtils
  • Label
  • Mode
  • Nfs
  • Popup
  • Profile
  • Report
  • Storage

Local Functions

local AbortConfirmation (symbol type) -> boolean

Display abort confirmation dialog

Parameters:
type Select dialog type, possible values: `changed, `not_changed or `none for none dialog
Return value:
False if user select to not abort, true otherwise.
local ShowEditDialog (string label, string value, list<string> values) -> map

Ask user for some value: display dialog with label, text entry and OK/Cancel buttons.

Parameters:
label Displayed text above the text entry in the dialog
value Default text in text entry, for empty text set value to "" or nil
values
Return value:
Returned map: $[ "text" : string, "clicked" : symbol ]. Value with key text is string entered by user, symbol is `ok or `cancel depending which button was pressed.
local GetMountedFilesystems () -> list<string>

Returns list of mounted file systems types.

Return value:
List of strings, each mounted file system type is reported only onetimes, list is alphabetically sorted.
Example
 GetMountedFilesystems() -> [ "devpts", "ext2", "nfs", "proc", "reiserfs" ]
local Ext2Filesystems () -> list<map<string, any> >

Returns list of Ext2 mountpoints - actually mounted and from /etc/fstab file

Return value:
List of strings
Example
 Ext2Filesystems() -> [ "/dev/hda1", "/dev/hda4" ]
local GetListWithFlags (list<string> in, list<string> selected) -> list<term>

This function reads two lists: full list and selection list (contains subset of items in full list). Returned list can be used in MultiSelectionBox widget.

Parameters:
in List of items
selected List with subset of items from list in.
Return value:
List of alphabetically sorted strings
Example
 GetListWithFlags(["/dev", "/etc"], ["/etc"]) -> [`item (`id ("/dev"), "/dev", false), `item (`id ("/etc"), "/etc", true)]
local AddIdBool (list in, boolean val) -> list<term>

Set boolean value val to all items in list.

Parameters:
in Input list of items
val Requested value
Return value:
List of items
Example
 AddIdBool( [ `item(`id("ext2"), "ext2", true) ], false) ) -> [ `item (`id ("ext2"), "ext2", false) ]
local AddId (list<string> in) -> list<term>

Returns list of items from list of values.

Parameters:
in Input list of values
Return value:
List of items
Example
 AddId("abc", "123") -> [`item(`id("abc"), "abc"), `item(`id("123"), "123")]
local AddIdExt2 (list<map<string, any> > in) -> list<term>

Returns list of items from list of values.

Parameters:
in Input list of maps with keys "partition", "mountpoints" and strings as values
Return value:
List of items
Example
 AddId([ $["partition" : "/dev/hda3", "mountpoint" : "/usr"] ]) -> [`item(`id("/dev/hda3"), "/dev/hda3", "/usr")]
local MediaList2UIList (list<map<string, any> > media) -> list<term>

Convert media description list to ComboBox items list

Parameters:
media Medium descriptions - list of maps with keys (and values): "label" (description string), "symbol" (identification symbol), "capacity" (size of free space on empty medium)
Return value:
Items list for UI widgets
local SetMultiWidgetsState () -> void

Set state of depending widgets in Multiple volume options dialog

local Ext2MountPoint (string device_name) -> string

Return mount point for Ext2 partition. This function at first checks if partition is mounted. If yes it returns actual mout point, if no it searches mount point from /etc/fstab file.

Parameters:
device_name Name of device
Return value:
Mount point of device or nil if device does not exist or there is other file system than Ext2
Example
 Ext2MountPoint("/dev/hda1") -> "/boot"
local AddMissingExtension (string file, string extension) -> string

Add extension to the file name if it is missing.

Parameters:
file filname
extension file extension (with dot)
Return value:
filename with extension
Example
 AddMissingExtension("filename", ".ext") -> "filename.ext"
 AddMissingExtension("filename.tar", ".gz") -> "filename.tar.gz"
 AddMissingExtension("filename.tar", ".tar") -> "filename.tar"
local GetBaseName (string file) -> string

Get base file name without extension

Parameters:
file file name
Return value:
base file name
Example
 GetBaseName("file.ext") -> "file"
 GetBaseName("file") -> "file"
 GetBaseName("dir/file.ext") -> "file"
local SendMail (string user, string subject, string message) -> boolean

Send mail to specified user

Parameters:
user Target email address
subject Subject string
message Message body
Return value:
True on success
local CreateUnderLine (string input, string ch) -> string

Create string from character ch with the same lenght as input

Parameters:
input Input string
ch String used in output
Return value:
String containg size(input) character
local SendSummary (map remove_result, string cron_profile, string backup_result, string backup_details) -> boolean

Send summary mail of the backup process to root.

Parameters:
remove_result Result of removing/renaming of the old archives
cron_profile
backup_result
backup_details
Return value:
True on success
local SecondsToDateString (integer sec) -> string

Convert number of second since 1.1.1970 to string. Result has format YYYYMMDDHHMMSS

Parameters:
sec Number of seconds
Return value:
String representation of the time, returns input value (sec) if an error occured
local GetInstallPackages () -> list<string>

Read packages available on the installation sources (Requires at least one installation source, otherwise return empty list)

Return value:
available packages
local CloneSystem (string filename, list<string> additional, string extra_key, map extra_options) -> boolean

Store autoyast profile of the system to file

Parameters:
filename where setting will be saved
additional additional part of system to clone
extra_key name of the extra configuration
extra_options options for extra_key
Return value:
true on success
local DetectMountpoints () -> map

Detect mount points

Return value:
map of mount points
local MpointTableContents (list<string> selected, list<string> all, map<string,map> description) -> list

Create table content with detected mount points

Parameters:
selected selected mount points to use
all all detected mount points + user defined dirs
description detected mount points
Return value:
table content
local NFSFileExists (string server, string share, string filename) -> boolean

Check whether file on the NFS server exists

Parameters:
server remote server name
share exported directory
filename name of the file
Return value:
true - file exists, false - file doesn't exist, nil - error (mount failed)
local NFSfile (string server, string share, string filename) -> string

Create NFS file description string

Parameters:
server server name
share exported directory name
filename remote file name
Return value:
result (nil if any of the parameter is nil)
local get_free_space (string directory) -> map

Get available space in the directory

Parameters:
directory selected directory
Return value:
on success returns parsed df output in a map $["device" : string(device), "total" : integer(total), "used" : integer(used), "free" : integer(free) ]