Implementation of Profile-manager
SCPM enables users to have multiple configuration (different network setings etc.) of their system.
For terminology, see the specification document.
For workflow, see the workflow diagram.
Dialogs
After starting module, the first dialog is Main dialog, labeled System Configuration Profile Management.
Here user can see
- list with aviable profiles
- SCPM state (enabled/disabled)
- current resource set
And what he/she can do:
- press the Options button to configure SPCM behaviour -> that invokes Options Dialog
- add, edit or delete profiles -> with appropriate buttons this invokes Add Profile Popup, Profile Setting Dialog or Confirm delete Popup
- switch to profile seleceted in the list box widget -> the Switch Dialog
When the user uses SCPM for first time and SCPM is disabled, the Introduction Popup is showed. From here he/she can choose to see an info page in Konqueror (or another aviable application) started by clicking "Show introduction" button or just continue.
The Options Dialog
Options Dialog is for changing SCPM configuration. User can enable or disable SCPM (at fist time it is disabled) and chooses the Resource Set. (List of aviable Resource Sets is shown in the list box.)
The Switch Dialog
This dialog shows changes, which will be done after switching to selected profile (the files and resources that will be created or deleted). After confirming the switch, the Progress Popup is shown. Here are shown the messages of what is currently doing - starting or stoping services, changing config files etc.
Add Profile Popup
User is asked, what will the new profile look like (based on the current configuration or on an existing profile). After that, he can edit it in the Profile Setting Dialog.
Profile Setting Dialog
Here could be changed the name and descrtiption of selected profile and choosed scripts to be executed before/after profile switching.
To know more about dialogs, see the specification document.
Implementation
The implementation of SCPM will has two parts: a YaST2 module (written in YCP language) and a SCR agent (in C++). The agent performs the actions with the SCPM library (which is written in C++, see the API documentation) after the Read/Write/Execute calls from the module.
Example: User checks an "Enabled" checkbox in the Options Dialog. After pushing the OK button, YCP module calls SCR::Write(.scpm.enabled, "true") and ".scpm" agent calls function SCPM::Enable from the SCPM library.
YCP module
For more information, see autodocs.
File profile-manager.ycp (the client): starting the function ScpmSequence
File wizard.ycp - the sequences definitions.
ProfileManagerSequence()
- ReadDialog() is called
- MainSequence() after success
- WiteDialog() finishs the module
MainSequence()
- main workflow
- MainDialog() is started
- OptionsDiaalog(), SwitchDialog() or ProfileSettingsDialog() can be run
Files complex.ycp and dialogs.ycp: the user interface.
Functions from this file use the module functions (e.g. Profile-manager::Read).
ReadDialog()
-
ProfileManager::Read() reads the current configuration
IntroductionPopup()
- is run from MainDialog() automatically, when ProfileManager::first_time is true (this is checked in Read())
- can be run IntroductionTextPopup when user wants to
IntroductionTextPopup()
-
this calls the application, which shows the info text; this is done by ProfileManager::RunIntroApplication()
MainDialog()
- can be run intro via IntroductionTextPopup()
- Add button invokes the AddProfilePopup()
- Edit button invokes the ProfileSettingsDialog()
- Delete button invokes the confirmation popup
- Pressing Switch button invokes ProgressPopup() (showing the information got from ProfileManager::PrepareSwitch()) and SwitchDialog() after that.
OptionsDialog()
- ProfileManager::ReadResourceSets() is run first to ... read the resource sets ;-)
- after OK the sequence can be run ProfileManager::WriteStatus() - if user wants to enable/disable) -
- or ProfileManager::WriteResources() and ProfileManager::RebuildDB(), if another resource set was choosed. For this action the confirmation popup is showed.
- When SCPM is enabled for first time (ProfileManager::initialized, which is read in Read(), is false), the ProgressPopup() is showed.
SwitchDialog()
- ProfileManager::SaveSwitchInfo() is run after pushing "Select all" button
- ProfileManager::DropSwitchInfo() is run after pushing "Deselect all" button
- ProfileManager::SetSaveFlag() is run after pushing "Select or deselect" button or after double clicking at the table item
- ShowChangesPopup() is called after push the appropriate button
- Switch() and ProgressPopup() are called after OK
ProgressPopup()
- shows the information about what the SCPM si doing - this information gets from ProfileManager::GetProgressText() function line by line (in the while-cycle)
- the cycle is finished after 100 hash marks are written to the hash file - this is checked by calling the ProfileManager::GetHashMarks() function
AddProfilePopup()
- user chooses the type of new profile (adding or copying)
- after success we continue to the ProfileSettingsDialog()
- global variable ProfileManager::profile_action is set to "copy" or "new"
ProfileSettingsDialog()
- profile description of the selected profile will be retrived by GetProfile()
- ProfileManager::RenameProfile() or ProfileManager::SetProfile() will be called if ProfileManager::profile_action is "edit"
- with other action, ProfileManager::AddProfile or ProfileManager::CopyProfile and also ProfileManager::SetProfile() to save the new parameters
File Profile-manager.ycp: the module - handles SCR calls, global variables etc.
Its functions are called from dialogs; they do appropriate SCR-calls. Most of functions return boolean (the success) an some of them changes the value of global variables.
Read()
- changes global booleans enabled and initialized, the global list profiles, global strings current_resources and active_profile
- initializes SCPM by calling SCR::Execute(.scpm)
- SCR::Read(.scpm.status.enabled)
- SCR::Read(.scpm.profiles)
- SCR::Read(.scpm.profiles.current)
- SCR::Read(.scpm.profiles.description)
- SCR::Read(.scpm.resources.current)
- also reads the settings from /var/lib/YaST2/scpm.ycp (currently - if it is a first time run of profile-manager and the state of close_popups variable)
- the path to files progressfile, hashfile, changesfile and tmpfile are defined
Write()
- writes the SCPM database by calling SCR::Write(.scpm)
- writes the user settings (currently the state of close_popups variable)
ReadResourceSets()
- changes global lists resource_sets_predefined and resource_sets_individua
- SCR::Read(.scpm.resources)
WriteSCPMStatus()
- SCR::Write(.scpm.status.enabled, <enabled>)
WriteStatusFirst()
- SCR::Write(.scpm.enable.first, <enabled>)
WriteResources(string resource_set_name)
- SCR::Write(.scpm.resources.current, <resource_set_name>)
RebuildDB()
- SCR::Execute(.scpm.resources.rebuild)
RunIntroApplication()
- Currently runs either konqueror, info or man (searches the system for what is present). On console it gets the output from "info scpm > output".
PrepareSwitch(string profile_name)
- SCR::Execute(.scpm.switch.prepare, <profile_name>)
ReadSwitchInfo()
- reads the contens of switch_info map from the tmpfile, where it was written after PrepareSwitch() call
Switch()
- uses the switch_info map
- SCR::Execute(.scpm.switch, <switch_info>)
CopyProfile(string source_name, string new_name)
- SCR::Execute(.scpm.profiles.copy, <source_name>, <new_name>)
AddProfile(string profile_name)
- SCR::Execute(.scpm.profiles.add, <profile_name>)
DeleteProfile(string profile_name)
- SCR::Execute(.scpm.profiles.delete, <profile_name>)
GetProfile(string profile name)
- changes global map profile_settings
- SCR::Read(.scpm.profiles.<command>, <profile_name>)
- this Read has to be run for multiple commands, where commands are [pre|post][start|stop]
RenameProfile(string actual_name, string new_name)
- SCR::Execute(.scpm.profiles.rename, <actual_name>, <new_name>)
SetProfile(string profile_name)
- uses map profile_settings
- SCR::Write(.scpm.profiles.<command>, <argument>, <profile_name>)
- this Write is run for each <command> in profile_settings map
GetProgressText(boolean everything)
- the contens of the progressfile is read
- as a standard only one new line is returned
- when parameter is true, the file is read to the end
GetHashMarks()
- the contens of the hashfile is read
The agent
For info about agent implementation, see its own documentation (or here).
Jiri Suchomel <jsuchome@suse.cz>