YaST2 Developers Documentation: Configuration of profile-manager



functions
files
intro

Configuration of profile-manager

modules/ProfileManager.ycp
Data for configuration of profile-manager, input and output funcs.
Representation of the configuration of profile-manager. Input and output routines.

Imports

  • Directory
  • Popup
  • Progress
  • Report
  • Require

Global Variables

Global Functions

Local Variables

Local Functions

global first_time -> boolean

Is the module runing for the first time?

global enabled -> boolean

Is SCPM enabled?

global needs_reinit -> boolean

Is SCPM re-initialization needed? (possibly after update)

global initialized -> boolean

Is SCPM initialized? This is set to true after first enabling.

global close_popups -> boolean

Is set "close popups automaticaly" check?

global auto -> boolean

This shows if the "autoswitch" was set while adding a new profile.

global profiles -> map

Map of actual profiles and its descriptions. It is read in ReadProfiles() and ReadProfilesDescription().

Example:
 
  $[ "default" : "This is the default",
     "home" : "My home profile",
   ...
  ]

global profile_settings -> map

Map of selected profile's settings. It is read in GetProfile() and written in SetProfile().

Example:
 
  $[ "name" : "home",
     "description" : "My home profile",
     "prestart" : "",
     "postart" : "/tmp/poststart_script",
     "prestop" : "",
     "poststop" : ""
  ]

global current_resources -> string

The name of current resource set. It is read in ReadCurrentResource().

global active_profile -> string

This is the name of the active profile. It is read in ReadActiveProfile().

global selected_profile -> string

This is the name of the profile selected in some widget.

global resource_sets_predefined -> list

The list of predefined resource sets.

Example:
 
  [ "typical",
    "network_only"
  ]

global resource_sets_individual -> list

The list of user defined resource sets.

local switch_info -> map

This map represents the switch_info struct. It is read in PrepareSwitch() and used by Switch().

Example:
 
  $[ "profile_name": "home",
     "profile_modified": true,
     "modified_resources":
      [ $[ "resource_name": "/etc/X11/XF86Config",
           "resource_type": "file",
           "is_new": false,
           "is_deleted": true,
           "save": true
        ]
      ]
  ]

global profile_action -> string

This variable defines the action whis will be done with the profile in the ProfileSettingsDialog. Can be "new", "copy" or "edit".

global scpm_error -> string

When scpm action fails, the error message is stored here by SetError()

local state -> map

In this map are written the variables close_popups and first_time. It is read from the file in ReadUserSettings() and written to the file in WriteUserSettings().

local progress_size -> integer

how many lines of progress has been pruducted

global hash_size -> integer

how many times was progress bar used

local progressfile -> string

The name of the file, where the progress state is beeing written. (The same name must use the scpm agent!)

local changesfile -> string

The name of the file, where are written the resource changes. This file is checked after pushing "Show changes" button. (The same name must use the scpm agent!)

global AbortFunction -> block<boolean>

Abort function return boolean return true if abort

global Abort () -> boolean

Abort function

Return value:
blah blah lahjk

local ShowError () -> void

This function is called when some scpm command failed. The error message is read and shown in Popup::Error.

local SetError () -> void

This function is called when some scpm command failed. The error message is read and stored in global variable scpm_error.

local resource_groups -> map

all resource groups available; filled by ReadResourceGroups()

local resource_groups_deleted -> list

list of resource groups marked for deletion

global scpm_conf -> map

this map holds the contents of scpm.conf configuration file

global modified_groups -> map

helper structure for faster querying modified resource groups (prepared for Switch) - is filled in GetModifiedGroups() function

local default_save -> boolean

default value of "save" flags of modified resources (groups) TODO: when is changed?

global canceled -> boolean

if module was canceled (aborted)

global use_rg -> boolean

if scpm supports resource groups

global current_resource_group -> string

name of resource group currently beeing edited (selected in SwitchDialog)

local SetResourceGroup (string groupname, list resources, string descr) -> boolean

Writes modified resource group.

Parameters:
groupname resource group name
resources list of resources belonging to this group
descr group description
Return value:
success

global GetResourceGroupResources (string groupname) -> list

Gets resources of resource group.

Parameters:
groupname resource group name
Return value:
of resources

