00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef DMMULTIPATH_CO_H
00024 #define DMMULTIPATH_CO_H
00025
00026 #include <list>
00027
00028 #include "y2storage/DmPartCo.h"
00029 #include "y2storage/Dmmultipath.h"
00030
00031 namespace storage
00032 {
00033 using std::map;
00034
00035
00036 class Storage;
00037 class SystemCmd;
00038 class ProcPart;
00039 class Region;
00040
00041
00042 class CmdMultipath
00043 {
00044
00045 public:
00046
00047 CmdMultipath();
00048
00049 struct Entry
00050 {
00051 string vendor;
00052 string model;
00053 list<string> devices;
00054 };
00055
00056 list<string> getEntries() const;
00057
00058 bool getEntry(const string& name, Entry& entry) const;
00059
00060 private:
00061
00062 typedef map<string, Entry>::const_iterator const_iterator;
00063
00064 map<string, Entry> data;
00065
00066 };
00067
00068
00069 class DmmultipathCo : public DmPartCo
00070 {
00071 friend class Storage;
00072
00073 public:
00074 DmmultipathCo( Storage * const s, const string& Name, ProcPart& ppart );
00075 DmmultipathCo( Storage * const s, const string& Name, unsigned num,
00076 unsigned long long Size, ProcPart& ppart );
00077 DmmultipathCo( const DmmultipathCo& rhs );
00078 virtual ~DmmultipathCo();
00079
00080 static storage::CType staticType() { return storage::DMMULTIPATH; }
00081 friend std::ostream& operator<< (std::ostream&, const DmmultipathCo& );
00082 void getInfo( storage::DmmultipathCoInfo& info ) const;
00083 void setUdevData(const list<string>& id);
00084
00085 bool equalContent( const Container& rhs ) const;
00086 string getDiffString( const Container& d ) const;
00087 DmmultipathCo& operator= ( const DmmultipathCo& rhs );
00088
00089 protected:
00090
00091
00092
00093 typedef CastIterator<VIter, Dmmultipath *> DmmultipathInter;
00094 typedef CastIterator<CVIter, const Dmmultipath *> DmmultipathCInter;
00095 template< class Pred >
00096 struct DmmultipathPI { typedef ContainerIter<Pred, DmmultipathInter> type; };
00097 template< class Pred >
00098 struct DmmultipathCPI { typedef ContainerIter<Pred, DmmultipathCInter> type; };
00099 typedef CheckFnc<const Dmmultipath> CheckFncDmmultipath;
00100 typedef CheckerIterator< CheckFncDmmultipath, DmmultipathPI<CheckFncDmmultipath>::type,
00101 DmmultipathInter, Dmmultipath > DmmultipathPIterator;
00102 typedef CheckerIterator< CheckFncDmmultipath, DmmultipathCPI<CheckFncDmmultipath>::type,
00103 DmmultipathCInter, const Dmmultipath > DmmultipathCPIterator;
00104 typedef DerefIterator<DmmultipathPIterator,Dmmultipath> DmmultipathIter;
00105 typedef DerefIterator<DmmultipathCPIterator,const Dmmultipath> ConstDmmultipathIter;
00106 typedef IterPair<DmmultipathIter> DmmultipathPair;
00107 typedef IterPair<ConstDmmultipathIter> ConstDmmultipathPair;
00108
00109 DmmultipathPair dmmultipathPair( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00110 {
00111 return( DmmultipathPair( dmmultipathBegin( CheckDmmultipath ), dmmultipathEnd( CheckDmmultipath ) ));
00112 }
00113 DmmultipathIter dmmultipathBegin( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00114 {
00115 IterPair<DmmultipathInter> p( (DmmultipathInter(begin())), (DmmultipathInter(end())) );
00116 return( DmmultipathIter( DmmultipathPIterator( p, CheckDmmultipath )) );
00117 }
00118 DmmultipathIter dmmultipathEnd( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00119 {
00120 IterPair<DmmultipathInter> p( (DmmultipathInter(begin())), (DmmultipathInter(end())) );
00121 return( DmmultipathIter( DmmultipathPIterator( p, CheckDmmultipath, true )) );
00122 }
00123
00124 ConstDmmultipathPair dmmultipathPair( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00125 {
00126 return( ConstDmmultipathPair( dmmultipathBegin( CheckDmmultipath ), dmmultipathEnd( CheckDmmultipath ) ));
00127 }
00128 ConstDmmultipathIter dmmultipathBegin( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00129 {
00130 IterPair<DmmultipathCInter> p( (DmmultipathCInter(begin())), (DmmultipathCInter(end())) );
00131 return( ConstDmmultipathIter( DmmultipathCPIterator( p, CheckDmmultipath )) );
00132 }
00133 ConstDmmultipathIter dmmultipathEnd( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00134 {
00135 IterPair<DmmultipathCInter> p( (DmmultipathCInter(begin())), (DmmultipathCInter(end())) );
00136 return( ConstDmmultipathIter( DmmultipathCPIterator( p, CheckDmmultipath, true )) );
00137 }
00138
00139 DmmultipathCo( Storage * const s, const string& File );
00140 virtual void print( std::ostream& s ) const { s << *this; }
00141 virtual Container* getCopy() const { return( new DmmultipathCo( *this ) ); }
00142 void getMultipathData( const string& name );
00143 void addMultipath( const string& name );
00144 void addPv( Pv*& p );
00145 void newP( DmPart*& dm, unsigned num, Partition* p );
00146 string setDiskLabelText( bool doing ) const;
00147
00148 static string undevName( const string& name );
00149
00150 static void activate( bool val=true );
00151 static bool isActive() { return active; }
00152
00153 static bool isActivated(const string& name);
00154 static list<string> getMultipaths();
00155
00156 static bool multipathNotDeleted( const Dmmultipath&d ) { return( !d.deleted() ); }
00157
00158 void logData( const string& Dir );
00159
00160 string vendor;
00161 string model;
00162
00163 static bool active;
00164 };
00165
00166 }
00167
00168 #endif