yast2-storage

DmmultipathCo.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) [2004-2009] Novell, Inc.
00003  *
00004  * All Rights Reserved.
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of version 2 of the GNU General Public License as published
00008  * by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful, but WITHOUT
00011  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013  * more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, contact Novell, Inc.
00017  *
00018  * To contact Novell about this file by physical or electronic mail, you may
00019  * find current contact information at www.novell.com.
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         // iterators over partitions
00090         // protected typedefs for iterators over partitions
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         void newP( DmPart*& dm, unsigned num, Partition* p, SystemInfo& si );
00143 
00144         static void activate(bool val);
00145         static bool isActive() { return active; }
00146 
00147         static list<string> getMultipaths(SystemInfo& systeminfo);
00148 
00149         string vendor;
00150         string model;
00151 
00152         static bool active;
00153 
00154     private:
00155 
00156         DmmultipathCo& operator=(const DmmultipathCo&); // disallow
00157 
00158     };
00159 
00160 }
00161 
00162 #endif