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 "storage/DmPartCo.h"
00029 #include "storage/Dmmultipath.h"
00030
00031 namespace storage
00032 {
00033
00034 class Storage;
00035 class SystemInfo;
00036
00037
00038 class CmdMultipath
00039 {
00040
00041 public:
00042
00043 CmdMultipath(bool test = false);
00044
00045 struct Entry
00046 {
00047 string vendor;
00048 string model;
00049 list<string> devices;
00050 };
00051
00052 list<string> getEntries() const;
00053
00054 bool getEntry(const string& name, Entry& entry) const;
00055
00056 bool looksLikeRealMultipath() const;
00057
00058 private:
00059
00060 typedef map<string, Entry>::const_iterator const_iterator;
00061
00062 map<string, Entry> data;
00063
00064 };
00065
00066
00067 class DmmultipathCo : public DmPartCo
00068 {
00069 friend class Storage;
00070
00071 public:
00072
00073 DmmultipathCo(Storage* s, const string& name, const string& device, SystemInfo& systeminfo);
00074 DmmultipathCo(const DmmultipathCo& c);
00075 virtual ~DmmultipathCo();
00076
00077 static storage::CType staticType() { return storage::DMMULTIPATH; }
00078 friend std::ostream& operator<< (std::ostream&, const DmmultipathCo& );
00079 void getInfo( storage::DmmultipathCoInfo& info ) const;
00080 void setUdevData(const list<string>& id);
00081
00082 bool equalContent( const Container& rhs ) const;
00083
00084 void logDifference(std::ostream& log, const DmmultipathCo& rhs) const;
00085 virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
00086
00087 protected:
00088
00089
00090
00091 typedef CastIterator<VIter, Dmmultipath *> DmmultipathInter;
00092 typedef CastIterator<CVIter, const Dmmultipath *> DmmultipathCInter;
00093 template< class Pred >
00094 struct DmmultipathPI { typedef ContainerIter<Pred, DmmultipathInter> type; };
00095 template< class Pred >
00096 struct DmmultipathCPI { typedef ContainerIter<Pred, DmmultipathCInter> type; };
00097 typedef CheckFnc<const Dmmultipath> CheckFncDmmultipath;
00098 typedef CheckerIterator< CheckFncDmmultipath, DmmultipathPI<CheckFncDmmultipath>::type,
00099 DmmultipathInter, Dmmultipath > DmmultipathPIterator;
00100 typedef CheckerIterator< CheckFncDmmultipath, DmmultipathCPI<CheckFncDmmultipath>::type,
00101 DmmultipathCInter, const Dmmultipath > DmmultipathCPIterator;
00102 typedef DerefIterator<DmmultipathPIterator,Dmmultipath> DmmultipathIter;
00103 typedef DerefIterator<DmmultipathCPIterator,const Dmmultipath> ConstDmmultipathIter;
00104 typedef IterPair<DmmultipathIter> DmmultipathPair;
00105 typedef IterPair<ConstDmmultipathIter> ConstDmmultipathPair;
00106
00107 DmmultipathPair dmmultipathPair( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00108 {
00109 return( DmmultipathPair( dmmultipathBegin( CheckDmmultipath ), dmmultipathEnd( CheckDmmultipath ) ));
00110 }
00111 DmmultipathIter dmmultipathBegin( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00112 {
00113 IterPair<DmmultipathInter> p( (DmmultipathInter(begin())), (DmmultipathInter(end())) );
00114 return( DmmultipathIter( DmmultipathPIterator( p, CheckDmmultipath )) );
00115 }
00116 DmmultipathIter dmmultipathEnd( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00117 {
00118 IterPair<DmmultipathInter> p( (DmmultipathInter(begin())), (DmmultipathInter(end())) );
00119 return( DmmultipathIter( DmmultipathPIterator( p, CheckDmmultipath, true )) );
00120 }
00121
00122 ConstDmmultipathPair dmmultipathPair( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00123 {
00124 return( ConstDmmultipathPair( dmmultipathBegin( CheckDmmultipath ), dmmultipathEnd( CheckDmmultipath ) ));
00125 }
00126 ConstDmmultipathIter dmmultipathBegin( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00127 {
00128 IterPair<DmmultipathCInter> p( (DmmultipathCInter(begin())), (DmmultipathCInter(end())) );
00129 return( ConstDmmultipathIter( DmmultipathCPIterator( p, CheckDmmultipath )) );
00130 }
00131 ConstDmmultipathIter dmmultipathEnd( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00132 {
00133 IterPair<DmmultipathCInter> p( (DmmultipathCInter(begin())), (DmmultipathCInter(end())) );
00134 return( ConstDmmultipathIter( DmmultipathCPIterator( p, CheckDmmultipath, true )) );
00135 }
00136
00137 virtual void print( std::ostream& s ) const { s << *this; }
00138 virtual Container* getCopy() const { return( new DmmultipathCo( *this ) ); }
00139 void getMultipathData(const string& name, SystemInfo& systeminfo);
00140 void addPv(const Pv& pv);
00141 void newP( DmPart*& dm, unsigned num, Partition* p );
00142
00143 static void activate(bool val);
00144 static bool isActive() { return active; }
00145
00146 static list<string> getMultipaths(SystemInfo& systeminfo);
00147
00148 string vendor;
00149 string model;
00150
00151 static bool active;
00152
00153 private:
00154
00155 DmmultipathCo& operator=(const DmmultipathCo&);
00156
00157 };
00158
00159 }
00160
00161 #endif