global ReadResourceGroups () -> boolean

Reads all available resource groups.

Return value:
true on success

global ResetResourceGroups () -> boolean

Resets RG's to default values

Return value:
success

global ResetResourceGroup (string groupname) -> boolean

Resets one resource group to default values

Parameters:
groupname
Return value:
success

global GetResourceGroups () -> map

Returns all available resource groups.

Return value:
of groups

global GroupDeletable (string groupname) -> boolean

Can be resource group deleted by user?

Parameters:
groupname name of group

global GroupnameExists (string groupname) -> boolean

Does given resource group exist? (Checked when user enters name of new group)

Parameters:
groupname name of group

global GetGroup (string groupname) -> map

Returns map resource group

Parameters:
groupname name of group

global MarkGroupDeleted (string groupname) -> void

Marks selected resource group for deletion (will not be shown in list)

Parameters:
groupname name of group

global MarkGroupActive (string groupname) -> boolean

Changes "active" flag of selected resource group to opposite value

Parameters:
groupname name of group
Return value:
new value

global ChangeGroup (map group) -> void

Updates global resource_groups map with currently edited group

Parameters:
group

local AllErrorMessages (string error) -> string

Store error messages generated by multiple commands to one string

Parameters:
error

global SaveResourceGroups () -> boolean

Save the resource groups edited in YaST UI

Return value:
success

global ReadConfigFile () -> boolean

reads a contents of scpm config file (/etc/scpm.conf)

Return value:
false when file doesn't exist

global WriteConfigFile () -> boolean

writes configuration data to scpm config file (/etc/scpm.conf)

Return value:
true

global GetModifiedGroupResources (string groupname) -> map

gets the modified resources belonging to one group

Parameters:
groupname
Return value:
of format resources_of_modified_group (see GetModifiedGroups())

global GetModifiedGroups () -> void

Uses "switch_info" map to generate helper structure "modified_groups"

Example:
 
 modified_groups structure
 $[ modified_group: resources_of_modified_group ]

 modified_group is name of resource group

 resources_of_modified_group is a map of format:
 $[
	0: $[
		"resource_name":	"/etc/inetd.conf",
		"resource_type":	"file",
		"save":			true,
		"save_mode":		"normal",
		"groups": [
			$[ "name":	"inetd",
			   "description": "Inetd services"
			]]
	],
	1: $[
		"resource_name":	"xinetd",
		"resource_type":	"service",
		"save":			true,
		"save_mode":		"normal",
		"groups": [
			$[ "name":	"inetd",
			   "description": "Inetd services"
			]]
	],
	"save"	:	true,
	"modified":	false,
	"description"	"Inetd services"
 ]
 numbers are indexes in the switch_info["modified_resources"]:[] list,
 "save" and "modified" are flags of this group (modified_group)

global UpdateOtherGroups (list groups) -> boolean

Update global flags (save/m) of groups according to the state of their resources

Parameters:
groups list of groups to check and possibly update

global CheckAndUpdateResources (string name, map resources) -> boolean

Check the modified resources belonging to specified group If user changed anything (in DetailsSwitchDialog), global maps modified_groups and switch_info are updated. Some of modified resource could be also contained in some other group and all such groups have to be checked also (to update modified_groups). It could be the situation when resource should not be saved and it is set in first group. But it is also the only resource of some other group and so such group should be also marked not to save.

Parameters:
name group name
resources map of that group's modified resources (altered by user)

global SetGroupSaveFlag (string groupname) -> boolean

Sets the "save" flag of all resources belonging to selected resource group to the opposite value. Also sets "save_mode" of each resource to "normal"

Parameters:
groupname resource group name
Return value:
the new value

global GetGroupsAsItems () -> list

Creates the item list for the Table widget (to use in Switch dialog).

Return value:
of items

local Initialize () -> boolean

Initialize the SCPM agent.

Return value:
true on success

local ReadSCPMStatus () -> boolean

Checks if SCPM is enabled/disabled/initialized.

Return value:
true on success

global ReadCurrentResources () -> boolean

Reads the current resource set.

Return value:
true on success

global ReadResourceSets () -> boolean

Reads the list of aviable resource sets.

Return value:
true on success

global ReadProfiles () -> boolean

