SCPM interface 1.0
|
00001 /* 00002 * $Id: scpm.hh,v 1.5 2006/11/02 16:15:01 gleissner Exp $ 00003 * 00004 * 00005 * Project : SCPM (System Configuration Profile Management) 00006 * Module : SCPM main engine 00007 * File : scpm.hh 00008 * Description : defines the SCPM interface 00009 * Author : Joachim Gleissner <jg@suse.de> 00010 * 00011 * Copyright 2001 SuSE GmbH 00012 * 2002-2004 SuSE Linux AG 00013 * 00014 * Released under the terms of the GNU General Public License 00015 * (see file COPYRIGHT in project root directory). 00016 * 00017 */ 00018 #ifndef SCPM_H 00019 #define SCPM_H 00020 00021 #include <string> 00022 #include <vector> 00023 #include <scpm_types.h> 00024 #include <scdb.h> 00025 00026 class SCPM_helpers; 00027 class Log; 00028 00029 class SCPM 00030 { 00031 public: 00032 00033 SCPM( int options=0, std::ostream &info_out=cout, std::ostream &hash_out=cout, std::string root="" ); 00034 ~SCPM(); 00035 00036 bool Enable( bool force=false ); 00037 bool Disable( ); 00038 00039 bool Active( std::string &profile ); 00040 bool List( std::vector<std::string> &profiles ); 00041 00042 bool Add( std::string profile, bool auto_switch=true ); 00043 bool Copy( std::string source_profile, std::string profile ); 00044 bool Create( std::string profile, std::string source_profile ); 00045 bool Delete( std::string profile ); 00046 bool Rename( std::string profile, std::string newprofile ); 00047 bool Reload( ); 00048 bool PrepareSwitch( std::string profile, switch_info_t &switch_info ); 00049 bool Switch( switch_info_t &switch_info ); 00050 bool Save( switch_info_t &switch_info ); 00051 bool Modify( std::string profile, std::string action ); 00052 bool Set( std::string command, std::string argument, std::string profile="" ); 00053 bool Get( std::string command, std::string &result, std::string profile="" ); 00054 bool Status( scpm_status_t &status ); 00055 00056 bool ShowChanges( std::ostream &output, std::string resource_type, 00057 std::string resource_name, bool backup=false, string version="" ); 00058 00059 bool SetResourceSet( std::string set ); 00060 bool GetResourceSet( std::string &set ); 00061 bool ListResourceSets( std::vector<std::string> &predefined, std::vector<std::string> &individual ); 00062 bool CopyResourceSet( std::string set, std::string newset ); 00063 bool DeleteResourceSet( std::string set ); 00064 00065 bool ListResourceGroups( std::vector<resource_group_t> &groups ); 00066 bool GetResourceGroup( const std::string &name, std::vector<resource_entry_t> &group, 00067 bool nouser=false ); 00068 bool GetResourceGroup( const std::string &name, std::vector<resource_entry_t> &group, 00069 std::string &description, bool nouser=false ); 00070 bool SetResourceGroup( const std::string &name, const std::vector<resource_entry_t> &group, 00071 const std::string &description ); 00072 bool DeleteResourceGroup( const std::string &group ); 00073 bool RenameResourceGroup( const std::string &group, const std::string &newgroup ); 00074 bool SetActiveResourceGroups( const std::vector<std::string> &groups ); 00075 bool GetActiveResourceGroups( std::vector<std::string> &groups ); 00076 bool ActivateResourceGroup( const std::string &group, bool auto_add=false ); 00077 bool DeactivateResourceGroup( const std::string &group, bool auto_remove=false ); 00078 bool ResetResourceGroup( const std::string &group ); 00079 bool ResetAllGroups( ); 00080 00081 bool RebuildDB( rebuild_mode_t mode=REBUILD_MODE_QUICK ); 00082 00083 bool SetConfigOption( const std::string &option, const std::string &value ); 00084 bool GetConfigOption( const std::string &option, std::string &value ); 00085 00086 // update and backup functions 00087 bool Update( const std::string &scriptname, std::vector<pair<std::string, std::string> > resources ); 00088 bool UpdateResources( ); 00089 bool RestoreBackup( const std::vector<pair<string, string> > &resources, const std::vector<std::string> &versions, const std::string &profile ); 00090 bool RemoveBackup( const std::vector<pair<string, string> > &resources, const std::vector<std::string> &versions, const std::string &profile ); 00091 bool ListBackups( const std::string &profile, std::vector<backup_info_t> *reslist ); 00092 bool AddBackup( const std::vector<pair<string, string> > &resources, const std::string &profile); 00093 bool Recover( bool rollback=false ); 00094 00095 bool Commit( ); 00096 00097 private: 00098 00099 struct prepare_failed{}; 00100 00101 std::vector<resource_group_t> &GetGroupsByResource( const std::string &resname, const std::string &restype ); 00102 void Prepare( bool write_access=false ); 00103 00104 SCPM_helpers *sh; 00105 Log *log; 00106 bool db_open; 00107 bool switch_prepared; 00108 bool init_failed; 00109 00110 }; 00111 00112 #endif