LvmVg.h

Go to the documentation of this file.
00001 #ifndef LVM_VG_H
00002 #define LVM_VG_H
00003 
00004 #include "y2storage/PeContainer.h"
00005 #include "y2storage/LvmLv.h"
00006 
00007 namespace storage
00008 {
00009 
00010 class LvmVg : public PeContainer
00011     {
00012     friend class Storage;
00013 
00014     public:
00015         LvmVg( Storage * const s, const string& Name );
00016         LvmVg( Storage * const s, const string& Name, bool lvm1 );
00017         LvmVg( const LvmVg& c );
00018         virtual ~LvmVg();
00019         unsigned numLv() const { return vols.size(); }
00020         bool lvm2() const { return( !lvm1 ); }
00021         bool inactive() const { return( inactiv ); }
00022         static storage::CType const staticType() { return storage::LVM; }
00023         friend std::ostream& operator<< (std::ostream&, const LvmVg& );
00024 
00025         int removeVg();
00026         int extendVg( const std::list<string>& dl );
00027         int extendVg( const string& device );
00028         int reduceVg( const std::list<string>& dl );
00029         int reduceVg( const string& device );
00030         int createLv( const string& name, unsigned long long sizeK, 
00031                       unsigned stripe, string& device );
00032         int removeLv( const string& name );
00033         int changeStripeSize( const string& name, 
00034                               unsigned long long stripeSize );
00035 
00036         int setPeSize( long long unsigned peSizeK );
00037         void normalizeDmDevices();
00038         void getCommitActions( std::list<storage::commitAction*>& l ) const;
00039         int commitChanges( storage::CommitStage stage );
00040         int getToCommit( storage::CommitStage stage, std::list<Container*>& col,
00041                          std::list<Volume*>& vol );
00042         int resizeVolume( Volume* v, unsigned long long newSize );
00043         int removeVolume( Volume* v );
00044         void getInfo( storage::LvmVgInfo& info ) const;
00045         bool equalContent( const LvmVg& rhs ) const;
00046         void logDifference( const LvmVg& rhs ) const;
00047 
00048         static void activate( bool val=true );
00049         static void getVgs( std::list<string>& l );
00050         static bool lvNotDeleted( const LvmLv& l ) { return( !l.deleted() ); }
00051 
00052         
00053     protected:
00054         // iterators over LVM LVs
00055         // protected typedefs for iterators over LVMLVs
00056         typedef CastIterator<VIter, LvmLv *> LvmLvInter;
00057         typedef CastIterator<CVIter, const LvmLv *> LvmLvCInter;
00058         template< class Pred >
00059             struct LvmLvPI { typedef ContainerIter<Pred, LvmLvInter> type; };
00060         template< class Pred >
00061             struct LvmLvCPI { typedef ContainerIter<Pred, LvmLvCInter> type; };
00062         typedef CheckFnc<const LvmLv> CheckFncLvmLv;
00063         typedef CheckerIterator< CheckFncLvmLv, LvmLvPI<CheckFncLvmLv>::type,
00064                                  LvmLvInter, LvmLv > LvmLvPIterator;
00065         typedef CheckerIterator< CheckFncLvmLv, LvmLvCPI<CheckFncLvmLv>::type,
00066                                  LvmLvCInter, const LvmLv > LvmLvCPIterator;
00067         typedef DerefIterator<LvmLvPIterator,LvmLv> LvmLvIter;
00068         typedef DerefIterator<LvmLvCPIterator,const LvmLv> ConstLvmLvIter;
00069         typedef IterPair<LvmLvIter> LvmLvPair;
00070         typedef IterPair<ConstLvmLvIter> ConstLvmLvPair;
00071 
00072         LvmLvPair lvmLvPair( bool (* Check)( const LvmLv& )=NULL)
00073             {
00074             return( LvmLvPair( lvmLvBegin( Check ), lvmLvEnd( Check ) ));
00075             }
00076         LvmLvIter lvmLvBegin( bool (* Check)( const LvmLv& )=NULL)
00077             {
00078             IterPair<LvmLvInter> p( (LvmLvInter(begin())), (LvmLvInter(end())) );
00079             return( LvmLvIter( LvmLvPIterator( p, Check )) );
00080             }
00081         LvmLvIter lvmLvEnd( bool (* Check)( const LvmLv& )=NULL)
00082             {
00083             IterPair<LvmLvInter> p( (LvmLvInter(begin())), (LvmLvInter(end())) );
00084             return( LvmLvIter( LvmLvPIterator( p, Check, true )) );
00085             }
00086 
00087         ConstLvmLvPair lvmLvPair( bool (* Check)( const LvmLv& )=NULL) const
00088             {
00089             return( ConstLvmLvPair( lvmLvBegin( Check ), lvmLvEnd( Check ) ));
00090             }
00091         ConstLvmLvIter lvmLvBegin( bool (* Check)( const LvmLv& )=NULL) const
00092             {
00093             IterPair<LvmLvCInter> p( (LvmLvCInter(begin())), (LvmLvCInter(end())) );
00094             return( ConstLvmLvIter( LvmLvCPIterator( p, Check )) );
00095             }
00096         ConstLvmLvIter lvmLvEnd( bool (* Check)( const LvmLv& )=NULL) const
00097             {
00098             IterPair<LvmLvCInter> p( (LvmLvCInter(begin())), (LvmLvCInter(end())) );
00099             return( ConstLvmLvIter( LvmLvCPIterator( p, Check, true )) );
00100             }
00101 
00102         LvmVg( Storage * const s, const string& File, int );
00103 
00104         void getVgData( const string& name, bool exists=true );
00105         void init();
00106         virtual void print( std::ostream& s ) const { s << *this; }
00107         virtual Container* getCopy() const { return( new LvmVg( *this ) ); }
00108 
00109         string createVgText( bool doing ) const;
00110         string removeVgText( bool doing ) const;
00111         string extendVgText( bool doing, const string& dev ) const;
00112         string reduceVgText( bool doing, const string& dev ) const;
00113 
00114         int doCreateVg();
00115         int doRemoveVg();
00116         int doExtendVg();
00117         int doReduceVg();
00118         int doCreate( Volume* v );
00119         int doRemove( Volume* v );
00120         int doResize( Volume* v );
00121         int doCreatePv( const string& device );
00122         string metaString();
00123         string instSysString();
00124 
00125         void logData( const string& Dir );
00126         void addLv( unsigned long& le, string& name, string& uuid,
00127                     string& status, string& alloc, bool& ro );
00128         void addPv( Pv*& p );
00129 
00130         string status;
00131         string uuid;
00132         bool lvm1;
00133         bool inactiv;
00134         unsigned num_lv;
00135         static bool active;
00136         mutable storage::LvmVgInfo info;
00137     };
00138 
00139 }
00140 
00141 #endif

Generated on Thu Jul 6 00:40:24 2006 for yast2-storage by  doxygen 1.4.6