Reads the list of aviable profiles.

Return value:
true on success

global ReadActiveProfile () -> boolean

Reads the active profile.

Return value:
true on success

global ReadProfilesDescriptions () -> boolean

Reads the descriptions of all aviable profiles.

Return value:
true on success

local ReadUserSettings () -> boolean

Check if the module is run for first time and reads user settings (currently close_popups check)

Return value:
true on success

global Read () -> boolean

Read all profile-manager settings

Return value:
true on success

global WriteUserSettings () -> boolean

Writes the user settings (currently close_popups check).

Return value:
true on success

global Write () -> boolean

Write all profile-manager settings

Return value:
true on success

global GetProfile () -> boolean

Reads the settings of the selected profile (we already have description from ReadProfileDescriptions()).

Return value:
true on success

global AddProfile (string name) -> boolean

Creates a new profile.

Parameters:
name Name of the new profile
Return value:
true

global CopyProfile (string source, string new) -> boolean

Creates a new profile by copying old one.

Parameters:
source Name of the source profile
new Name of the new profile
Return value:
true

global RenameProfile (string old, string new) -> boolean

Renames a profile.

Parameters:
old Name of the affected profile
new New name of the profile
Return value:
true on success

global SetProfile (string name, map settings) -> boolean

Sets the parameters of the profile. Uses the global variable profile_settings.

Parameters:
name Name of the affected profile
settings The map of profile settings
Return value:
true on success

global DeleteProfile (string to_delete) -> boolean

Deletes the profile.

Parameters:
to_delete Name of the affected profile
Return value:
true on success

global PrepareSwitch () -> void

Calls PrepareSwitch(), which drops switch_info map to file

global SaveSwitchInfo () -> boolean

Sets all "save" flags in switch_info map to true.

Return value:
true on success

global DropSwitchInfo () -> boolean

Sets all "save" flags in switch_info map to false.

Return value:
true on success

global Save () -> void

Saves modified resources of the profile

global Switch () -> void

Switchs to the selected profile.

global WriteSCPMStatus () -> boolean

Enables or disables SCPM (depends on value of enabled variable).

Return value:
true on success

global WriteStatusFirst () -> void

Enables SCPM for the first time

global WriteResources (string resource_set) -> boolean

Changes the current resources.

Parameters:
resource_set Name of new resource set
Return value:
true on success

global RebuildDB () -> boolean

Rebuilds SCPM database after changing resources.

Return value:
true on success

global ShowChanges () -> string

Checks, what changes will be done to the selected resource after switch. Uses global variable active_resource.

Return value:
The changes.

global SetSaveFlag () -> boolean

Sets the "save" flag of selected resource to the opposite value.

Return value:
true on success

global GetProfilesAsItems () -> list

Creates the item list for the Table widget.

Return value:
of items

global GetResourcesAsItems () -> list

Creates the item list for the Table widget (to use in Switch dialog).

Return value:
of items

global CheckNameValidity (string name) -> boolean

Checks if the name of the new profile consists of valid characters: [a-zA-Z0-9_-.]

Parameters:
name Name of the new profile.
Return value:
true if valid

global CheckFilesValidity (map settings) -> list

Checks the existence of the scripts from

Parameters:
settings The map with paths to scripts
Return value:
of non-executable files (empty when all is OK)

global SetFilePermitions (map settings) -> boolean

Sets the file permitions of scripts from profile_settings to 700.

Parameters:
settings The map with paths to scripts
Return value:
true on success

global ModifiedSettings (map new_settings) -> boolean

Checks if the profile settings was modified.

Parameters:
new_settings The map of new profile settings.
Return value:
true if modified

global GetHashMarks () -> integer

Gets the hash marks (to show in ProgressPopup) from the hashfile

Return value:
number of characters in hashfile

global GetProgressText (boolean everything) -> string

Reads the file with the progress informations.

Parameters:
everything if set to true, returns the entire rest of file
Return value:
the text to show in ProgressPopup (one line in normal case)

global ReadSwitchInfo () -> boolean

Reads the switch info map, which was dumped to file by agent's thread

Return value:
true on success

global Wait () -> boolean

Checks the return value of agent's thread

Return value:
true if thread finished succesfully

YaST2 Developers Documentation