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?
This shows if the "autoswitch" was set while adding a new profile.
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.
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()
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:
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
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)
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:
global GetResourceGroupResources (string groupname) -> list
|
|
Gets resources of resource group.
- Parameters:
groupname |
resource group name |
- Return value:
global ReadResourceGroups () -> boolean
|
|
Reads all available resource groups.
- Return value:
global ResetResourceGroups () -> boolean
|
|
Resets RG's to default values
- Return value:
global ResetResourceGroup (string groupname) -> boolean
|
|
Resets one resource group to default values
- Parameters:
- Return value:
global GetResourceGroups () -> map
|
|
Returns all available resource groups.
- Return value:
global GroupDeletable (string groupname) -> boolean
|
|
Can be resource group deleted by user?
- Parameters:
global GroupnameExists (string groupname) -> boolean
|
|
Does given resource group exist? (Checked when user enters name of new group)
- Parameters:
global GetGroup (string groupname) -> map
|
|
Returns map resource group
- Parameters:
global MarkGroupDeleted (string groupname) -> void
|
|
Marks selected resource group for deletion (will not be shown in list)
- Parameters:
global MarkGroupActive (string groupname) -> boolean
|
|
Changes "active" flag of selected resource group to opposite value
- Parameters:
- Return value:
global ChangeGroup (map group) -> void
|
|
Updates global resource_groups map with currently edited group
- Parameters:
local AllErrorMessages (string error) -> string
|
|
Store error messages generated by multiple commands to one string
- Parameters:
global SaveResourceGroups () -> boolean
|
|
Save the resource groups edited in YaST UI
- Return value:
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:
global GetModifiedGroupResources (string groupname) -> map
|
|
gets the modified resources belonging to one group
- Parameters:
- 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:
global GetGroupsAsItems () -> list
|
|
Creates the item list for the Table widget (to use in Switch dialog).
- Return value:
local Initialize () -> boolean
|
|
Initialize the SCPM agent.
- Return value:
local ReadSCPMStatus () -> boolean
|
|
Checks if SCPM is enabled/disabled/initialized.
- Return value:
global ReadCurrentResources () -> boolean
|
|
Reads the current resource set.
- Return value:
global ReadResourceSets () -> boolean
|
|
Reads the list of aviable resource sets.
- Return value:
global ReadProfiles () -> boolean
|
|
Reads the list of aviable profiles.
- Return value:
global ReadActiveProfile () -> boolean
|
|
Reads the active profile.
- Return value:
global ReadProfilesDescriptions () -> boolean
|
|
Reads the descriptions of all aviable profiles.
- Return value:
local ReadUserSettings () -> boolean
|
|
Check if the module is run for first time and
reads user settings (currently close_popups check)
- Return value:
global Read () -> boolean
|
|
Read all profile-manager settings
- Return value:
global WriteUserSettings () -> boolean
|
|
Writes the user settings (currently close_popups check).
- Return value:
global Write () -> boolean
|
|
Write all profile-manager settings
- Return value:
global GetProfile () -> boolean
|
|
Reads the settings of the selected profile
(we already have description from ReadProfileDescriptions()).
- Return value:
global AddProfile (string name) -> boolean
|
|
Creates a new profile.
- Parameters:
name |
Name of the new profile |
- Return value:
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:
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:
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:
global DeleteProfile (string to_delete) -> boolean
|
|
Deletes the profile.
- Parameters:
to_delete |
Name of the affected profile |
- Return value:
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:
global DropSwitchInfo () -> boolean
|
|
Sets all "save" flags in switch_info map to false.
- Return value:
Saves modified resources of the profile
Switchs to the selected profile.
global WriteSCPMStatus () -> boolean
|
|
Enables or disables SCPM
(depends on value of enabled variable).
- Return value:
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:
global RebuildDB () -> boolean
|
|
Rebuilds SCPM database after changing resources.
- Return value:
global ShowChanges () -> string
|
|
Checks, what changes will be done to the selected resource after switch.
Uses global variable active_resource.
- Return value:
global SetSaveFlag () -> boolean
|
|
Sets the "save" flag of selected resource to the opposite value.
- Return value:
global GetProfilesAsItems () -> list
|
|
Creates the item list for the Table widget.
- Return value:
global GetResourcesAsItems () -> list
|
|
Creates the item list for the Table widget (to use in Switch dialog).
- Return value:
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:
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:
global ModifiedSettings (map new_settings) -> boolean
|
|
Checks if the profile settings was modified.
- Parameters:
new_settings |
The map of new profile settings. |
- Return value:
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:
global Wait () -> boolean
|
|
Checks the return value of agent's thread
- Return value:
|
true if thread finished succesfully |
|