Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

Generated on Wed Sep 14 11:27:07 2005 for yast2-storage by  doxygen 1.4.4