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 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 changeStripe( const string& name, unsigned long stripe );
00034         int changeStripeSize( const string& name, 
00035                               unsigned long long stripeSize );
00036 
00037         int setPeSize( long long unsigned peSizeK );
00038         void normalizeDmDevices();
00039         void getCommitActions( std::list<storage::commitAction*>& l ) const;
00040         int commitChanges( storage::CommitStage stage );
00041         int getToCommit( storage::CommitStage stage, std::list<Container*>& col,
00042                          std::list<Volume*>& vol );
00043         int resizeVolume( Volume* v, unsigned long long newSize );
00044         int removeVolume( Volume* v );
00045         void getInfo( storage::LvmVgInfo& info ) const;
00046         bool equalContent( const Container& rhs ) const;
00047         void logDifference( const Container& rhs ) const;
00048 
00049         static void activate( bool val=true );
00050         static void getVgs( std::list<string>& l );
00051         static bool lvNotDeleted( const LvmLv& l ) { return( !l.deleted() ); }
00052 
00053         
00054     protected:
00055         // iterators over LVM LVs
00056         // protected typedefs for iterators over LVMLVs
00057         typedef CastIterator<VIter, LvmLv *> LvmLvInter;
00058         typedef CastIterator<CVIter, const LvmLv *> LvmLvCInter;
00059         template< class Pred >
00060             struct LvmLvPI { typedef ContainerIter<Pred, LvmLvInter> type; };
00061         template< class Pred >
00062             struct LvmLvCPI { typedef ContainerIter<Pred, LvmLvCInter> type; };
00063         typedef CheckFnc<const LvmLv> CheckFncLvmLv;
00064         typedef CheckerIterator< CheckFncLvmLv, LvmLvPI<CheckFncLvmLv>::type,
00065                                  LvmLvInter, LvmLv > LvmLvPIterator;
00066         typedef CheckerIterator< CheckFncLvmLv, LvmLvCPI<CheckFncLvmLv>::type,
00067                                  LvmLvCInter, const LvmLv > LvmLvCPIterator;
00068         typedef DerefIterator<LvmLvPIterator,LvmLv> LvmLvIter;
00069         typedef DerefIterator<LvmLvCPIterator,const LvmLv> ConstLvmLvIter;
00070         typedef IterPair<LvmLvIter> LvmLvPair;
00071         typedef IterPair<ConstLvmLvIter> ConstLvmLvPair;
00072 
00073         LvmLvPair lvmLvPair( bool (* Check)( const LvmLv& )=NULL)
00074             {
00075             return( LvmLvPair( lvmLvBegin( Check ), lvmLvEnd( Check ) ));
00076             }
00077         LvmLvIter lvmLvBegin( bool (* Check)( const LvmLv& )=NULL)
00078             {
00079             IterPair<LvmLvInter> p( (LvmLvInter(begin())), (LvmLvInter(end())) );
00080             return( LvmLvIter( LvmLvPIterator( p, Check )) );
00081             }
00082         LvmLvIter lvmLvEnd( bool (* Check)( const LvmLv& )=NULL)
00083             {
00084             IterPair<LvmLvInter> p( (LvmLvInter(begin())), (LvmLvInter(end())) );
00085             return( LvmLvIter( LvmLvPIterator( p, Check, true )) );
00086             }
00087 
00088         ConstLvmLvPair lvmLvPair( bool (* Check)( const LvmLv& )=NULL) const
00089             {
00090             return( ConstLvmLvPair( lvmLvBegin( Check ), lvmLvEnd( Check ) ));
00091             }
00092         ConstLvmLvIter lvmLvBegin( bool (* Check)( const LvmLv& )=NULL) const
00093             {
00094             IterPair<LvmLvCInter> p( (LvmLvCInter(begin())), (LvmLvCInter(end())) );
00095             return( ConstLvmLvIter( LvmLvCPIterator( p, Check )) );
00096             }
00097         ConstLvmLvIter lvmLvEnd( bool (* Check)( const LvmLv& )=NULL) const
00098             {
00099             IterPair<LvmLvCInter> p( (LvmLvCInter(begin())), (LvmLvCInter(end())) );
00100             return( ConstLvmLvIter( LvmLvCPIterator( p, Check, true )) );
00101             }
00102 
00103         LvmVg( Storage * const s, const string& File, int );
00104 
00105         void getVgData( const string& name, bool exists=true );
00106         void init();
00107         virtual void print( std::ostream& s ) const { s << *this; }
00108         virtual Container* getCopy() const { return( new LvmVg( *this ) ); }
00109 
00110         string createVgText( bool doing ) const;
00111         string removeVgText( bool doing ) const;
00112         string extendVgText( bool doing, const string& dev ) const;
00113         string reduceVgText( bool doing, const string& dev ) const;
00114 
00115         int doCreateVg();
00116         int doRemoveVg();
00117         int doExtendVg();
00118         int doReduceVg();
00119         int doCreate( Volume* v );
00120         int doRemove( Volume* v );
00121         int doResize( Volume* v );
00122         int doCreatePv( const string& device );
00123         string metaString();
00124         string instSysString();
00125 
00126         void logData( const string& Dir );
00127         void addLv( unsigned long& le, string& name, string& uuid,
00128                     string& status, string& alloc, bool& ro );
00129         void addPv( Pv*& p );
00130 
00131         string status;
00132         string uuid;
00133         bool lvm1;
00134         bool inactiv;
00135         unsigned num_lv;
00136         static bool active;
00137         mutable storage::LvmVgInfo info;
00138     };
00139 
00140 }
00141 
00142 #endif

Generated on Wed Apr 30 14:58:40 2008 for yast2-storage by  doxygen 1.4.6