SCPM interface  1.0
scpm.h
Go to the documentation of this file.
1 /*
2  * $Id: scpm.hh,v 1.5 2006/11/02 16:15:01 gleissner Exp $
3  *
4  *
5  * Project : SCPM (System Configuration Profile Management)
6  * Module : SCPM main engine
7  * File : scpm.hh
8  * Description : defines the SCPM interface
9  * Author : Joachim Gleissner <jg@suse.de>
10  *
11  * Copyright 2001 SuSE GmbH
12  * 2002-2004 SuSE Linux AG
13  *
14  * Released under the terms of the GNU General Public License
15  * (see file COPYRIGHT in project root directory).
16  *
17  */
18 #ifndef SCPM_H
19 #define SCPM_H
20 
21 #include <string>
22 #include <vector>
23 #include <scpm_types.h>
24 #include <scdb.h>
25 
26 class SCPM_helpers;
27 class Log;
28 
29 class SCPM
30 {
31 public:
32 
33  SCPM( int options=0, std::ostream &info_out=std::cout, std::ostream &hash_out=std::cout, std::string root="" );
34  ~SCPM();
35 
36  bool Enable( bool force=false );
37  bool Disable( );
38 
39  bool Active( std::string &profile );
40  bool List( std::vector<std::string> &profiles );
41 
42  bool Add( std::string profile, bool auto_switch=true );
43  bool Copy( std::string source_profile, std::string profile );
44  bool Create( std::string profile, std::string source_profile );
45  bool Delete( std::string profile );
46  bool Rename( std::string profile, std::string newprofile );
47  bool Reload( );
48  bool PrepareSwitch( std::string profile, switch_info_t &switch_info );
49  bool Switch( switch_info_t &switch_info );
50  bool Save( switch_info_t &switch_info );
51  bool Modify( std::string profile, std::string action );
52  bool Set( std::string command, std::string argument, std::string profile="" );
53  bool Get( std::string command, std::string &result, std::string profile="" );
54  bool Status( scpm_status_t &status );
55 
56  bool ShowChanges( std::ostream &output, std::string resource_type,
57  std::string resource_name, bool backup=false, std::string version="" );
58 
59  bool SetResourceSet( std::string set );
60  bool GetResourceSet( std::string &set );
61  bool ListResourceSets( std::vector<std::string> &predefined, std::vector<std::string> &individual );
62  bool CopyResourceSet( std::string set, std::string newset );
63  bool DeleteResourceSet( std::string set );
64 
65  bool ListResourceGroups( std::vector<resource_group_t> &groups );
66  bool GetResourceGroup( const std::string &name, std::vector<resource_entry_t> &group,
67  bool nouser=false );
68  bool GetResourceGroup( const std::string &name, std::vector<resource_entry_t> &group,
69  std::string &description, bool nouser=false );
70  bool SetResourceGroup( const std::string &name, const std::vector<resource_entry_t> &group,
71  const std::string &description );
72  bool DeleteResourceGroup( const std::string &group );
73  bool RenameResourceGroup( const std::string &group, const std::string &newgroup );
74  bool SetActiveResourceGroups( const std::vector<std::string> &groups );
75  bool GetActiveResourceGroups( std::vector<std::string> &groups );
76  bool ActivateResourceGroup( const std::string &group, bool auto_add=false );
77  bool DeactivateResourceGroup( const std::string &group, bool auto_remove=false );
78  bool ResetResourceGroup( const std::string &group );
79  bool ResetAllGroups( );
80 
82 
83  bool SetConfigOption( const std::string &option, const std::string &value );
84  bool GetConfigOption( const std::string &option, std::string &value );
85 
86  // update and backup functions
87  bool Update( const std::string &scriptname, std::vector<std::pair<std::string, std::string> > resources );
88  bool UpdateResources( );
89  bool RestoreBackup( const std::vector<std::pair<std::string, std::string> > &resources,
90  const std::vector<std::string> &versions, const std::string &profile );
91  bool RemoveBackup( const std::vector<std::pair<std::string, std::string> > &resources,
92  const std::vector<std::string> &versions, const std::string &profile );
93  bool ListBackups( const std::string &profile, std::vector<backup_info_t> *reslist );
94  bool AddBackup( const std::vector<std::pair<std::string, std::string> > &resources,
95  const std::string &profile);
96  bool Recover( bool rollback=false );
97 
98  bool Commit( );
99 
100 private:
101 
102  struct prepare_failed{};
103 
104  std::vector<resource_group_t> &GetGroupsByResource( const std::string &resname,
105  const std::string &restype );
106  void Prepare( bool write_access=false );
107 
108  SCPM_helpers *sh;
109  Log *log;
110  bool db_open;
111  bool switch_prepared;
112  bool init_failed;
113 
114 };
115 
116 #endif
bool GetConfigOption(const std::string &option, std::string &value)
Sets a configuartion option.
bool CopyResourceSet(std::string set, std::string newset)
Copies a resource set.
bool Set(std::string command, std::string argument, std::string profile="")
Set profile options.
variable type for profile switch information
Definition: scpm_types.h:63
bool DeleteResourceSet(std::string set)
Deletes an individual resource set.
bool DeactivateResourceGroup(const std::string &group, bool auto_remove=false)
Deactivates a resource group.
bool Delete(std::string profile)
Deletes a profile.
bool RenameResourceGroup(const std::string &group, const std::string &newgroup)
Renames a resource group.
bool ActivateResourceGroup(const std::string &group, bool auto_add=false)
Activates a resource group.
bool Create(std::string profile, std::string source_profile)
Adds a new profile.
bool Disable()
Completely disables SCPM.
~SCPM()
Destructor.
bool ShowChanges(std::ostream &output, std::string resource_type, std::string resource_name, bool backup=false, std::string version="")
Shows changes of given resource.
bool RebuildDB(rebuild_mode_t mode=REBUILD_MODE_QUICK)
Performs a rebuild of the database.
bool Add(std::string profile, bool auto_switch=true)
Adds a new profile.
bool Enable(bool force=false)
Makes SCPM ready for use.
bool SetConfigOption(const std::string &option, const std::string &value)
Sets a configuartion option.
bool List(std::vector< std::string > &profiles)
lists all profiles
bool ListResourceGroups(std::vector< resource_group_t > &groups)
Generates a list of all installed resource groups.
bool Switch(switch_info_t &switch_info)
Perform prepared switch.
transport container for SCPM status information
Definition: scpm_types.h:69
bool Modify(std::string profile, std::string action)
Perform a profile modify action.
bool DeleteResourceGroup(const std::string &group)
Removes a resource group.
bool SetResourceGroup(const std::string &name, const std::vector< resource_entry_t > &group, const std::string &description)
Modifies or creates a resource group.
Some variable types used by SCPM.
bool GetResourceSet(std::string &set)
Gets the active resource set.
bool ResetResourceGroup(const std::string &group)
Resets defaults of a resource group.
bool Status(scpm_status_t &status)
Query some status information.
bool ResetAllGroups()
Resets all resource groups.
bool SetActiveResourceGroups(const std::vector< std::string > &groups)
Sets active resource groups.
bool Copy(std::string source_profile, std::string profile)
Adds a new profile.
bool Rename(std::string profile, std::string newprofile)
Renames a profile.
bool Get(std::string command, std::string &result, std::string profile="")
Get profile options.
Removes obsolete resources and adds new ones.
Definition: scpm_types.h:92
bool Active(std::string &profile)
query for active profile
SCPM interface class.
Definition: scpm.h:29
bool ListResourceSets(std::vector< std::string > &predefined, std::vector< std::string > &individual)
Gets all defined resource sets.
SCPM(int options=0, std::ostream &info_out=std::cout, std::ostream &hash_out=std::cout, std::string root="")
Constructor.
rebuild_mode_t
Rebuild mode enum.
Definition: scpm_types.h:91
bool GetActiveResourceGroups(std::vector< std::string > &groups)
Lists active resource groups.
bool Save(switch_info_t &switch_info)
Save modified resources.
bool PrepareSwitch(std::string profile, switch_info_t &switch_info)
Prepares the switch to profile profile
bool SetResourceSet(std::string set)
Sets a resource set for use.
bool Reload()
Reloads the current profile.

SCPM interface description - 2002,2003 SuSE Linux AG