From mboxrd@z Thu Jan 1 00:00:00 1970 From: kupcevic@sourceware.org Date: 10 Aug 2006 22:53:24 -0000 Subject: [Cluster-devel] conga/ricci common/ClientSocket.cpp common/Exc ... Message-ID: <20060810225324.31942.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: kupcevic at sourceware.org 2006-08-10 22:53:09 Modified files: ricci/common : ClientSocket.cpp Except.cpp Logger.cpp Module.cpp Random.cpp ServerSocket.cpp Socket.cpp Thread.cpp Time.cpp Variable.cpp XML.cpp executils.cpp executils_test.cpp utils.cpp ricci/include : APIerror.h Except.h Logger.h Module.h Socket.h Time.h Variable.h XML.h XML_tags.h executils.h utils.h ricci/modules/cluster: ClusterConf.cpp ClusterModule.cpp ClusterStatus.cpp Clusvcadm.cpp Clusvcadm.h Fence.cpp Fence.h main.cpp ricci/modules/cluster/clumon/src/cim-provider: ClusterProvider.cpp ricci/modules/cluster/clumon/src/common: Cluster.cpp ClusterMonitor.cpp Node.cpp Service.cpp ricci/modules/cluster/clumon/src/daemon: Communicator.cpp Communicator.h Monitor.cpp Monitor.h Peer.cpp Peer.h main.cpp ricci/modules/cluster/clumon/src/include: Cluster.h ClusterMonitor.h ricci/modules/cluster/clumon/src/snmp-agent: clusterMIB.cpp nodesMIB_access.cpp servicesMIB_access.cpp ricci/modules/log: LogParser.cpp LogParser.h LoggingModule.cpp main.cpp ricci/modules/rpm: PackageHandler.cpp PackageHandler.h RpmModule.cpp main.cpp ricci/modules/service: ServiceManager.cpp ServiceManager.h ServiceModule.cpp main.cpp ricci/modules/storage: BD.cpp BD.h BDFactory.cpp BDFactory.h ClusterNotQuorateError.h ClvmdError.h Content.cpp Content.h ContentExtendedPartition.cpp ContentExtendedPartition.h ContentFS.cpp ContentFS.h ContentFactory.cpp ContentFactory.h ContentNone.cpp ContentNone.h ContentUnusable.cpp ContentUnusable.h ExtendedFS.cpp ExtendedFS.h FSController.cpp FSController.h HD.cpp HD.h LV.cpp LV.h LVM.cpp LVM.h MDRaid.cpp MDRaid.h MDRaidSource.cpp MDRaidSource.h MDRaidTarget.cpp MDRaidTarget.h Mapper.cpp Mapper.h MapperFactory.cpp MapperFactory.h MapperSource.cpp MapperSource.h MountHandler.cpp MountHandler.h PTSource.cpp PTSource.h PV.cpp PV.h Partition.cpp Partition.h PartitionTable.cpp PartitionTable.h Props.cpp Props.h StorageModule.cpp SwapFS.cpp SwapFS.h System.cpp System.h UMountError.h VG.cpp VG.h defines.h main.cpp mdadm_wrapper.cpp mdadm_wrapper.h parted_wrapper.cpp parted_wrapper.h ricci/ricci : Auth.cpp Auth.h ClientInstance.cpp DBusController.cpp DBusController.h QueueLocker.cpp Ricci.cpp Ricci.h RicciWorker.cpp RicciWorker.h SSLInstance.cpp SSLInstance.h Server.cpp auth_helper.cpp dbus_test.cpp main.cpp Added files: ricci/include : shred_allocator.h Log message: ricci: shred temp files and memory used for strings that are exchanged with clients (includes root password) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/ClientSocket.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Except.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Logger.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Module.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Random.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/ServerSocket.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Socket.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Thread.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Time.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Variable.cpp.diff?cvsroot=cluster&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/XML.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/executils.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/executils_test.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/utils.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/shred_allocator.h.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/APIerror.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Except.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Logger.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Module.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Socket.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Time.h.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Variable.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/XML.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/XML_tags.h.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/executils.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/utils.h.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterConf.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterModule.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterStatus.cpp.diff?cvsroot=cluster&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Clusvcadm.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Clusvcadm.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Fence.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Fence.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/main.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/cim-provider/ClusterProvider.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/common/Cluster.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/common/ClusterMonitor.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/common/Node.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/common/Service.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Communicator.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Monitor.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Peer.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Peer.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/main.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/include/Cluster.h.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/include/ClusterMonitor.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/snmp-agent/clusterMIB.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/snmp-agent/nodesMIB_access.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/snmp-agent/servicesMIB_access.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/LogParser.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/LogParser.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/LoggingModule.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/main.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/PackageHandler.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/PackageHandler.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/RpmModule.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/main.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceModule.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/main.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/BD.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/BD.h.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/BDFactory.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/BDFactory.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ClusterNotQuorateError.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ClvmdError.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Content.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Content.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentExtendedPartition.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentExtendedPartition.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentFS.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentFS.h.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentFactory.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentFactory.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentNone.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentNone.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentUnusable.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ContentUnusable.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ExtendedFS.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ExtendedFS.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/FSController.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/FSController.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/HD.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/HD.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/LV.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/LV.h.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/LVM.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/LVM.h.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MDRaid.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MDRaid.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MDRaidSource.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MDRaidSource.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MDRaidTarget.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MDRaidTarget.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Mapper.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Mapper.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MapperFactory.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MapperFactory.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MapperSource.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MapperSource.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MountHandler.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MountHandler.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/PTSource.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/PTSource.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/PV.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/PV.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Partition.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Partition.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/PartitionTable.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/PartitionTable.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Props.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Props.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/StorageModule.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/SwapFS.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/SwapFS.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/System.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/System.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/UMountError.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/VG.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/VG.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/defines.h.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/main.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/mdadm_wrapper.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/mdadm_wrapper.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Auth.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Auth.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/ClientInstance.cpp.diff?cvsroot=cluster&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/DBusController.cpp.diff?cvsroot=cluster&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/DBusController.h.diff?cvsroot=cluster&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/QueueLocker.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.cpp.diff?cvsroot=cluster&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.h.diff?cvsroot=cluster&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/RicciWorker.cpp.diff?cvsroot=cluster&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/RicciWorker.h.diff?cvsroot=cluster&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/SSLInstance.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/SSLInstance.h.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Server.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/auth_helper.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/dbus_test.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/main.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 --- conga/ricci/common/ClientSocket.cpp 2006/05/25 15:54:56 1.3 +++ conga/ricci/common/ClientSocket.cpp 2006/08/10 22:53:07 1.4 @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include @@ -43,12 +43,12 @@ _addr(addr) {} -ClientSocket::ClientSocket(const std::string& sock_path) : +ClientSocket::ClientSocket(const String& sock_path) : Socket(-1) { _sock = socket(PF_UNIX, SOCK_STREAM, 0); if (_sock == -1) - throw std::string("ClientSocket(string): socket() failed"); + throw String("ClientSocket(String): socket() failed"); struct sockaddr_un { sa_family_t sun_family; @@ -58,24 +58,24 @@ memcpy(addr.sun_path, sock_path.c_str(), sock_path.size()+1); if (connect(_sock, (struct sockaddr*) &addr, sizeof(addr))) { - throw std::string("ClientSocket(string): connect() failed"); + throw String("ClientSocket(String): connect() failed"); } - // std::string msg = std::string("created client socket ") + _sock; + // String msg = String("created client socket ") + _sock; // msg += ", and connected to " + sock_path; // log(msg, LogSocket); } -ClientSocket::ClientSocket(const std::string& hostname, unsigned short port) : +ClientSocket::ClientSocket(const String& hostname, unsigned short port) : Socket(-1) { _sock = socket(PF_INET, SOCK_STREAM, 0); if (_sock == -1) - throw std::string("ClientSocket(hostname, port): socket() failed"); + throw String("ClientSocket(hostname, port): socket() failed"); struct hostent* ent = gethostbyname2(hostname.c_str(), AF_INET); if (!ent) - throw std::string("ClientSocket(hostname, port): gethostbyname() failed"); + throw String("ClientSocket(hostname, port): gethostbyname() failed"); char** addrs = ent->h_addr_list; for (int i=0; addrs[i]; i++) { @@ -86,14 +86,14 @@ if (connect(_sock, (struct sockaddr*) &addr_in, sizeof(addr_in))) continue; else { - // std::string msg = std::string("created client socket ") + _sock; + // String msg = String("created client socket ") + _sock; // msg += ", and connected to " + hostname + ", port " + port; // log(msg, LogSocket); _addr = addr_in.sin_addr.s_addr; return; } } - throw std::string("ClientSocket(hostname, port): connect() failed"); + throw String("ClientSocket(hostname, port): connect() failed"); } ClientSocket::ClientSocket(const ClientSocket& s) : @@ -116,7 +116,7 @@ bool -ClientSocket::connected_to(const std::string& hostname) +ClientSocket::connected_to(const String& hostname) { struct hostent* ent = gethostbyname2(hostname.c_str(), AF_INET); if (!ent) @@ -129,11 +129,11 @@ return false; } -std::string +String ClientSocket::recv() { if (_sock == -1) - throw std::string("ClientSocket::recv(): socket already closed"); + throw String("ClientSocket::recv(): socket already closed"); while (true) { char buffer[1024]; @@ -143,25 +143,25 @@ continue; else if (errno == EAGAIN) return ""; - throw std::string("ClientSocket::recv(): recv error"); + throw String("ClientSocket::recv(): recv error"); } if (ret == 0) { close(); - throw std::string("ClientSocket::recv(): socket has been shutdown"); + throw String("ClientSocket::recv(): socket has been shutdown"); } - // log(std::string("received ") + ret + " bytes from socket " + _sock, + // log(String("received ") + ret + " bytes from socket " + _sock, // LogLevel(LogSocket|LogTransfer)); - return std::string(buffer, ret); + return String(buffer, ret); } } -std::string -ClientSocket::send(const std::string& msg) +String +ClientSocket::send(const String& msg) { if (_sock == -1) - throw std::string("ClientSocket::send(): socket already closed"); + throw String("ClientSocket::send(): socket already closed"); while (true) { int ret = ::send(_sock, msg.c_str(), msg.size(), 0); @@ -171,10 +171,10 @@ else if (errno == EAGAIN || errno == EWOULDBLOCK) return msg; - throw std::string("ClientSocket::recv(): socket error"); + throw String("ClientSocket::recv(): socket error"); } - // log(std::string("sent ") + ret + " bytes thru socket " + _sock, + // log(String("sent ") + ret + " bytes thru socket " + _sock, // LogLevel(LogSocket|LogTransfer)); return msg.substr(ret); } --- conga/ricci/common/Except.cpp 2006/04/07 16:49:00 1.1 +++ conga/ricci/common/Except.cpp 2006/08/10 22:53:07 1.2 @@ -29,11 +29,11 @@ Except::Except(long long error_code, - const std::string& msg) : + const String& msg) : _code(error_code), _msg(msg) { if (_code == generic_error) - throw string("Exception() invalid error_code"); + throw String("Exception() invalid error_code"); } Except::~Except() @@ -45,7 +45,7 @@ return _code; } -std::string +String Except::description() const { return _msg; --- conga/ricci/common/Logger.cpp 2006/03/06 21:48:04 1.1 +++ conga/ricci/common/Logger.cpp 2006/08/10 22:53:07 1.2 @@ -30,7 +30,7 @@ #include #include #include -#include +#include "String.h" using namespace std; @@ -44,8 +44,8 @@ _domain_c(NULL) {} -Logger::Logger(const std::string& filepath, - const std::string& domain, +Logger::Logger(const String& filepath, + const String& domain, LogLevel level) : _level(level) { @@ -54,7 +54,7 @@ _domain_c = (char*) malloc(domain.size()+1); if (_domain_c == NULL) - throw string("Logger::Logger(): malloc() failed"); + throw String("Logger::Logger(): malloc() failed"); strcpy(_domain_c, c_str); _fd = open(path_c, @@ -62,11 +62,11 @@ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (_fd == -1) { free(_domain_c); - throw string("Logger::Logger(): open() failed"); + throw String("Logger::Logger(): open() failed"); } } -Logger::Logger(int fd, const std::string& domain, LogLevel level) : +Logger::Logger(int fd, const String& domain, LogLevel level) : _fd(fd), _level(level) { @@ -75,7 +75,7 @@ _domain_c = (char*) malloc(domain.size()+1); if (_domain_c == NULL) { close_fd(); - throw string("Logger::Logger(): malloc() failed"); + throw String("Logger::Logger(): malloc() failed"); } strcpy(_domain_c, c_str); } @@ -101,7 +101,7 @@ } void -Logger::log(const std::string& msg, LogLevel level) +Logger::log(const String& msg, LogLevel level) { log_sigsafe(msg.c_str(), level); } @@ -139,24 +139,24 @@ // ### helper functions ### -std::string -operator+ (const std::string& s, int i) +String +operator+ (const String& s, int i) { char buff[128]; snprintf(buff, sizeof(buff), "%d", i); return s + buff; } -std::string -operator+ (int i, const std::string& s) +String +operator+ (int i, const String& s) { char buff[128]; snprintf(buff, sizeof(buff), "%d", i); - return string(buff) + s; + return String(buff) + s; } void -log(const std::string& msg, LogLevel level) +log(const String& msg, LogLevel level) { logger->log(msg, level); } --- conga/ricci/common/Module.cpp 2006/04/13 18:06:14 1.3 +++ conga/ricci/common/Module.cpp 2006/08/10 22:53:07 1.4 @@ -45,7 +45,7 @@ static VarMap extract_vars(const XMLObject& xml); static void insert_vars(const VarMap& vars, XMLObject& xml); -static string clean_string(const string& msg); +static String clean_string(const String& msg); @@ -61,7 +61,7 @@ for (ApiFcnMap::const_iterator api_iter = api_fcns.begin(); api_iter != api_fcns.end(); api_iter++) { - const string& api_vers = api_iter->first; + const String& api_vers = api_iter->first; if (api_vers.empty()) continue; FcnMap funcs = api_iter->second; @@ -81,22 +81,22 @@ if (request.tag() != REQUEST_TAG) throw APIerror("missing request tag"); - string version = request.get_attr(MOD_VERSION_TAG); + String version = request.get_attr(MOD_VERSION_TAG); if (_api_fcns.find(version) == _api_fcns.end()) throw APIerror("unsupported API version"); if (request.children().size() != 1) - throw APIerror(string("missing ") + FUNC_CALL_TAG); + throw APIerror(String("missing ") + FUNC_CALL_TAG); const XMLObject& func_xml = request.children().front(); if (func_xml.tag() != FUNC_CALL_TAG) - throw APIerror(string("missing ") + FUNC_CALL_TAG); + throw APIerror(String("missing ") + FUNC_CALL_TAG); - string fcn_name = func_xml.get_attr("name"); + String fcn_name = func_xml.get_attr("name"); if (fcn_name.empty()) throw APIerror("missing function name"); FcnMap& fcns = _api_fcns[version]; if (fcns.find(fcn_name) == fcns.end()) - throw APIerror(string("function '") + fcn_name + "' not in API '" + version + "'"); + throw APIerror(String("function '") + fcn_name + "' not in API '" + version + "'"); // construct response xml XMLObject response(RESPONSE_TAG); @@ -105,15 +105,15 @@ XMLObject func_resp_xml(FUNC_RESPONSE_TAG); func_resp_xml.set_attr("function_name", fcn_name); try { - map in_vars = extract_vars(func_xml); - map out_vars = (fcns[fcn_name])(in_vars); + map in_vars = extract_vars(func_xml); + map out_vars = (fcns[fcn_name])(in_vars); insert_vars(out_vars, func_resp_xml); func_resp_xml.add_child(Variable("success", true).xml()); } catch (Except e) { func_resp_xml.add_child(Variable("success", false).xml()); func_resp_xml.add_child(Variable("error_code", e.code()).xml()); func_resp_xml.add_child(Variable("error_description", e.description()).xml()); - } catch ( string e ) { + } catch ( String e ) { func_resp_xml.add_child(Variable("success", false).xml()); func_resp_xml.add_child(Variable("error_code", Except::generic_error).xml()); func_resp_xml.add_child(Variable("error_description", clean_string(e)).xml()); @@ -122,14 +122,14 @@ } catch ( ... ) { func_resp_xml.add_child(Variable("success", false).xml()); func_resp_xml.add_child(Variable("error_code", Except::generic_error).xml()); - func_resp_xml.add_child(Variable("error_description", string("No description")).xml()); + func_resp_xml.add_child(Variable("error_description", String("No description")).xml()); } response.add_child(func_resp_xml); return response; } catch ( APIerror e ) { XMLObject err_resp("API_error"); err_resp.set_attr("description", e.msg); - insert_vars(list_APIs(map()), err_resp); + insert_vars(list_APIs(map()), err_resp); return err_resp; } catch ( ... ) { XMLObject err_resp("internal_error"); @@ -141,13 +141,13 @@ VarMap extract_vars(const XMLObject& xml) { - map args; + map args; for (list::const_iterator iter = xml.children().begin(); iter != xml.children().end(); iter++) { try { Variable var(*iter); - args.insert(pair(var.name(), var)); + args.insert(pair(var.name(), var)); } catch ( ... ) {} } return args; @@ -166,7 +166,7 @@ VarMap list_APIs(const VarMap& args) { - list apis; + list apis; for (ApiFcnMap::const_iterator iter = _api_fcns.begin(); iter != _api_fcns.end(); iter++) @@ -174,16 +174,16 @@ Variable api_var("APIs", apis); VarMap ret; - ret.insert(pair(api_var.name(), api_var)); + ret.insert(pair(api_var.name(), api_var)); return ret; } -string -clean_string(const string& msg) +String +clean_string(const String& msg) { - string ret(msg); - string::size_type i; + String ret(msg); + String::size_type i; while ((i = ret.find_first_of("\"<>")) != ret.npos) ret[i] = ' '; return ret; @@ -212,7 +212,7 @@ stdin_out_module_driver(Module& module) { unsigned int time_beg = time_mil(); - string data; + String data; while (time_mil() < time_beg + timeout) { poll_fd poll_data; @@ -230,7 +230,7 @@ if (errno == EINTR) continue; else - throw string("poll() error"); + throw String("poll() error"); } // process event @@ -240,7 +240,7 @@ if (ret == -1) { if (errno == EINTR) continue; - throw std::string("error reading stdin"); + throw String("error reading stdin"); } try { data.append(buff, ret); @@ -252,11 +252,11 @@ continue; } if (poll_data.revents & (POLLERR | POLLHUP | POLLNVAL)) - throw string("stdin error???"); + throw String("stdin error???"); } // while // cout << data << endl; - throw string("invalid input"); + throw String("invalid input"); } --- conga/ricci/common/Random.cpp 2006/03/23 16:29:37 1.1 +++ conga/ricci/common/Random.cpp 2006/08/10 22:53:07 1.2 @@ -26,7 +26,7 @@ #include "Time.h" #include -#include +#include "String.h" static Mutex mutex; @@ -42,7 +42,7 @@ int range = max - min; if (range <= 5) - throw std::string("random_generate(min, max): range too small"); + throw String("random_generate(min, max): range too small"); return (int) (min + range * ((double) rand_r(&seed))/RAND_MAX); } --- conga/ricci/common/ServerSocket.cpp 2006/04/03 14:50:57 1.2 +++ conga/ricci/common/ServerSocket.cpp 2006/08/10 22:53:07 1.3 @@ -30,18 +30,18 @@ #include #include #include -#include +#include "String.h" -ServerSocket::ServerSocket(const std::string& sock_path) : +ServerSocket::ServerSocket(const String& sock_path) : Socket(-1), _unix_sock(true), _sock_path(sock_path) { _sock = socket(PF_UNIX, SOCK_STREAM, 0); if (_sock == -1) { - std::string m = std::string("ServerSocket(sock_path=") + sock_path + "): socket() failed, errno=" + errno; + String m = String("ServerSocket(sock_path=") + sock_path + "): socket() failed, errno=" + errno; throw m; } @@ -54,16 +54,16 @@ unlink(_sock_path.c_str()); if (bind(_sock, (struct sockaddr*) &addr, sizeof(addr))) { - std::string m = std::string("ServerSocket(sock_path=") + sock_path + "): bind() failed, errno=" + errno; + String m = String("ServerSocket(sock_path=") + sock_path + "): bind() failed, errno=" + errno; throw m; } if (listen(_sock, 5)) { - std::string m = std::string("ServerSocket(sock_path=") + sock_path + "): listen() failed, errno=" + errno; + String m = String("ServerSocket(sock_path=") + sock_path + "): listen() failed, errno=" + errno; throw m; } - std::string msg = std::string("created unix server socket, ") + _sock + ", " + sock_path; + String msg = String("created unix server socket, ") + _sock + ", " + sock_path; // log(msg, LogSocket); } @@ -74,7 +74,7 @@ { _sock = socket(PF_INET, SOCK_STREAM, 0); if (_sock == -1) { - std::string m = std::string("ServerSocket(port=") + port + "): socket() failed, errno=" + errno; + String m = String("ServerSocket(port=") + port + "): socket() failed, errno=" + errno; throw m; } @@ -83,16 +83,16 @@ addr.sin_port = htons(port); addr.sin_addr.s_addr = INADDR_ANY; if (bind(_sock, (struct sockaddr*) &addr, sizeof(addr))) { - std::string m = std::string("ServerSocket(port=") + port + "): bind() failed, errno=" + errno; + String m = String("ServerSocket(port=") + port + "): bind() failed, errno=" + errno; throw m; } if (listen(_sock, 5)) { - std::string m = std::string("ServerSocket(port=") + port + "): listen() failed, errno=" + errno; + String m = String("ServerSocket(port=") + port + "): listen() failed, errno=" + errno; throw m; } - std::string msg = std::string("created tcp server socket, ") + _sock + ", port " + port; + String msg = String("created tcp server socket, ") + _sock + ", port " + port; // log(msg, LogSocket); } @@ -130,7 +130,7 @@ if (ret == -1) { if (errno == EINTR) continue; - throw std::string("ServerSocket(): accept() failed"); + throw String("ServerSocket(): accept() failed"); } // log("ServerSocket: accepted connection", LogSocket); return ClientSocket(ret, addr_in.sin_addr.s_addr); --- conga/ricci/common/Socket.cpp 2006/04/03 14:50:57 1.2 +++ conga/ricci/common/Socket.cpp 2006/08/10 22:53:07 1.3 @@ -46,7 +46,7 @@ _counter = counting_auto_ptr(new int(1)); } catch ( ... ) { close(); - throw std::string("Socket(int sock) failed"); + throw String("Socket(int sock) failed"); } } @@ -85,7 +85,7 @@ Socket::close() { if (_sock != -1) { - log(std::string("closing socket ") + _sock, LogSocket); + log(String("closing socket ") + _sock, LogSocket); shutdown(_sock, SHUT_RDWR); int e; do { @@ -112,10 +112,10 @@ Socket::nonblocking() { if (!valid()) - throw std::string("socket not valid"); + throw String("socket not valid"); int flags = fcntl(_sock, F_GETFL); if (flags == -1) - throw std::string("fcntl() failed"); + throw String("fcntl() failed"); return flags & O_NONBLOCK; } @@ -123,17 +123,17 @@ Socket::nonblocking(bool mode) { if (!valid()) - throw std::string("socket not valid"); + throw String("socket not valid"); int old_flags = fcntl(_sock, F_GETFL); if (old_flags == -1) - throw std::string("fcntl() failed"); + throw String("fcntl() failed"); int new_flags; if (mode) new_flags = old_flags | O_NONBLOCK; else new_flags = old_flags & ~O_NONBLOCK; if (fcntl(_sock, F_SETFL, new_flags)) - throw std::string("fcntl() failed"); + throw String("fcntl() failed"); return old_flags & O_NONBLOCK; } @@ -143,7 +143,7 @@ int timeout) { if (!valid()) - throw std::string("socket not valid"); + throw String("socket not valid"); poll_fd poll_data; poll_data.fd = _sock; @@ -169,7 +169,7 @@ if (errno == EINTR) continue; else - throw std::string("poll() error"); + throw String("poll() error"); } else { if (poll_data.revents & POLLIN) read = true; @@ -184,11 +184,11 @@ -std::vector -name2IP(const std::string& hostname) +std::vector +name2IP(const String& hostname) { char buff[INET_ADDRSTRLEN+1]; - std::vector addrs; + std::vector addrs; struct hostent* ent = gethostbyname2(hostname.c_str(), AF_INET); if (!ent) return addrs; --- conga/ricci/common/Thread.cpp 2006/03/06 21:48:04 1.1 +++ conga/ricci/common/Thread.cpp 2006/08/10 22:53:07 1.2 @@ -23,7 +23,7 @@ #include "Thread.h" //#include "Logger.h" -#include +#include "String.h" @@ -45,7 +45,7 @@ Thread::~Thread() { - // log(std::string("entered destructor of thread ") + (int) _thread, LogThread); + // log(String("entered destructor of thread ") + (int) _thread, LogThread); Thread::stop(); } @@ -61,7 +61,7 @@ _stop = false; } pthread_create(&_thread, NULL, start_thread, this); - // log(std::string("created thread ") + (int) _thread, LogThread); + // log(String("created thread ") + (int) _thread, LogThread); _running = true; } } @@ -69,18 +69,18 @@ void Thread::stop() { - // log(std::string("entered Thread::stop() for thread ") + (int) _thread, LogThread); + // log(String("entered Thread::stop() for thread ") + (int) _thread, LogThread); MutexLocker l1(_main_mutex); if (_running) { { - // log(std::string("Thread::stop(): locking stop mutex for thread ") + (int) _thread, LogThread); + // log(String("Thread::stop(): locking stop mutex for thread ") + (int) _thread, LogThread); MutexLocker l2(_stop_mutex); _stop = true; } - // log(std::string("entering pthread_join() for thread ") + (int) _thread, LogThread); + // log(String("entering pthread_join() for thread ") + (int) _thread, LogThread); if (pthread_join(_thread, NULL)) - throw std::string("error stopping thread"); - // log(std::string("stopped thread ") + (int) _thread, LogThread); + throw String("error stopping thread"); + // log(String("stopped thread ") + (int) _thread, LogThread); _running = false; } } @@ -88,7 +88,7 @@ bool Thread::running() { - // log(std::string("entered Thread::running() for thread ") + (int) _thread, LogThread); + // log(String("entered Thread::running() for thread ") + (int) _thread, LogThread); MutexLocker l1(_main_mutex); bool ret = _running; return ret; @@ -97,7 +97,7 @@ bool Thread::shouldStop() { - // log(std::string("entered Thread::shouldStop() for thread ") + (int) _thread, LogThread); + // log(String("entered Thread::shouldStop() for thread ") + (int) _thread, LogThread); MutexLocker l(_stop_mutex); bool ret = _stop; return ret; --- conga/ricci/common/Time.cpp 2006/06/20 19:37:22 1.3 +++ conga/ricci/common/Time.cpp 2006/08/10 22:53:07 1.4 @@ -45,13 +45,13 @@ return t.tv_sec*1000 + t.tv_usec/1000; } -std::string +String time_formated() { char time[64]; time_t t = time_sec(); ctime_r(&t, time); - std::string m(time); + String m(time); return m.substr(0, m.size()-1); } --- conga/ricci/common/Variable.cpp 2006/07/12 18:27:26 1.6 +++ conga/ricci/common/Variable.cpp 2006/08/10 22:53:07 1.7 @@ -37,11 +37,11 @@ Variable::Variable(const XMLObject& xml) { if (xml.tag() != VARIABLE_TAG) - throw string("not a variable"); + throw String("not a variable"); _name = xml.get_attr("name"); if (_name == "") - throw string("invalid variable name"); + throw String("invalid variable name"); _mutable = (xml.get_attr("mutable") == "true"); @@ -49,7 +49,7 @@ // _validator = Validator(xml); // incoming limits are not to be trusted anyhow - string type(xml.get_attr("type")); + String type(xml.get_attr("type")); if (type == VARIABLE_INT) { _type = Integer; _val_int = utils::to_long(xml.get_attr("value").c_str()); @@ -60,7 +60,7 @@ _type = Boolean; _val_bool = (xml.get_attr("value") == "true"); } else if (type == VARIABLE_STR) { - _type = String; + _type = StringVar; _val_str = xml.get_attr("value"); } else if (type == VARIABLE_STR_SEL) { _type = StrSel; @@ -68,7 +68,7 @@ } else if (type == VARIABLE_XML) { _type = XMLVar; if (xml.children().empty()) - throw string("variable missing XML value"); + throw String("variable missing XML value"); else _val_xml = xml.children().front(); } else if (type == VARIABLE_LIST_INT) { @@ -96,7 +96,7 @@ iter++) _val_list_XML.push_back(*iter); } else - throw string("invalid variable type"); + throw String("invalid variable type"); } @@ -104,7 +104,7 @@ // integer -Variable::Variable(const std::string& name, +Variable::Variable(const String& name, long long value) : _name(name), _type(Integer), @@ -112,7 +112,7 @@ { set_value(value); } -Variable::Variable(const std::string& name, +Variable::Variable(const String& name, long long value, long long min, long long max, @@ -127,7 +127,7 @@ // integer selector -Variable::Variable(const std::string& name, +Variable::Variable(const String& name, long long value, const std::list& valid_values) : _name(name), @@ -140,7 +140,7 @@ // integer list -Variable::Variable(const std::string& name, +Variable::Variable(const String& name, const std::list& value, bool mutabl) : _name(name), @@ -152,7 +152,7 @@ // boolean -Variable::Variable(const std::string& name, +Variable::Variable(const String& name, bool value, bool mutabl) : _name(name), @@ -164,22 +164,22 @@ // string -Variable::Variable(const std::string& name, - const std::string& value) : +Variable::Variable(const String& name, + const String& value) : _name(name), - _type(String), + _type(StringVar), _mutable(false) { set_value(value); } -Variable::Variable(const std::string& name, - const std::string& value, +Variable::Variable(const String& name, + const String& value, long long min_length, long long max_length, - const std::string& illegal_chars, - const std::list& reserved_words) : + const String& illegal_chars, + const std::list& reserved_words) : _name(name), - _type(String), + _type(StringVar), _mutable(true), _validator(min_length, max_length, @@ -191,9 +191,9 @@ // string selector -Variable::Variable(const std::string& name, - const std::string& value, - const std::list& valid_values) : +Variable::Variable(const String& name, + const String& value, + const std::list& valid_values) : _name(name), _type(StrSel), _mutable(true), @@ -204,8 +204,8 @@ // string list -Variable::Variable(const std::string& name, - const std::list& value, +Variable::Variable(const String& name, + const std::list& value, bool mutabl) : _name(name), _type(ListStr), @@ -216,7 +216,7 @@ // XML -Variable::Variable(const std::string& name, +Variable::Variable(const String& name, const XMLObject& value) : _name(name), _type(XMLVar), @@ -226,7 +226,7 @@ } // XML list -Variable::Variable(const std::string& name, +Variable::Variable(const String& name, const std::list& value) : _name(name), _type(ListXML), @@ -244,14 +244,14 @@ Variable::get_int() const { if (_type != Integer && _type != IntSel) - throw string("variable ") + name() + " is not of " + VARIABLE_INT + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_INT + " type"; return _val_int; } void Variable::set_value(long long value) { if (_type != Integer && _type != IntSel) - throw string("variable ") + name() + " is not of " + VARIABLE_INT + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_INT + " type"; _validator.validate(value); _val_int = value; } @@ -260,30 +260,30 @@ Variable::get_bool() const { if (_type != Boolean) - throw string("variable ") + name() + " is not of " + VARIABLE_BOOL + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_BOOL + " type"; return _val_bool; } void Variable::set_value(bool value) { if (_type != Boolean) - throw string("variable ") + name() + " is not of " + VARIABLE_BOOL + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_BOOL + " type"; _validator.validate(value); _val_bool = value; } -std::string +String Variable::get_string() const { - if (_type != String && _type != StrSel) - throw string("variable ") + name() + " is not of " + VARIABLE_STR + " type"; + if (_type != StringVar && _type != StrSel) + throw String("variable ") + name() + " is not of " + VARIABLE_STR + " type"; return _val_str; } void -Variable::set_value(const std::string& value) +Variable::set_value(const String& value) { - if (_type != String && _type != StrSel) - throw string("variable ") + name() + " is not of " + VARIABLE_STR + " type"; + if (_type != StringVar && _type != StrSel) + throw String("variable ") + name() + " is not of " + VARIABLE_STR + " type"; _validator.validate(value); _val_str = value; } @@ -292,14 +292,14 @@ Variable::get_XML() const { if (_type != XMLVar) - throw string("variable ") + name() + " is not of " + VARIABLE_XML + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_XML + " type"; return _val_xml; } void Variable::set_value(const XMLObject& value) { if (_type != XMLVar) - throw string("variable ") + name() + " is not of " + VARIABLE_XML + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_XML + " type"; _validator.validate(value); _val_xml = value; } @@ -308,30 +308,30 @@ Variable::get_list_int() const { if (_type != ListInt) - throw string("variable ") + name() + " is not of " + VARIABLE_LIST_INT + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_LIST_INT + " type"; return _val_list_int; } void Variable::set_value(const std::list& value) { if (_type != ListInt) - throw string("variable ") + name() + " is not of " + VARIABLE_LIST_INT + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_LIST_INT + " type"; _validator.validate(value); _val_list_int = value; } -std::list +std::list Variable::get_list_str() const { if (_type != ListStr) - throw string("variable ") + name() + " is not of " + VARIABLE_LIST_STR + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_LIST_STR + " type"; return _val_list_str; } void -Variable::set_value(const std::list& value) +Variable::set_value(const std::list& value) { if (_type != ListStr) - throw string("variable ") + name() + " is not of " + VARIABLE_LIST_STR + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_LIST_STR + " type"; _validator.validate(value); _val_list_str = value; } @@ -340,14 +340,14 @@ Variable::get_list_XML() const { if (_type != ListXML) - throw string("variable ") + name() + " is not of " + VARIABLE_LIST_XML + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_LIST_XML + " type"; return _val_list_XML; } void Variable::set_value(const std::list& value) { if (_type != ListXML) - throw string("variable ") + name() + " is not of " + VARIABLE_LIST_XML + " type"; + throw String("variable ") + name() + " is not of " + VARIABLE_LIST_XML + " type"; _validator.validate(value); _val_list_XML = value; } @@ -364,7 +364,7 @@ return get_int() == var.get_int(); case Boolean: return get_bool() == var.get_bool(); - case String: + case StringVar: case StrSel: return get_string() == var.get_string(); case XMLVar: @@ -389,9 +389,9 @@ Variable::validate(const Variable& var) const { if (name() != var.name()) - throw string("different variable names"); + throw String("different variable names"); if (type() != var.type()) - throw string("different variable types"); + throw String("different variable types"); switch (var.type()) { case Integer: @@ -399,7 +399,7 @@ return _validator.validate(var.get_int()); case Boolean: return _validator.validate(var.get_bool()); - case String: + case StringVar: case StrSel: return _validator.validate(var.get_string()); case XMLVar: @@ -436,7 +436,7 @@ xml.set_attr("type", VARIABLE_BOOL); xml.set_attr("value", utils::to_string(_val_bool)); break; - case String: + case StringVar: xml.set_attr("type", VARIABLE_STR); xml.set_attr("value", _val_str); break; @@ -463,7 +463,7 @@ case ListStr: xml.set_attr("type", VARIABLE_LIST_STR); i = 0; - for (list::const_iterator iter = _val_list_str.begin(); + for (list::const_iterator iter = _val_list_str.begin(); iter != _val_list_str.end(); iter++, i++) { XMLObject xml_t = XMLObject(VARIABLE_LISTENTRY); @@ -483,7 +483,7 @@ break; default: - throw string("invalid variable type"); + throw String("invalid variable type"); break; } @@ -539,8 +539,8 @@ // string Validator::Validator(long long min_length, long long max_length, - const std::string& illegal_chars, - const std::list& reserved_words) : + const String& illegal_chars, + const std::list& reserved_words) : _always_valid(false), _integer(false), _int_sel(false), @@ -554,7 +554,7 @@ } // string selector -Validator::Validator(const std::list& valid_words) : +Validator::Validator(const std::list& valid_words) : _always_valid(false), _integer(false), _int_sel(false), @@ -586,11 +586,11 @@ else return true; } else - throw string("not long long"); + throw String("not long long"); } bool -Validator::validate(const std::string& value) const +Validator::validate(const String& value) const { if (_always_valid) return true; @@ -610,7 +610,7 @@ else return true; } else - throw string("not string"); + throw String("not string"); } bool @@ -641,7 +641,7 @@ } bool -Validator::validate(const std::list& value) const +Validator::validate(const std::list& value) const { if (_always_valid) return true; @@ -679,8 +679,8 @@ xml.set_attr("min_length", utils::to_string(_min_length)); xml.set_attr("max_length", utils::to_string(_max_length)); xml.set_attr("illegal_chars", _illegal_chars); - string reserved; - for (list::const_iterator iter = _reserved_words.begin(); + String reserved; + for (list::const_iterator iter = _reserved_words.begin(); iter != _reserved_words.end(); iter++) { if (!reserved.empty()) @@ -689,7 +689,7 @@ } xml.set_attr("reserved_words", reserved); } else if (_string_sel) { - for (list::const_iterator iter = _valid_words.begin(); + for (list::const_iterator iter = _valid_words.begin(); iter != _valid_words.end(); iter++) { XMLObject entry("listentry"); --- conga/ricci/common/XML.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/common/XML.cpp 2006/08/10 22:53:07 1.3 @@ -34,7 +34,7 @@ using namespace std; -XMLObject::XMLObject(const string& elem_name) : +XMLObject::XMLObject(const String& elem_name) : _tag(elem_name) {} @@ -55,23 +55,23 @@ } bool -XMLObject::has_attr(const string& attr_name) const +XMLObject::has_attr(const String& attr_name) const { return _attrs.find(attr_name) != _attrs.end(); } -string -XMLObject::set_attr(const string& attr_name, const string& value) +String +XMLObject::set_attr(const String& attr_name, const String& value) { - string ret = _attrs[attr_name]; + String ret = _attrs[attr_name]; _attrs[attr_name] = value; return ret; } -string -XMLObject::get_attr(const string& attr_name) const +String +XMLObject::get_attr(const String& attr_name) const { - map::const_iterator iter = _attrs.find(attr_name); + map::const_iterator iter = _attrs.find(attr_name); if (iter == _attrs.end()) return ""; else @@ -98,14 +98,14 @@ } void -XMLObject::generate_xml(string& xml, const string& indent) const +XMLObject::generate_xml(String& xml, const String& indent) const { xml += indent + "<" + _tag; - for (map::const_iterator iter = attrs().begin(); + for (map::const_iterator iter = attrs().begin(); iter != attrs().end(); iter++) { - const string& name = iter->first; - const string& value = iter->second; + const String& name = iter->first; + const String& value = iter->second; xml += " " + name + "=\"" + value + "\""; } if (children().empty()) @@ -163,7 +163,7 @@ } XMLObject -parseXML(const string& xml) +parseXML(const String& xml) { static bool initialized = false; if (!initialized) { @@ -177,7 +177,7 @@ NULL, XML_PARSE_NONET); if (!doc) - throw string("parseXML(): couldn't parse xml"); + throw String("parseXML(): couldn't parse xml"); XMLObject root("if you see this, something wrong happened"); try { @@ -187,14 +187,14 @@ } catch ( ... ) { xmlFreeDoc(doc); xmlCleanupParser(); - throw string("parseXML(): low memory"); + throw String("parseXML(): low memory"); } } -string +String generateXML(const XMLObject& obj) { - string xml("\n"); + String xml("\n"); obj.generate_xml(xml, ""); // verify xml @@ -205,7 +205,7 @@ XML_PARSE_NONET); if (!doc) { // cout << xml << endl; - throw string("generateXML(): internal error"); + throw String("generateXML(): internal error"); } xmlFreeDoc(doc); --- conga/ricci/common/executils.cpp 2006/07/17 22:45:36 1.5 +++ conga/ricci/common/executils.cpp 2006/08/10 22:53:07 1.6 @@ -38,16 +38,16 @@ static void read_data(struct pollfd& poll_info, bool& fd_closed, - std::string& data); + String& data); static void close_fd(int fd); int -execute(const std::string& path, - const std::vector& args, - std::string& out, - std::string& err, +execute(const String& path, + const std::vector& args, + String& out, + String& err, int& status, int timeout) { @@ -182,7 +182,7 @@ } // while (true) // command - std::string comm(path); + String comm(path); for (unsigned int i=0; i arguments; + vector arguments; - string path; + String path; if (argc < 2) { cout << "enter path to execute: "; cin >> path; --- conga/ricci/common/executils_test.cpp 2006/03/06 21:48:04 1.1 +++ conga/ricci/common/executils_test.cpp 2006/08/10 22:53:07 1.2 @@ -16,7 +16,7 @@ #include #include -#include +#include "String.h" #include #include #include @@ -42,12 +42,12 @@ { // set_logger(counting_auto_ptr(new Logger(1, "executils_test", LogExecute))); - map > oracle; - oracle["/bin/cat"] = vector(1, "/etc/cluster/cluster.conf"); - oracle["/sbin/magma_tool"] = vector(1, "members"); - oracle["/usr/sbin/clustat"] = vector(1, "-x"); - oracle["/sbin/ifconfig"] = vector(); - // oracle["/bin/sleep"] = vector(1, "4"); + map > oracle; + oracle["/bin/cat"] = vector(1, "/etc/cluster/cluster.conf"); + oracle["/sbin/magma_tool"] = vector(1, "members"); + oracle["/usr/sbin/clustat"] = vector(1, "-x"); + oracle["/sbin/ifconfig"] = vector(); + // oracle["/bin/sleep"] = vector(1, "4"); setup_signal(SIGUSR1, nothing); setup_signal(SIGUSR2, nothing_2); @@ -58,10 +58,10 @@ killer.start(); while (true) { - for (map >::iterator iter = oracle.begin(); + for (map >::iterator iter = oracle.begin(); iter != oracle.end(); iter++) { - string out, err; + String out, err; int status; execute(iter->first, iter->second, out, err, status); --- conga/ricci/common/utils.cpp 2006/05/26 19:28:51 1.4 +++ conga/ricci/common/utils.cpp 2006/08/10 22:53:07 1.5 @@ -34,13 +34,13 @@ using namespace std; -string -utils::hash_str(const string& txt) +String +utils::hash_str(const String& txt) { unsigned char buff[16]; MD5((const unsigned char*) txt.c_str(), txt.size(), buff); - string hash; + String hash; for (unsigned int i=0; i>4)); hash += (char) ('a' + (int) ((buff[i] & 0x0f)>>4)); @@ -51,11 +51,11 @@ -string -utils::lstrip(string str, const string& del) +String +utils::lstrip(String str, const String& del) { if (del.empty()) - throw string("empty separator"); + throw String("empty separator"); while (str.find(del) == 0) { str = str.substr(del.size()); @@ -63,11 +63,11 @@ return str; } -string -utils::rstrip(string str, const string& del) +String +utils::rstrip(String str, const String& del) { if (del.empty()) - throw string("empty separator"); + throw String("empty separator"); if (str.size() < del.size()) return str; @@ -81,15 +81,15 @@ return str; } -string -utils::lstrip(string str) +String +utils::lstrip(String str) { while (str.find_first_of(" \n\t") == 0) str = str.substr(1); return str; } -string -utils::rstrip(string str) +String +utils::rstrip(String str) { unsigned int i; while ((i=str.size()) != 0) { @@ -102,56 +102,56 @@ return str; } -vector -utils::split(const string& t, const string& del) +vector +utils::split(const String& t, const String& del) { if (del.empty()) - throw string("empty separator"); + throw String("empty separator"); - string txt(t); + String txt(t); // merge separators if (del == " " || del == "\n") { - string::size_type i; + String::size_type i; while ((i = txt.find(del+del)) != txt.npos) txt.erase(i, del.size()); } // split - vector lines; - for (string::size_type from=0, to=txt.find(del); + vector lines; + for (String::size_type from=0, to=txt.find(del); from != txt.size(); ) { - string substr = txt.substr(from, to-from); + String substr = txt.substr(from, to-from); lines.push_back(substr); if (to == txt.npos) return lines; from = to + del.size(); to = txt.find(del, from); } - lines.push_back(string()); + lines.push_back(String()); return lines; } -vector -utils::split(const string& t) +vector +utils::split(const String& t) { - string del(" "); - string txt(t); + String del(" "); + String txt(t); // merge separators - string::size_type i; + String::size_type i; while ((i = txt.find('\t')) != txt.npos) txt[i] = ' '; while ((i = txt.find(del+del)) != txt.npos) txt.erase(i, del.size()); // split - vector lines; - for (string::size_type from=0, to=txt.find(del); + vector lines; + for (String::size_type from=0, to=txt.find(del); from != txt.size(); ) { - string substr = txt.substr(from, to-from); + String substr = txt.substr(from, to-from); lines.push_back(substr); if (to == txt.npos) return lines; @@ -162,20 +162,20 @@ return lines; } -string -utils::to_lower(const string& str) +String +utils::to_lower(const String& str) { - string s; - for (string::size_type i=0; i& args, - std::string& out, - std::string& err, +utils::execute(const String& path, + const std::vector& args, + String& out, + String& err, int& status, bool caching) { - string _command = path; - for (vector::const_iterator iter = args.begin(); + String _command = path; + for (vector::const_iterator iter = args.begin(); iter != args.end(); iter++) _command += " " + *iter; - map::iterator iter = cache.find(_command); + map::iterator iter = cache.find(_command); if (iter != cache.end() && caching) { exec_cache &c = iter->second; // cout << "exec: " << _command << " cached" << endl; @@ -264,7 +264,7 @@ // cout << "exec: " << _command << " executed" << endl; exec_cache c(_command, out, err, status, ret); if (caching) - cache.insert(pair(_command, c)); + cache.insert(pair(_command, c)); out = c.out; err = c.err; status = c.status; @@ -276,6 +276,6 @@ { cache.clear(); } -std::map +std::map utils::cache; - + /cvs/cluster/conga/ricci/include/shred_allocator.h,v --> standard output revision 1.1 --- conga/ricci/include/shred_allocator.h +++ - 2006-08-10 22:53:11.901119000 +0000 @@ -0,0 +1,129 @@ +// derived from malloc_allocator.h (GNU C++ library) + +// Allocator that wraps "C" malloc -*- C++ -*- +// and shreds memory before calling free + +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef shred_allocator_h +#define shred_allocator_h 1 + +#include + + +template +void +shred(_Tp* __p, size_t n) +{ + size_t size = sizeof(_Tp) / sizeof(char) * n; + if (size && __p) { + // shred memory + for (char *ptr = (char*) __p; + ptr < ((char*) __p) + size; + ptr++) + *ptr = 'o'; + } +} + + +template +class shred_allocator +{ +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + + template + struct rebind + { typedef shred_allocator<_Tp1> other; }; + + shred_allocator() throw() { } + + shred_allocator(const shred_allocator&) throw() { } + + template + shred_allocator(const shred_allocator<_Tp1>&) throw() { } + + ~shred_allocator() throw() { } + + pointer + address(reference __x) const { return &__x; } + + const_pointer + address(const_reference __x) const { return &__x; } + + // NB: __n is permitted to be 0. The C++ standard says nothing + // about what the return value is when __n == 0. + pointer + allocate(size_type __n, const void* = 0) + { + pointer __ret = static_cast<_Tp*>(malloc(__n * sizeof(_Tp))); + if (!__ret) + throw std::bad_alloc(); + return __ret; + } + + // __p is not permitted to be a null pointer. + void + deallocate(pointer __p, size_type n) + { + shred(__p, n); + free(static_cast(__p)); + } + + size_type + max_size() const throw() + { return size_t(-1) / sizeof(_Tp); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 402. wrong new expression in [some_] allocator::construct + void + construct(pointer __p, const _Tp& __val) + { ::new(__p) _Tp(__val); } + + void + destroy(pointer __p) { __p->~_Tp(); } +}; + +template +inline bool +operator==(const shred_allocator<_Tp>&, const shred_allocator<_Tp>&) +{ return true; } + +template +inline bool +operator!=(const shred_allocator<_Tp>&, const shred_allocator<_Tp>&) +{ return false; } + + +#endif // shred_allocator_h --- conga/ricci/include/APIerror.h 2006/04/07 16:49:00 1.1 +++ conga/ricci/include/APIerror.h 2006/08/10 22:53:07 1.2 @@ -29,10 +29,10 @@ { public: APIerror() : msg("") {} - APIerror(const std::string& msg) : msg(msg) {} + APIerror(const String& msg) : msg(msg) {} virtual ~APIerror() {} - const std::string msg; + const String msg; }; --- conga/ricci/include/Except.h 2006/04/07 16:42:39 1.2 +++ conga/ricci/include/Except.h 2006/08/10 22:53:07 1.3 @@ -24,7 +24,7 @@ #ifndef Except_h #define Except_h -#include +#include "String.h" class Except @@ -33,17 +33,17 @@ virtual ~Except(); long long code() const; - std::string description() const; + String description() const; static const long long generic_error = -1; protected: Except(long long error_code, - const std::string& msg); + const String& msg); private: long long _code; - std::string _msg; + String _msg; }; --- conga/ricci/include/Logger.h 2006/03/06 21:48:04 1.1 +++ conga/ricci/include/Logger.h 2006/08/10 22:53:07 1.2 @@ -25,7 +25,7 @@ #define Logger_h #include "counting_auto_ptr.h" -#include +#include "String.h" @@ -46,13 +46,13 @@ { public: Logger(); - Logger(const std::string& filepath, const std::string& domain, LogLevel level); - Logger(int fd, const std::string& domain, LogLevel level); + Logger(const String& filepath, const String& domain, LogLevel level); + Logger(int fd, const String& domain, LogLevel level); virtual ~Logger(); - void log(const std::string& msg, LogLevel level=LogBasic); + void log(const String& msg, LogLevel level=LogBasic); void log_sigsafe(const char* msg, LogLevel level=LogBasic); - void operator<< (const std::string& msg) { log(msg); } + void operator<< (const String& msg) { log(msg); } private: int _fd; @@ -67,9 +67,9 @@ // helper functions -std::string operator+ (const std::string&, int); -std::string operator+ (int, const std::string&); -void log(const std::string& msg, LogLevel level=LogBasic); +String operator+ (const String&, int); +String operator+ (int, const String&); +void log(const String& msg, LogLevel level=LogBasic); void log_sigsafe(const char* msg, LogLevel level=LogBasic); void set_logger(counting_auto_ptr); --- conga/ricci/include/Module.h 2006/04/07 16:42:39 1.1 +++ conga/ricci/include/Module.h 2006/08/10 22:53:07 1.2 @@ -28,20 +28,20 @@ #include "Variable.h" #include "APIerror.h" -#include +#include "String.h" #include #include // name->variable map -typedef std::map VarMap; +typedef std::map VarMap; // name->function map -typedef std::map FcnMap; // api->name->function map -typedef std::map ApiFcnMap; +typedef std::map ApiFcnMap; class Module --- conga/ricci/include/Socket.h 2006/04/03 14:50:57 1.2 +++ conga/ricci/include/Socket.h 2006/08/10 22:53:07 1.3 @@ -26,7 +26,7 @@ #include "counting_auto_ptr.h" -#include +#include "String.h" #include @@ -34,7 +34,7 @@ // provide external locking -std::vector name2IP(const std::string& hostname); +std::vector name2IP(const String& hostname); class Socket @@ -72,20 +72,20 @@ { public: ClientSocket(); - ClientSocket(const std::string& sock_path); // UNIX socket - ClientSocket(const std::string& hostname, unsigned short port); // TCP socket + ClientSocket(const String& sock_path); // UNIX socket + ClientSocket(const String& hostname, unsigned short port); // TCP socket ClientSocket(const ClientSocket&); ClientSocket& operator= (const ClientSocket&); virtual ~ClientSocket(); - std::string recv(); - std::string send(const std::string& msg); // return what is left to send + String recv(); + String send(const String& msg); // return what is left to send void ready(bool& recv, bool& send, int timeout); virtual bool server() { return false; } - virtual bool connected_to(const std::string& hostname); + virtual bool connected_to(const String& hostname); protected: unsigned int _addr; @@ -98,7 +98,7 @@ class ServerSocket : public Socket { public: - ServerSocket(const std::string& sock_path); // UNIX socket + ServerSocket(const String& sock_path); // UNIX socket ServerSocket(unsigned short port); // TCP socket ServerSocket(const ServerSocket&); ServerSocket& operator= (const ServerSocket&); @@ -112,7 +112,7 @@ private: bool _unix_sock; - std::string _sock_path; + String _sock_path; }; // ServerSocket --- conga/ricci/include/Time.h 2006/06/20 19:37:23 1.3 +++ conga/ricci/include/Time.h 2006/08/10 22:53:07 1.4 @@ -24,7 +24,7 @@ #ifndef Time_h #define Time_h -#include +#include "String.h" // number of seconds since Epoch @@ -38,7 +38,7 @@ // sleep num seconds void sleep_sec(unsigned char num); -std::string time_formated(); +String time_formated(); #endif // Time_h --- conga/ricci/include/Variable.h 2006/04/07 16:42:39 1.2 +++ conga/ricci/include/Variable.h 2006/08/10 22:53:07 1.3 @@ -24,7 +24,7 @@ #ifndef Variable_h #define Variable_h -#include +#include "String.h" #include #include "XML.h" @@ -33,7 +33,7 @@ enum VarType {Integer = 1, IntSel = 2, // integer selector Boolean = 3, - String = 4, + StringVar = 4, StrSel = 5, // string selector XMLVar = 6, ListInt = 7, @@ -60,21 +60,21 @@ // string Validator(long long min_length, long long max_length, - const std::string& illegal_chars, - const std::list& reserved_words); + const String& illegal_chars, + const std::list& reserved_words); // string selector - Validator(const std::list& valid_words); + Validator(const std::list& valid_words); virtual ~Validator(); bool validate(long long value) const; - bool validate(const std::string& value) const; + bool validate(const String& value) const; bool validate(bool value) const; bool validate(const XMLObject& value) const; bool validate(const std::list& value) const; - bool validate(const std::list& value) const; + bool validate(const std::list& value) const; bool validate(const std::list& value) const; @@ -95,11 +95,11 @@ bool _string; long long _min_length; long long _max_length; - std::string _illegal_chars; - std::list _reserved_words; + String _illegal_chars; + std::list _reserved_words; bool _string_sel; - std::list _valid_words; + std::list _valid_words; }; // class Validator @@ -113,56 +113,56 @@ { public: // integer - Variable(const std::string& name, + Variable(const String& name, long long value); - Variable(const std::string& name, + Variable(const String& name, long long value, long long min, long long max, long long step); // integer selector - Variable(const std::string& name, + Variable(const String& name, long long value, const std::list& valid_values); // integer list - Variable(const std::string& name, + Variable(const String& name, const std::list& value, bool mutabl=false); // boolean - Variable(const std::string& name, + Variable(const String& name, bool value, bool mutabl=false); // string - Variable(const std::string& name, - const std::string& value); - Variable(const std::string& name, - const std::string& value, + Variable(const String& name, + const String& value); + Variable(const String& name, + const String& value, long long min_length, long long max_length, - const std::string& illegal_chars, - const std::list& reserved_words); + const String& illegal_chars, + const std::list& reserved_words); // string selector - Variable(const std::string& name, - const std::string& value, - const std::list& valid_words); + Variable(const String& name, + const String& value, + const std::list& valid_words); // string list - Variable(const std::string& name, - const std::list& value, + Variable(const String& name, + const std::list& value, bool mutabl=false); // xml - Variable(const std::string& name, + Variable(const String& name, const XMLObject& value); // xml list - Variable(const std::string& name, + Variable(const String& name, const std::list& value); @@ -171,7 +171,7 @@ virtual ~Variable(); - std::string name() const { return _name; } + String name() const { return _name; } VarType type() const { return _type; } bool mutabl() const { return _mutable; } void mutabl(bool mutabl) { _mutable = mutabl; } @@ -187,32 +187,32 @@ void set_value(long long value); void set_value(bool value); - void set_value(const std::string& value); + void set_value(const String& value); void set_value(const XMLObject& value); void set_value(const std::list& value); - void set_value(const std::list& value); + void set_value(const std::list& value); void set_value(const std::list& value); long long get_int() const; bool get_bool() const; - std::string get_string() const; + String get_string() const; XMLObject get_XML() const; std::list get_list_int() const; - std::list get_list_str() const; + std::list get_list_str() const; std::list get_list_XML() const; private: - std::string _name; + String _name; VarType _type; long long _val_int; bool _val_bool; - std::string _val_str; + String _val_str; XMLObject _val_xml; std::list _val_list_int; - std::list _val_list_str; + std::list _val_list_str; std::list _val_list_XML; bool _mutable; --- conga/ricci/include/XML.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/include/XML.h 2006/08/10 22:53:07 1.3 @@ -24,7 +24,7 @@ #ifndef XML_h #define XML_h -#include +#include "String.h" #include #include @@ -33,18 +33,18 @@ class XMLObject { public: - XMLObject(const std::string& elem_name = "TagName"); + XMLObject(const String& elem_name = "TagName"); virtual ~XMLObject(); - std::string tag() const + String tag() const { return _tag; }; // attributes - bool has_attr(const std::string& attr_name) const; - std::string set_attr(const std::string& attr_name, - const std::string& value); // return old value - std::string get_attr(const std::string& attr_name) const; - const std::map& attrs() const + bool has_attr(const String& attr_name) const; + String set_attr(const String& attr_name, + const String& value); // return old value + String get_attr(const String& attr_name) const; + const std::map& attrs() const { return _attrs; } // kids @@ -56,16 +56,16 @@ bool operator== (const XMLObject&) const; private: - std::string _tag; + String _tag; std::list _kids; - std::map _attrs; - void generate_xml(std::string& xml, const std::string& indent) const; - friend std::string generateXML(const XMLObject& obj); + std::map _attrs; + void generate_xml(String& xml, const String& indent) const; + friend String generateXML(const XMLObject& obj); }; -XMLObject parseXML(const std::string& xml); -std::string generateXML(const XMLObject& obj); +XMLObject parseXML(const String& xml); +String generateXML(const XMLObject& obj); #endif // XML_h --- conga/ricci/include/XML_tags.h 2006/04/07 16:42:39 1.3 +++ conga/ricci/include/XML_tags.h 2006/08/10 22:53:07 1.4 @@ -24,7 +24,7 @@ #ifndef XML_tags_h #define XML_tags_h -#include +#include "String.h" @@ -33,29 +33,29 @@ // ### Variable ### -#define VARIABLE_TAG std::string("var") +#define VARIABLE_TAG String("var") -#define VARIABLE_INT std::string("int") -#define VARIABLE_INT_SEL std::string("int_select") -#define VARIABLE_BOOL std::string("boolean") -#define VARIABLE_STR std::string("string") -#define VARIABLE_STR_SEL std::string("string_select") -#define VARIABLE_XML std::string("xml") -#define VARIABLE_LIST_STR std::string("list_str") -#define VARIABLE_LIST_INT std::string("list_int") -#define VARIABLE_LIST_XML std::string("list_xml") -#define VARIABLE_LISTENTRY std::string("listentry") +#define VARIABLE_INT String("int") +#define VARIABLE_INT_SEL String("int_select") +#define VARIABLE_BOOL String("boolean") +#define VARIABLE_STR String("string") +#define VARIABLE_STR_SEL String("string_select") +#define VARIABLE_XML String("xml") +#define VARIABLE_LIST_STR String("list_str") +#define VARIABLE_LIST_INT String("list_int") +#define VARIABLE_LIST_XML String("list_xml") +#define VARIABLE_LISTENTRY String("listentry") -#define REQUEST_TAG std::string("request") -#define RESPONSE_TAG std::string("response") -#define SEQUENCE_TAG std::string("sequence") +#define REQUEST_TAG String("request") +#define RESPONSE_TAG String("response") +#define SEQUENCE_TAG String("sequence") -#define FUNC_CALL_TAG std::string("function_call") -#define FUNC_RESPONSE_TAG std::string("function_response") +#define FUNC_CALL_TAG String("function_call") +#define FUNC_RESPONSE_TAG String("function_response") -#define MOD_VERSION_TAG std::string("API_version") +#define MOD_VERSION_TAG String("API_version") --- conga/ricci/include/executils.h 2006/03/27 21:30:36 1.2 +++ conga/ricci/include/executils.h 2006/08/10 22:53:07 1.3 @@ -24,15 +24,15 @@ #ifndef executils_h #define executils_h -#include +#include "String.h" #include // return 0 on success, non-zero on failure -int execute(const std::string& path, - const std::vector& args, - std::string& out, - std::string& err, +int execute(const String& path, + const std::vector& args, + String& out, + String& err, int& status, int timeout=-1 /* milliseconds, kill child after timeout has elapsed, --- conga/ricci/include/utils.h 2006/05/26 19:28:51 1.3 +++ conga/ricci/include/utils.h 2006/08/10 22:53:07 1.4 @@ -25,16 +25,16 @@ #define utils_h #include -#include +#include "String.h" #include class exec_cache { public: - exec_cache(const std::string& command, - const std::string& out, - const std::string& err, + exec_cache(const String& command, + const String& out, + const String& err, int status, int exec_ret) : command(command), @@ -43,9 +43,9 @@ status(status), exec_ret(exec_ret) {} - const std::string command; - const std::string out; - const std::string err; + const String command; + const String out; + const String err; const int status; const int exec_ret; @@ -55,48 +55,48 @@ class utils { public: - static std::string hash_str(const std::string& txt); + static String hash_str(const String& txt); - static std::string strip(std::string str) + static String strip(String str) { return rstrip(lstrip(str)); } - static std::string lstrip(std::string str); - static std::string rstrip(std::string str); + static String lstrip(String str); + static String rstrip(String str); - static std::string strip(std::string str, - const std::string& del) + static String strip(String str, + const String& del) { return rstrip(lstrip(str, del), del); } - static std::string lstrip(std::string str, - const std::string& del); - static std::string rstrip(std::string str, - const std::string& del); + static String lstrip(String str, + const String& del); + static String rstrip(String str, + const String& del); - static std::vector split(const std::string& str, - const std::string& del); - static std::vector split(const std::string& str); + static std::vector split(const String& str, + const String& del); + static std::vector split(const String& str); - static std::string to_lower(const std::string& str); - static std::string to_upper(const std::string& str); + static String to_lower(const String& str); + static String to_upper(const String& str); - // static int to_int(const std::string& str); - static long long to_long(const std::string& str); - static float to_float(const std::string& str); + // static int to_int(const String& str); + static long long to_long(const String& str); + static float to_float(const String& str); - static std::string to_string(int value); - static std::string to_string(long value); - static std::string to_string(long long value); - static std::string to_string(bool value); + static String to_string(int value); + static String to_string(long value); + static String to_string(long long value); + static String to_string(bool value); - static int execute(const std::string& path, - const std::vector& args, - std::string& out, - std::string& err, + static int execute(const String& path, + const std::vector& args, + String& out, + String& err, int& status, bool caching=true); static void clear_cache(); - static std::map cache; + static std::map cache; }; --- conga/ricci/modules/cluster/ClusterConf.cpp 2006/04/07 16:42:39 1.3 +++ conga/ricci/modules/cluster/ClusterConf.cpp 2006/08/10 22:53:08 1.4 @@ -33,8 +33,8 @@ using namespace std; -#define CLUSTER_CONF_DIR string("/etc/cluster/") -#define CLUSTER_CONF_NAME string("cluster.conf") +#define CLUSTER_CONF_DIR String("/etc/cluster/") +#define CLUSTER_CONF_NAME String("cluster.conf") #define CLUSTER_CONF_PATH (CLUSTER_CONF_DIR + CLUSTER_CONF_NAME) #define CCS_TOOL_PATH "/sbin/ccs_tool" @@ -53,7 +53,7 @@ is.seekg(0, ios::beg); buff = new char[length]; is.read(buff, length); - string cluster_conf(buff, length); + String cluster_conf(buff, length); XMLObject xml(parseXML(cluster_conf)); delete [] buff; @@ -71,12 +71,12 @@ { // sanity check if (xml.tag() != "cluster") - throw string("invalid cluster.conf"); + throw String("invalid cluster.conf"); if (xml.get_attr("name").empty()) - throw string("invalid cluster.conf"); + throw String("invalid cluster.conf"); long long conf_version = utils::to_long(xml.get_attr("config_version")); if (conf_version == 0) - throw string("invalid cluster.conf"); + throw String("invalid cluster.conf"); // create dir, if not existing DIR* dir = opendir(CLUSTER_CONF_DIR.c_str()); @@ -86,13 +86,13 @@ if (errno == ENOENT) { if (mkdir(CLUSTER_CONF_DIR.c_str(), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)) - throw string("failed to create ") + CLUSTER_CONF_DIR; + throw String("failed to create ") + CLUSTER_CONF_DIR; } else - throw string("opendir() error"); + throw String("opendir() error"); } // save tmp cluster.conf - string tmp_path(CLUSTER_CONF_PATH + ".tmp_ricci"); + String tmp_path(CLUSTER_CONF_PATH + ".tmp_ricci"); fstream fs(tmp_path.c_str(), ios_base::out | ios_base::trunc); fs << generateXML(xml); @@ -100,15 +100,15 @@ // propagate/move to proper place if (propagate) { try { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("update"); args.push_back(tmp_path); if (utils::execute(CCS_TOOL_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("ccs_tool failed"); + throw String("ccs_tool failed"); bool cman = false; for (list::const_iterator iter = xml.children().begin(); @@ -122,9 +122,9 @@ args.push_back("-r"); args.push_back(utils::to_string(conf_version)); if (utils::execute(CMAN_TOOL_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("cman_tool failed"); + throw String("cman_tool failed"); } unlink(tmp_path.c_str()); @@ -135,7 +135,7 @@ } else { if (rename(tmp_path.c_str(), CLUSTER_CONF_PATH.c_str())) { unlink(tmp_path.c_str()); - throw string("failed to rename cluster.conf"); + throw String("failed to rename cluster.conf"); } } } --- conga/ricci/modules/cluster/ClusterModule.cpp 2006/06/20 19:37:23 1.3 +++ conga/ricci/modules/cluster/ClusterModule.cpp 2006/08/10 22:53:08 1.4 @@ -83,7 +83,7 @@ Variable var("status", Cluster::status()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -93,7 +93,7 @@ Variable var("cluster.conf", ClusterConf::get()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -112,7 +112,7 @@ iter = args.find("propagate"); if (iter != args.end()) propagate = iter->second.get_bool(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -125,13 +125,13 @@ VarMap service_stop(const VarMap& args) { - string name; + String name; try { VarMap::const_iterator iter = args.find("servicename"); if (iter == args.end()) throw APIerror("missing servicename variable"); name = iter->second.get_string(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -144,7 +144,7 @@ VarMap service_start(const VarMap& args) { - string service_name, node_name; + String service_name, node_name; try { VarMap::const_iterator iter = args.find("servicename"); if (iter == args.end()) @@ -154,7 +154,7 @@ iter = args.find("nodename"); if (iter != args.end()) node_name = iter->second.get_string(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -167,13 +167,13 @@ VarMap service_restart(const VarMap& args) { - string name; + String name; try { VarMap::const_iterator iter = args.find("servicename"); if (iter == args.end()) throw APIerror("missing servicename variable"); name = iter->second.get_string(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -186,13 +186,13 @@ VarMap fence_node(const VarMap& args) { - string name; + String name; try { VarMap::const_iterator iter = args.find("nodename"); if (iter == args.end()) throw APIerror("missing nodename variable"); name = iter->second.get_string(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -210,7 +210,7 @@ VarMap::const_iterator iter = args.find("cluster_startup"); if (iter != args.end()) cluster_startup = iter->second.get_bool(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -228,7 +228,7 @@ VarMap::const_iterator iter = args.find("cluster_shutdown"); if (iter != args.end()) cluster_shutdown = iter->second.get_bool(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } --- conga/ricci/modules/cluster/ClusterStatus.cpp 2006/08/09 20:53:22 1.9 +++ conga/ricci/modules/cluster/ClusterStatus.cpp 2006/08/10 22:53:08 1.10 @@ -28,7 +28,7 @@ #include "Clusvcadm.h" #include "utils.h" -#include +#include "String.h" using namespace std; @@ -47,10 +47,10 @@ -static void run_initd(const string& servname, +static void run_initd(const String& servname, bool start, bool fail); -static void run_chkconfig(const string& servname, +static void run_chkconfig(const String& servname, bool on); static void cman_leave(); static void gulm_leave(); @@ -80,7 +80,7 @@ // send status request int beg = int(time_sec()); - string request("GET"); + String request("GET"); while ((int(time_sec()) < beg + 5)) { bool read = false, write = true; sock.ready(read, write, 500); @@ -91,7 +91,7 @@ // receive status report beg = int(time_sec()); - string xml_in; + String xml_in; while ((int(time_sec()) < beg + 5)) { bool read = true, write = false; sock.ready(read, write, 500); @@ -195,12 +195,12 @@ void -run_chkconfig(const string& servname, +run_chkconfig(const String& servname, bool on) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back(servname); if (on) args.push_back("on"); @@ -210,16 +210,16 @@ } void -run_initd(const string& servname, +run_initd(const String& servname, bool start, bool fail) { - string path(INITD_DIR_PATH); + String path(INITD_DIR_PATH); path += servname; - string out, err; + String out, err; int status; - vector args; + vector args; if (start) args.push_back("start"); else @@ -229,18 +229,18 @@ if (status == 0) failed = false; if (fail && failed) - throw string("service ") + servname + " " + string(start?"start":"stop") + " failed"; + throw String("service ") + servname + " " + String(start?"start":"stop") + " failed"; } void cman_leave() { // when bz179627 gets fixed, just call service cman stop, but for now ... - string out, err; + String out, err; int status; - vector args; + vector args; if (utils::execute(LSMOD_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); bool cman_loaded = (out.find("cman") != out.npos); if (cman_loaded) { @@ -263,9 +263,9 @@ args.push_back("dlm"); args.push_back("cman"); if (utils::execute(MODPROBE_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("modprobe -r failed"); + throw String("modprobe -r failed"); } } --- conga/ricci/modules/cluster/Clusvcadm.cpp 2006/04/07 16:42:39 1.2 +++ conga/ricci/modules/cluster/Clusvcadm.cpp 2006/08/10 22:53:08 1.3 @@ -49,21 +49,21 @@ RG_STATE_RECOVER = 118, // Pending recovery RG_STATE_DISABLED = 119}; // Resource not allowd to run - ServiceStatus(const string& name, - const string& node, + ServiceStatus(const String& name, + const String& node, state status) : name(name), node(node), status(status) {} virtual ~ServiceStatus() {} - string name; - string node; + String name; + String node; state status; }; -static pair, list > +static pair, list > service_states(); @@ -71,29 +71,29 @@ void -Clusvcadm::start(const std::string& servicename, - const std::string& nodename) +Clusvcadm::start(const String& servicename, + const String& nodename) { - pair, list > info = service_states(); - list nodes = info.first; + pair, list > info = service_states(); + list nodes = info.first; list services = info.second; // check if node can run services bool node_found = false; - for (list::const_iterator iter = nodes.begin(); + for (list::const_iterator iter = nodes.begin(); iter != nodes.end(); iter++) if (*iter == nodename) node_found = true; if (!node_found && nodename.size()) - throw string("node unable to run services"); + throw String("node unable to run services"); // start for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) if (iter->name == servicename) { - string flag; + String flag; if (iter->status == ServiceStatus::RG_STATE_STOPPED || iter->status == ServiceStatus::RG_STATE_STOPPING || iter->status == ServiceStatus::RG_STATE_FAILED || @@ -105,9 +105,9 @@ flag = "-r"; if (flag.size()) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back(flag); args.push_back(servicename); if (nodename.size()) { @@ -115,21 +115,21 @@ args.push_back(nodename); } if (utils::execute(CLUSVCADM_TOOL_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("clusvcadm failed"); + throw String("clusvcadm failed"); } return; } - throw string("no such service"); + throw String("no such service"); } void -Clusvcadm::stop(const std::string& servicename) +Clusvcadm::stop(const String& servicename) { - pair, list > info = service_states(); - list nodes = info.first; + pair, list > info = service_states(); + list nodes = info.first; list services = info.second; for (list::const_iterator iter = services.begin(); @@ -138,34 +138,34 @@ if (iter->name == servicename) { if (iter->status == ServiceStatus::RG_STATE_STARTING || iter->status == ServiceStatus::RG_STATE_STARTED) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("-d"); args.push_back(servicename); if (utils::execute(CLUSVCADM_TOOL_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("clusvcadm failed"); + throw String("clusvcadm failed"); } return; } - throw string("no such service"); + throw String("no such service"); } void -Clusvcadm::restart(const std::string& servicename) +Clusvcadm::restart(const String& servicename) { - pair, list > info = service_states(); - list nodes = info.first; + pair, list > info = service_states(); + list nodes = info.first; list services = info.second; for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) if (iter->name == servicename) { - string flag; + String flag; if (iter->status == ServiceStatus::RG_STATE_STOPPED || iter->status == ServiceStatus::RG_STATE_STOPPING || iter->status == ServiceStatus::RG_STATE_FAILED || @@ -176,40 +176,40 @@ flag = "-R"; if (flag.size()) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back(flag); args.push_back(servicename); if (utils::execute(CLUSVCADM_TOOL_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("clusvcadm failed"); + throw String("clusvcadm failed"); } return; } - throw string("no such service"); + throw String("no such service"); } -pair, list > +pair, list > service_states() { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("-x"); if (utils::execute(CLUSTAT_TOOL_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("clustat failed"); + throw String("clustat failed"); XMLObject xml = parseXML(out); if (xml.tag() != "clustat") - throw string("invalid clustat output"); + throw String("invalid clustat output"); XMLObject nodes_xml("noname"), groups_xml("noname"), quorum_xml("noname"); for (list::const_iterator iter = xml.children().begin(); @@ -225,7 +225,7 @@ if (quorum_xml.get_attr("groupmember") != "1") throw NoServiceManager(); - list nodes; + list nodes; for (list::const_iterator iter = nodes_xml.children().begin(); iter != nodes_xml.children().end(); iter++) @@ -237,12 +237,12 @@ iter != groups_xml.children().end(); iter++) if (iter->tag() == "group") { - string name(iter->get_attr("name")); - string node(iter->get_attr("owner")); + String name(iter->get_attr("name")); + String node(iter->get_attr("owner")); ServiceStatus::state state = (ServiceStatus::state) utils::to_long(iter->get_attr("state")); services.push_back(ServiceStatus(name, node, state)); } - return pair, list >(nodes, services); + return pair, list >(nodes, services); } --- conga/ricci/modules/cluster/Clusvcadm.h 2006/03/28 19:52:52 1.1 +++ conga/ricci/modules/cluster/Clusvcadm.h 2006/08/10 22:53:08 1.2 @@ -24,16 +24,16 @@ #ifndef Clusvcadm_h #define Clusvcadm_h -#include +#include "String.h" class Clusvcadm { public: - static void start(const std::string& servicename, - const std::string& nodename); - static void stop(const std::string& servicename); - static void restart(const std::string& servicename); + static void start(const String& servicename, + const String& nodename); + static void stop(const String& servicename); + static void restart(const String& servicename); }; --- conga/ricci/modules/cluster/Fence.cpp 2006/03/28 20:41:13 1.1 +++ conga/ricci/modules/cluster/Fence.cpp 2006/08/10 22:53:08 1.2 @@ -35,14 +35,14 @@ void -Fence::fence_node(const std::string& nodename) +Fence::fence_node(const String& nodename) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back(nodename); if (utils::execute(FENCE_NODE_TOOL_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("fence_node failed"); + throw String("fence_node failed"); } --- conga/ricci/modules/cluster/Fence.h 2006/03/28 20:41:13 1.1 +++ conga/ricci/modules/cluster/Fence.h 2006/08/10 22:53:08 1.2 @@ -24,13 +24,13 @@ #ifndef Fence_h #define Fence_h -#include +#include "String.h" class Fence { public: - static void fence_node(const std::string& nodename); + static void fence_node(const String& nodename); }; --- conga/ricci/modules/cluster/main.cpp 2006/04/07 16:42:40 1.2 +++ conga/ricci/modules/cluster/main.cpp 2006/08/10 22:53:08 1.3 @@ -32,7 +32,7 @@ try { ClusterModule m; return stdin_out_module_driver(m); - } catch (string e) { + } catch (String e) { cerr << e << endl; return 1; } --- conga/ricci/modules/cluster/clumon/src/cim-provider/ClusterProvider.cpp 2006/08/09 16:50:42 1.2 +++ conga/ricci/modules/cluster/clumon/src/cim-provider/ClusterProvider.cpp 2006/08/10 22:53:08 1.3 @@ -44,7 +44,7 @@ using namespace Pegasus; using namespace ClusterMonitoring; -using Pegasus::String; + static CIMInstance buildClusterInstance(counting_auto_ptr& cluster, Boolean qual, Boolean orig); --- conga/ricci/modules/cluster/clumon/src/common/Cluster.cpp 2006/05/25 15:54:56 1.4 +++ conga/ricci/modules/cluster/clumon/src/common/Cluster.cpp 2006/08/10 22:53:08 1.5 @@ -29,7 +29,7 @@ using namespace ClusterMonitoring; -Cluster::Cluster(const string &name, const string &alias, unsigned int minQuorum) : +Cluster::Cluster(const String &name, const String &alias, unsigned int minQuorum) : _name(name), _alias(alias), _minQuorum(minQuorum) @@ -43,13 +43,13 @@ -std::string +String Cluster::name() { return _name; } -std::string +String Cluster::alias() { return _alias; @@ -59,7 +59,7 @@ Cluster::votes() { unsigned int votes = 0; - for (map >::iterator iter = _nodes.begin(); + for (map >::iterator iter = _nodes.begin(); iter != _nodes.end(); iter++) { Node& node = *(iter->second); @@ -93,14 +93,14 @@ counting_auto_ptr -Cluster::addNode(const std::string& name, +Cluster::addNode(const String& name, unsigned int votes, bool online, bool clustered, - const string& uptime) + const String& uptime) { counting_auto_ptr node(new Node(name, _name, votes, online, clustered, uptime)); - if (_nodes.insert(pair >(name, node)).second) + if (_nodes.insert(pair >(name, node)).second) return node; else // already present @@ -108,15 +108,15 @@ } counting_auto_ptr -Cluster::addService(const std::string& name, - const std::string& nodeName, +Cluster::addService(const String& name, + const String& nodeName, bool failed, bool autostart, - const string& time_since_transition) + const String& time_since_transition) { - map >::iterator iter = _nodes.find(nodeName); + map >::iterator iter = _nodes.find(nodeName); if (iter == _nodes.end()) - throw string("Cluster::addService(): add node first"); + throw String("Cluster::addService(): add node first"); return iter->second->addService(name, failed, autostart, time_since_transition); } @@ -126,7 +126,7 @@ { list > ret; - for (map >::iterator iter = _nodes.begin(); + for (map >::iterator iter = _nodes.begin(); iter != _nodes.end(); iter++) { counting_auto_ptr& node = iter->second; @@ -141,7 +141,7 @@ { list > ret; - for (map >::iterator iter = _nodes.begin(); + for (map >::iterator iter = _nodes.begin(); iter != _nodes.end(); iter++) { counting_auto_ptr& node = iter->second; @@ -156,7 +156,7 @@ { list > ret; - for (map >::iterator iter = _nodes.begin(); + for (map >::iterator iter = _nodes.begin(); iter != _nodes.end(); iter++) { counting_auto_ptr& node = iter->second; @@ -172,7 +172,7 @@ { list > ret; - for (map >::iterator iter = _nodes.begin(); + for (map >::iterator iter = _nodes.begin(); iter != _nodes.end(); iter++) { list > services = iter->second->services(); @@ -231,7 +231,7 @@ -string +String ClusterMonitoring::cluster2xml(Cluster& cluster) { char buff[1024]; @@ -285,20 +285,20 @@ } counting_auto_ptr -ClusterMonitoring::xml2cluster(const std::string& xml) +ClusterMonitoring::xml2cluster(const String& xml) { XMLObject clu = parseXML(xml); if (clu.tag() != "cluster") - throw string("xml2cluster(): invalid xml"); + throw String("xml2cluster(): invalid xml"); // cluster - string name = clu.get_attr("name"); + String name = clu.get_attr("name"); if (name.empty()) - throw string("xml2cluster(): missing cluster name"); + throw String("xml2cluster(): missing cluster name"); unsigned int minQuorum = 0; if (sscanf(clu.get_attr("minQuorum").c_str(), "%u", &minQuorum) != 1) - throw string("xml2cluster(): invalid value for cluster's minQuorum"); - string alias = clu.get_attr("alias"); + throw String("xml2cluster(): invalid value for cluster's minQuorum"); + String alias = clu.get_attr("alias"); counting_auto_ptr cluster(new Cluster(name, alias, minQuorum)); // nodes @@ -308,25 +308,25 @@ const XMLObject& obj = *iter; if (obj.tag() == "node") { // name - string node_name = obj.get_attr("name"); + String node_name = obj.get_attr("name"); if (node_name.empty()) - throw string("xml2cluster(): node missing 'name' attr"); + throw String("xml2cluster(): node missing 'name' attr"); // votes unsigned int votes; if (sscanf(obj.get_attr("votes").c_str(), "%u", &votes) != 1) - throw string("xml2cluster(): invalid value for node's votes"); + throw String("xml2cluster(): invalid value for node's votes"); // online - string online_str = obj.get_attr("online"); + String online_str = obj.get_attr("online"); bool online = online_str == "true"; if (online_str.empty()) - throw string("xml2cluster(): node missing 'online' attr"); + throw String("xml2cluster(): node missing 'online' attr"); // clustered - string clustered_str = obj.get_attr("clustered"); + String clustered_str = obj.get_attr("clustered"); bool clustered = clustered_str == "true"; if (clustered_str.empty()) - throw string("xml2cluster(): node missing 'clustered' attr"); + throw String("xml2cluster(): node missing 'clustered' attr"); // uptime - string uptime = obj.get_attr("uptime"); + String uptime = obj.get_attr("uptime"); // add node to cluster cluster->addNode(node_name, votes, online, clustered, uptime); } @@ -339,31 +339,31 @@ const XMLObject& obj = *iter; if (obj.tag() == "service") { // name - string service_name = obj.get_attr("name"); + String service_name = obj.get_attr("name"); if (service_name.empty()) - throw string("xml2cluster(): service missing 'name' attr"); + throw String("xml2cluster(): service missing 'name' attr"); // running - string running_str = obj.get_attr("running"); + String running_str = obj.get_attr("running"); bool running = running_str == "true"; if (running_str.empty()) - throw string("xml2cluster(): service missing 'running' attr"); + throw String("xml2cluster(): service missing 'running' attr"); // nodename - string nodename = obj.get_attr("nodename"); + String nodename = obj.get_attr("nodename"); if (running) if (nodename.empty()) - throw string("xml2cluster(): running service missing 'nodename' attr"); + throw String("xml2cluster(): running service missing 'nodename' attr"); // failed - string failed_str = obj.get_attr("failed"); + String failed_str = obj.get_attr("failed"); bool failed = failed_str == "true"; if (failed_str.empty()) - throw string("xml2cluster(): service missing 'failed' attr"); + throw String("xml2cluster(): service missing 'failed' attr"); // autostart - string autostart_str = obj.get_attr("autostart"); + String autostart_str = obj.get_attr("autostart"); bool autostart = autostart_str == "true"; if (autostart_str.empty()) - throw string("xml2cluster(): service missing 'autostart' attr"); + throw String("xml2cluster(): service missing 'autostart' attr"); // time since last transition - string time_since_transition = obj.get_attr("time_since_transition"); + String time_since_transition = obj.get_attr("time_since_transition"); // add service to cluster cluster->addService(service_name, nodename, failed, autostart, time_since_transition); } --- conga/ricci/modules/cluster/clumon/src/common/ClusterMonitor.cpp 2006/06/14 21:44:37 1.1 +++ conga/ricci/modules/cluster/clumon/src/common/ClusterMonitor.cpp 2006/08/10 22:53:08 1.2 @@ -32,7 +32,7 @@ using namespace ClusterMonitoring; -ClusterMonitor::ClusterMonitor(const std::string& socket_path) : +ClusterMonitor::ClusterMonitor(const String& socket_path) : _sock_path(socket_path) {} @@ -49,7 +49,7 @@ if(sock.send("GET").size()) throw int(); - std::string xml; + String xml; unsigned int timeout = 1000; while (timeout > 0) { struct pollfd poll_data; @@ -66,7 +66,7 @@ if (errno == EINTR) continue; else - throw std::string("get_cluster(): poll() error"); + throw String("get_cluster(): poll() error"); } if (poll_data.revents & POLLIN) { xml += sock.recv(); @@ -75,7 +75,7 @@ continue; } if (poll_data.revents & (POLLERR | POLLHUP | POLLNVAL)) - throw std::string("get_cluster(): socket error"); + throw String("get_cluster(): socket error"); } return xml2cluster(xml); } catch ( ... ) { --- conga/ricci/modules/cluster/clumon/src/common/Node.cpp 2006/05/25 15:54:56 1.3 +++ conga/ricci/modules/cluster/clumon/src/common/Node.cpp 2006/08/10 22:53:08 1.4 @@ -27,12 +27,12 @@ using namespace ClusterMonitoring; -Node::Node(const string& name, - const string& clustername, +Node::Node(const String& name, + const String& clustername, unsigned int votes, bool online, bool clustered, - const string& uptime) : + const String& uptime) : _name(name), _clustername(clustername), _votes(votes), @@ -45,13 +45,13 @@ {} -string +String Node::name() const { return _name; } -string +String Node::clustername() const { return _clustername; @@ -75,7 +75,7 @@ return _clustered; } -string +String Node::uptime() const { return _uptime; @@ -83,13 +83,13 @@ counting_auto_ptr -Node::addService(const string& name, +Node::addService(const String& name, bool failed, bool autostart, - const string& time_since_transition) + const String& time_since_transition) { counting_auto_ptr service(new Service(name, _clustername, *this, failed, autostart, time_since_transition)); - _services.insert(pair >(name, service)); + _services.insert(pair >(name, service)); return service; } @@ -98,7 +98,7 @@ { list > ret; - for (map >::iterator iter = _services.begin(); + for (map >::iterator iter = _services.begin(); iter != _services.end(); iter++) ret.push_back(iter->second); --- conga/ricci/modules/cluster/clumon/src/common/Service.cpp 2006/05/25 15:54:56 1.2 +++ conga/ricci/modules/cluster/clumon/src/common/Service.cpp 2006/08/10 22:53:08 1.3 @@ -28,12 +28,12 @@ using namespace std; -Service::Service(const string& name, - const string& clustername, +Service::Service(const String& name, + const String& clustername, const Node& node, bool failed, bool autostart, - const string& time_since_transition) : + const String& time_since_transition) : _name(name), _clustername(clustername), _nodename(node.name()), @@ -46,13 +46,13 @@ {} -string +String Service::name() const { return _name; } -string +String Service::clustername() const { return _clustername; @@ -64,7 +64,7 @@ return _nodename.size(); } -string +String Service::nodename() const { return _nodename; @@ -82,7 +82,7 @@ return _autostart; } -string +String Service::time_since_transition() const { return _time_since_transition; --- conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp 2006/06/19 21:21:54 1.2 +++ conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp 2006/08/10 22:53:08 1.3 @@ -57,7 +57,7 @@ { _connect_time = time_sec(); _rand_state = time_mil(); - log(string("Communicator created, port ") + _port, LogCommunicator); + log(String("Communicator created, port ") + _port, LogCommunicator); } Communicator::~Communicator() @@ -67,15 +67,15 @@ } void -Communicator::send(const std::string& msg) +Communicator::send(const String& msg) { MutexLocker l(_mutex); _out_q.push_back(msg); } void -Communicator::update_peers(const string& self, - const std::vector& hosts) +Communicator::update_peers(const String& self, + const std::vector& hosts) { MutexLocker l(_mutex); _my_hostname = self; @@ -88,9 +88,9 @@ Communicator::run() { while (!shouldStop()) { - vector names; - vector que; - string my_hostname; + vector names; + vector que; + String my_hostname; { MutexLocker l(_mutex); my_hostname = _my_hostname; @@ -102,15 +102,15 @@ } // remove non-peers - vector remove_us; - for (map::iterator iter = _peers.begin(); + vector remove_us; + for (map::iterator iter = _peers.begin(); iter != _peers.end(); iter++) { - const string& name = iter->first; + const String& name = iter->first; if (find(names.begin(), names.end(), name) == names.end()) remove_us.push_back(name); } - for (vector::iterator iter = remove_us.begin(); + for (vector::iterator iter = remove_us.begin(); iter != remove_us.end(); iter++) { log("dropping connection with " + *iter, LogCommunicator); @@ -119,25 +119,25 @@ // connect to peers if (time_to_connect()) { - for (vector::iterator iter = names.begin(); + for (vector::iterator iter = names.begin(); iter != names.end(); iter ++) { - const string& name = *iter; + const String& name = *iter; if (_peers.find(name) == _peers.end()) try { - _peers.insert(pair(name, Peer(name, _port))); + _peers.insert(pair(name, Peer(name, _port))); log("connected to " + name + ", socket " + _peers[name].get_sock_fd(), LogCommunicator); } catch ( ... ) {} } } // buffer msgs - for (vector::iterator iter_q = que.begin(); + for (vector::iterator iter_q = que.begin(); iter_q != que.end(); iter_q++) { - string& msg = *iter_q; + String& msg = *iter_q; _delivery_point.msg_arrived(my_hostname, msg); - for (map::iterator iter_p = _peers.begin(); + for (map::iterator iter_p = _peers.begin(); iter_p != _peers.end(); iter_p++) iter_p->second.append(msg); @@ -149,10 +149,10 @@ } void -Communicator::serve_sockets(vector& names) +Communicator::serve_sockets(vector& names) { map fd_peer; - for (map::iterator iter = _peers.begin(); + for (map::iterator iter = _peers.begin(); iter != _peers.end(); iter++) { Peer& peer = iter->second; @@ -182,7 +182,7 @@ if (errno == EINTR) return; else - throw string("Communicator::run(): poll() error"); + throw String("Communicator::run(): poll() error"); } // process events @@ -194,29 +194,29 @@ if (poll_info.revents & POLLIN) { try { ClientSocket sock = _serv_sock.accept(); - string hostname; - for (vector::iterator iter = names.begin(); + String hostname; + for (vector::iterator iter = names.begin(); iter != names.end(); iter++) { - string& name = *iter; + String& name = *iter; if (sock.connected_to(name)) hostname = name; } if (hostname.size()) { - _peers.insert(pair(hostname, Peer(hostname, sock))); + _peers.insert(pair(hostname, Peer(hostname, sock))); log("accepted connection from " + hostname + ", socket " + sock.get_sock(), LogCommunicator); } } catch ( ... ) {} } if (poll_info.revents & (POLLERR | POLLHUP | POLLNVAL)) - throw string("Communicator::run(): server socket error????"); + throw String("Communicator::run(): server socket error????"); } // client socket else { Peer& peer = fd_peer[poll_info.fd]; if (poll_info.revents & POLLIN) { - vector msgs; + vector msgs; try { msgs = peer.receive(); } catch ( ... ) { --- conga/ricci/modules/cluster/clumon/src/daemon/Communicator.h 2006/06/19 21:21:54 1.2 +++ conga/ricci/modules/cluster/clumon/src/daemon/Communicator.h 2006/08/10 22:53:08 1.3 @@ -29,7 +29,7 @@ #include "Socket.h" #include "Peer.h" -#include +#include "String.h" #include #include @@ -44,8 +44,8 @@ CommDP(); virtual ~CommDP(); - virtual void msg_arrived(const std::string& host, - const std::string& msg) = 0; + virtual void msg_arrived(const String& host, + const String& msg) = 0; }; @@ -55,8 +55,8 @@ Communicator(unsigned short port, CommDP& delivery_point); virtual ~Communicator(); - void send(const std::string& msg); - void update_peers(const std::string& self, const std::vector& peers); + void send(const String& msg); + void update_peers(const String& self, const std::vector& peers); private: unsigned short _port; @@ -64,14 +64,14 @@ CommDP& _delivery_point; - std::map _peers; + std::map _peers; Mutex _mutex; - std::string _my_hostname; - std::vector _out_q; - std::vector _peer_hostnames; + String _my_hostname; + std::vector _out_q; + std::vector _peer_hostnames; - void serve_sockets(std::vector&hostnames); + void serve_sockets(std::vector&hostnames); bool time_to_connect(); unsigned int _connect_time; --- conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp 2006/05/25 15:54:56 1.4 +++ conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp 2006/08/10 22:53:08 1.5 @@ -86,8 +86,8 @@ try { // get local info - string my_nodename, clustername, msg; - vector nodenames = get_local_info(my_nodename, + String my_nodename, clustername, msg; + vector nodenames = get_local_info(my_nodename, clustername, msg); @@ -105,7 +105,7 @@ _cluster = counting_auto_ptr(); } - string msg = string("monitoring iteration took ") + (time_sec() - time_beg) + " seconds"; + String msg = String("monitoring iteration took ") + (time_sec() - time_beg) + " seconds"; log(msg, LogTime); // wait some time @@ -118,12 +118,12 @@ } -string -Monitor::request(const string& msg) +String +Monitor::request(const String& msg) { MutexLocker l(_mutex); if (msg == "GET") { - string def(generateXML(XMLObject("cluster")) + "\n"); + String def(generateXML(XMLObject("cluster")) + "\n"); if (_cluster.get() == NULL) return def; try { @@ -132,13 +132,13 @@ return def; } } - throw string("invalid request"); + throw String("invalid request"); } void -Monitor::msg_arrived(const string& hostname, const string& msg_in) +Monitor::msg_arrived(const String& hostname, const String& msg_in) { - string msg(msg_in); + String msg(msg_in); // strip \n from the beggining while (msg.size()) if (msg[0] == '\n') @@ -149,7 +149,7 @@ try { XMLObject obj = parseXML(msg); if (obj.tag() == "clumond") { - string type = obj.get_attr("type"); + String type = obj.get_attr("type"); if (type == "clusterupdate") if (obj.children().size() == 1) { const XMLObject& cluster = *(obj.children().begin()); @@ -164,15 +164,15 @@ } catch ( ... ) {} } -vector -Monitor::get_local_info(string& nodename, - string& clustername, - string& msg) +vector +Monitor::get_local_info(String& nodename, + String& clustername, + String& msg) { XMLObject cluster = parse_cluster_conf(); // nodes - vector nodes; + vector nodes; for (list::const_iterator iter = cluster.children().begin(); iter != cluster.children().end(); iter++) @@ -190,13 +190,13 @@ } catch ( ... ) {} // insert current node info - const vector clustered_nodes = this->clustered_nodes(); + const vector clustered_nodes = this->clustered_nodes(); for (list::const_iterator iter = cluster.children().begin(); iter != cluster.children().end(); iter++) { XMLObject& kid = (XMLObject&) *iter; if (kid.tag() == "node") { - string name(kid.get_attr("name")); + String name(kid.get_attr("name")); if (name == nodename) { // insert info about this node -> self kid.set_attr("uptime", uptime()); @@ -220,7 +220,7 @@ XMLObject& kid = (XMLObject&) *iter_c; if (kid.tag() == "service") if (kid.get_attr("name") == service.get_attr("name")) { - for (map::const_iterator iter = service.attrs().begin(); + for (map::const_iterator iter = service.attrs().begin(); iter != service.attrs().end(); iter++) kid.set_attr(iter->first, iter->second); @@ -245,21 +245,21 @@ Monitor::parse_cluster_conf() { int status; - string out, err; - vector args; + String out, err; + vector args; args.push_back("/etc/cluster/cluster.conf"); if (execute("/bin/cat", args, out, err, status, EXECUTE_TIMEOUT)) - throw string("parse_cluster_conf(): missing cluster.conf"); + throw String("parse_cluster_conf(): missing cluster.conf"); if (status) - throw string("parse_cluster_conf(): missing cluster.conf"); + throw String("parse_cluster_conf(): missing cluster.conf"); XMLObject cluster_conf = parseXML(out); if (cluster_conf.tag() != "cluster") - throw string("parse_cluster_conf(): invalid cluster.conf"); + throw String("parse_cluster_conf(): invalid cluster.conf"); XMLObject cluster("cluster"); cluster.set_attr("alias", ""); - for (map::const_iterator iter = cluster_conf.attrs().begin(); + for (map::const_iterator iter = cluster_conf.attrs().begin(); iter != cluster_conf.attrs().end(); iter++) cluster.set_attr(iter->first, iter->second); @@ -275,7 +275,7 @@ const XMLObject& node_conf = *iter_n; if (node_conf.tag() == "clusternode") { XMLObject node("node"); - for (map::const_iterator iter_a = node_conf.attrs().begin(); + for (map::const_iterator iter_a = node_conf.attrs().begin(); iter_a != node_conf.attrs().end(); iter_a++) node.set_attr(iter_a->first, iter_a->second); @@ -289,7 +289,7 @@ const XMLObject& service_conf = *iter_s; if (service_conf.tag() == "service") { XMLObject service("service"); - for (map::const_iterator iter_a = service_conf.attrs().begin(); + for (map::const_iterator iter_a = service_conf.attrs().begin(); iter_a != service_conf.attrs().end(); iter_a++) service.set_attr(iter_a->first, iter_a->second); @@ -309,7 +309,7 @@ } counting_auto_ptr -Monitor::merge_data(const string& clustername) +Monitor::merge_data(const String& clustername) { MutexLocker l(_mutex); @@ -318,10 +318,10 @@ cluster.set_attr("config_version", "0"); unsigned int config_version = 0; - vector >::iterator> stales; - vector online_nodes; + vector >::iterator> stales; + vector online_nodes; - for (map >::iterator iter = _cache.begin(); + for (map >::iterator iter = _cache.begin(); iter != _cache.end(); iter++) { if (iter->second.first < time_sec() - 8) @@ -353,8 +353,8 @@ // build cluster counting_auto_ptr cluster_ret; - string name = cluster.get_attr("name"); - string alias = cluster.get_attr("alias"); + String name = cluster.get_attr("name"); + String alias = cluster.get_attr("alias"); unsigned int minQuorum = 0; if (sscanf(cluster.get_attr("minQuorum").c_str(), "%u", &minQuorum) != 1) cluster_ret = counting_auto_ptr (new Cluster(name, alias)); @@ -366,9 +366,9 @@ iter++) { const XMLObject& obj = *iter; if (obj.tag() == "node") { - string node_name = obj.get_attr("name"); + String node_name = obj.get_attr("name"); if (node_name.empty()) - throw string("merge_data(): node missing 'name' attr"); + throw String("merge_data(): node missing 'name' attr"); unsigned int votes; if (sscanf(obj.get_attr("votes").c_str(), "%u", &votes) != 1) votes = 1; @@ -378,7 +378,7 @@ else online = find(online_nodes.begin(), online_nodes.end(), node_name) != online_nodes.end(); bool clustered = obj.get_attr("clustered") == "true"; - string uptime = obj.get_attr("uptime"); + String uptime = obj.get_attr("uptime"); // add node to cluster cluster_ret->addNode(node_name, votes, online, clustered, uptime); } @@ -390,16 +390,16 @@ const XMLObject& obj = *iter; if (obj.tag() == "service") { // name - string service_name = obj.get_attr("name"); + String service_name = obj.get_attr("name"); if (service_name.empty()) - throw string("merge_data(): service missing 'name' attr"); + throw String("merge_data(): service missing 'name' attr"); bool running = obj.get_attr("running") == "true"; - string nodename = obj.get_attr("nodename"); + String nodename = obj.get_attr("nodename"); if (running && nodename.empty()) - throw string("merge_data(): running service missing 'nodename' attr"); + throw String("merge_data(): running service missing 'nodename' attr"); bool failed = obj.get_attr("failed") == "true"; bool autostart = obj.get_attr("autostart") != "0"; - string time_since_transition = obj.get_attr("time_since_transition"); + String time_since_transition = obj.get_attr("time_since_transition"); // add service to cluster cluster_ret->addService(service_name, nodename, failed, autostart, time_since_transition); } @@ -413,12 +413,12 @@ bool Monitor::clustered() { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("members"); if (execute("/sbin/magma_tool", args, out, err, status, EXECUTE_TIMEOUT)) - throw string("clustered(): missing magma_tool"); + throw String("clustered(): missing magma_tool"); if (status) return false; @@ -434,12 +434,12 @@ bool Monitor::quorate() { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("quorum"); if (execute("/sbin/magma_tool", args, out, err, status, EXECUTE_TIMEOUT)) - throw string("quorate(): missing magma_tool"); + throw String("quorate(): missing magma_tool"); if (status) return false; @@ -451,22 +451,22 @@ } */ -vector +vector Monitor::clustered_nodes() { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("members"); if (execute("/sbin/magma_tool", args, out, err, status, EXECUTE_TIMEOUT)) - throw string("clustered_nodes(): missing magma_tool"); + throw String("clustered_nodes(): missing magma_tool"); if (status) - return vector(); + return vector(); // split out by lines - vector lines; + vector lines; while (out.size()) { - string::size_type idx = out.find('\n'); + String::size_type idx = out.find('\n'); lines.push_back(out.substr(0, idx)); if (idx == out.npos) out = ""; @@ -474,16 +474,16 @@ out = out.substr(idx+1); } - vector running; - for (vector::iterator iter = lines.begin(); + vector running; + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string& line = *iter; + String& line = *iter; if (line.find("Member ID") != line.npos) { - string t = line.substr(line.find(": ") + 2); - string::size_type idx = t.find(','); - string name = t.substr(0, idx); - string rest = t.substr(idx); + String t = line.substr(line.find(": ") + 2); + String::size_type idx = t.find(','); + String name = t.substr(0, idx); + String rest = t.substr(idx); if (rest.find("UP") != rest.npos) running.push_back(name); } @@ -491,22 +491,22 @@ return running; } -string -Monitor::nodename(const vector& nodenames) +String +Monitor::nodename(const vector& nodenames) { - string out, err; + String out, err; int status; - if (execute("/sbin/ifconfig", vector(), out, err, status, EXECUTE_TIMEOUT)) - throw string("nodename(): missing ifconfig"); + if (execute("/sbin/ifconfig", vector(), out, err, status, EXECUTE_TIMEOUT)) + throw String("nodename(): missing ifconfig"); if (status) - throw string("nodename(): ifconfig failed???"); + throw String("nodename(): ifconfig failed???"); - for (vector::const_iterator iter = nodenames.begin(); + for (vector::const_iterator iter = nodenames.begin(); iter != nodenames.end(); iter++) { - const string& nodename = *iter; - vector ips = name2IP(nodename); - for (vector::iterator iter_ip = ips.begin(); + const String& nodename = *iter; + vector ips = name2IP(nodename); + for (vector::iterator iter_ip = ips.begin(); iter_ip != ips.end(); iter_ip++) { if (out.find(*iter_ip) != out.npos) @@ -522,14 +522,14 @@ vector services; try { - string out, err; + String out, err; int status; - vector args; + vector args; bool fast_available = false; // clustat -f ? args.push_back("-h"); if (execute("/usr/sbin/clustat", args, out, err, status, EXECUTE_TIMEOUT)) - throw string("services_info(): missing clustat"); + throw String("services_info(): missing clustat"); if (status) return vector(); if (out.find("-f") != out.npos) @@ -540,7 +540,7 @@ args.push_back("-f"); args.push_back("-x"); if (execute("/usr/sbin/clustat", args, out, err, status, EXECUTE_TIMEOUT)) - throw string("services_info(): missing clustat"); + throw String("services_info(): missing clustat"); if (status) return vector(); @@ -607,38 +607,38 @@ return services; } -string +String Monitor::uptime() const { struct sysinfo s_info; if (sysinfo(&s_info)) return ""; - return string(utils::to_string(s_info.uptime)); + return String(utils::to_string(s_info.uptime)); } -string +String Monitor::probe_quorum() const { int status; - string out, err; - vector args; + String out, err; + vector args; args.push_back("/proc/cluster/status"); if (execute("/bin/cat", args, out, err, status, EXECUTE_TIMEOUT)) - throw string("no /proc/cluster/status"); + throw String("no /proc/cluster/status"); if (status) - throw string("no /proc/cluster/status"); + throw String("no /proc/cluster/status"); - vector lines = utils::split(out, "\n"); - for (vector::const_iterator iter = lines.begin(); + vector lines = utils::split(out, "\n"); + for (vector::const_iterator iter = lines.begin(); iter != lines.end(); iter++) { - vector words = utils::split(*iter); + vector words = utils::split(*iter); if (words.size() != 2) continue; if (words[0] == "Quorum:") return words[1]; } - throw string("quorum not found"); + throw String("quorum not found"); } @@ -649,14 +649,14 @@ merge_xmls(const XMLObject& what, const XMLObject& with) { if (what.tag() != with.tag()) - throw string("merge_xmls(): tag mismatch"); + throw String("merge_xmls(): tag mismatch"); XMLObject new_xml(what.tag()); - for (map::const_iterator iter = what.attrs().begin(); + for (map::const_iterator iter = what.attrs().begin(); iter != what.attrs().end(); iter++) new_xml.set_attr(iter->first, iter->second); - for (map::const_iterator iter = with.attrs().begin(); + for (map::const_iterator iter = with.attrs().begin(); iter != with.attrs().end(); iter++) new_xml.set_attr(iter->first, iter->second); --- conga/ricci/modules/cluster/clumon/src/daemon/Monitor.h 2006/04/07 16:42:40 1.2 +++ conga/ricci/modules/cluster/clumon/src/daemon/Monitor.h 2006/08/10 22:53:08 1.3 @@ -24,7 +24,7 @@ #ifndef Monitor_h #define Monitor_h -#include +#include "String.h" #include #include "XML.h" @@ -43,10 +43,10 @@ Monitor(unsigned short port); virtual ~Monitor(); - std::string request(const std::string&); + String request(const String&); - virtual void msg_arrived(const std::string& host, - const std::string& msg); + virtual void msg_arrived(const String& host, + const String& msg); protected: void run(); @@ -54,26 +54,26 @@ Mutex _mutex; // _cluster and _cache counting_auto_ptr _cluster; - std::map > _cache; + std::map > _cache; Communicator _comm; // return (nodenames - my_nodename) - std::vector get_local_info(std::string& nodename, - std::string& clustername, - std::string& msg); - counting_auto_ptr merge_data(const std::string& clustername); + std::vector get_local_info(String& nodename, + String& clustername, + String& msg); + counting_auto_ptr merge_data(const String& clustername); XMLObject parse_cluster_conf(); // bool clustered(); // bool quorate(); - std::string nodename(const std::vector& nodenames); - std::vector clustered_nodes(); + String nodename(const std::vector& nodenames); + std::vector clustered_nodes(); std::vector services_info(); - std::string uptime() const; + String uptime() const; - std::string probe_quorum() const; + String probe_quorum() const; }; // class Monitor --- conga/ricci/modules/cluster/clumon/src/daemon/Peer.cpp 2006/03/27 23:15:30 1.1 +++ conga/ricci/modules/cluster/clumon/src/daemon/Peer.cpp 2006/08/10 22:53:08 1.2 @@ -31,22 +31,22 @@ Peer::Peer() : _sock(new ClientSocket()), - _in(new string()), - _out(new string()) + _in(new String()), + _out(new String()) {} -Peer::Peer(const string& hostname, const ClientSocket& sock) : +Peer::Peer(const String& hostname, const ClientSocket& sock) : _sock(new ClientSocket(sock)), _hostname(hostname), - _in(new string()), - _out(new string()) + _in(new String()), + _out(new String()) {} -Peer::Peer(const string& hostname, unsigned short port) : +Peer::Peer(const String& hostname, unsigned short port) : _sock(new ClientSocket(hostname, port)), _hostname(hostname), - _in(new string()), - _out(new string()) + _in(new String()), + _out(new String()) {} Peer::~Peer() @@ -68,21 +68,21 @@ if (_out->empty()) return; log("sending data to " + _hostname, LogTransfer); - string rest = _sock->send(*_out); + String rest = _sock->send(*_out); *_out = rest; } -vector +vector Peer::receive() { log("receiving data from " + _hostname, LogTransfer); - string& in = *_in; + String& in = *_in; in += _sock->recv(); - vector ret; + vector ret; while (true) { - string::size_type idx = in.find("\n\n"); + String::size_type idx = in.find("\n\n"); if (idx == in.npos) return ret; idx += 2; @@ -92,7 +92,7 @@ } void -Peer::append(const string& msg) +Peer::append(const String& msg) { _out->append(msg); } @@ -103,7 +103,7 @@ return _sock->get_sock(); } -string +String Peer::hostname() { return _hostname; --- conga/ricci/modules/cluster/clumon/src/daemon/Peer.h 2006/03/27 23:15:30 1.1 +++ conga/ricci/modules/cluster/clumon/src/daemon/Peer.h 2006/08/10 22:53:08 1.2 @@ -28,7 +28,7 @@ #include "Socket.h" #include -#include +#include "String.h" namespace ClusterMonitoring @@ -39,29 +39,29 @@ { public: Peer(); - Peer(const std::string& hostname, const ClientSocket&); - Peer(const std::string& hostname, unsigned short port); + Peer(const String& hostname, const ClientSocket&); + Peer(const String& hostname, unsigned short port); virtual ~Peer(); void send(); - std::vector receive(); + std::vector receive(); bool outq_empty() { return _out->empty(); } - void append(const std::string& msg); + void append(const String& msg); int get_sock_fd(); - std::string hostname(); + String hostname(); bool operator== (const Peer&) const; private: counting_auto_ptr _sock; - const std::string _hostname; + const String _hostname; - counting_auto_ptr _in; - counting_auto_ptr _out; + counting_auto_ptr _in; + counting_auto_ptr _out; }; // class Peer --- conga/ricci/modules/cluster/clumon/src/daemon/main.cpp 2006/03/27 23:15:30 1.1 +++ conga/ricci/modules/cluster/clumon/src/daemon/main.cpp 2006/08/10 22:53:08 1.2 @@ -59,11 +59,11 @@ { public: ClientInfo() {} - ClientInfo(ClientSocket& sock, string str="") : + ClientInfo(ClientSocket& sock, String str="") : sock(sock), str(str) {} ClientSocket sock; - string str; + String str; }; @@ -116,7 +116,7 @@ unblock_signal(SIGSEGV); serve_clients(monitor, server); - } catch (string e) { + } catch (String e) { log("unhandled exception in main(): " + e); log("died", LogAll); return 1; @@ -165,7 +165,7 @@ if (errno == EINTR) continue; else - throw string("serve_clients(): poll() error"); + throw String("serve_clients(): poll() error"); } // process events @@ -181,7 +181,7 @@ } catch ( ... ) {} } if (poll_info.revents & (POLLERR | POLLHUP | POLLNVAL)) - throw string("serve_clients(): server socket error????"); + throw String("serve_clients(): server socket error????"); } // client socket else { --- conga/ricci/modules/cluster/clumon/src/include/Cluster.h 2006/05/25 15:54:56 1.4 +++ conga/ricci/modules/cluster/clumon/src/include/Cluster.h 2006/08/10 22:53:08 1.5 @@ -25,7 +25,7 @@ #define Cluster_h #include -#include +#include "String.h" #include #include @@ -41,33 +41,33 @@ class Cluster; -std::string cluster2xml(Cluster& cluster); -counting_auto_ptr xml2cluster(const std::string& xml); +String cluster2xml(Cluster& cluster); +counting_auto_ptr xml2cluster(const String& xml); class Cluster { public: - Cluster(const std::string& name, const std::string& alias, unsigned int minQuorum=0); + Cluster(const String& name, const String& alias, unsigned int minQuorum=0); virtual ~Cluster(); - std::string name(); - std::string alias(); + String name(); + String alias(); unsigned int votes(); unsigned int minQuorum(); bool quorate(); - counting_auto_ptr addNode(const std::string& name, + counting_auto_ptr addNode(const String& name, unsigned int votes, bool online, bool clustered, - const std::string& uptime); + const String& uptime); - counting_auto_ptr addService(const std::string& name, - const std::string& nodeName, + counting_auto_ptr addService(const String& name, + const String& nodeName, bool failed, bool autostart, - const std::string& time_since_transition); + const String& time_since_transition); std::list > nodes(); std::list > clusteredNodes(); @@ -79,10 +79,10 @@ std::list > failedServices(); private: - std::string _name; - std::string _alias; + String _name; + String _alias; unsigned int _minQuorum; - std::map > _nodes; + std::map > _nodes; }; @@ -90,36 +90,36 @@ class Node { public: - Node(const std::string& name, - const std::string& clustername, + Node(const String& name, + const String& clustername, unsigned int votes, bool online, bool clustered, - const std::string& uptime); + const String& uptime); virtual ~Node(); - std::string name() const; - std::string clustername() const; + String name() const; + String clustername() const; unsigned int votes() const; bool online() const; bool clustered() const; // available to cluster - std::string uptime() const; + String uptime() const; - counting_auto_ptr addService(const std::string& name, + counting_auto_ptr addService(const String& name, bool failed, bool autostart, - const std::string& time_since_transition); + const String& time_since_transition); std::list > services(); private: - std::string _name; - std::string _clustername; + String _name; + String _clustername; unsigned int _votes; bool _online; bool _clustered; // available to cluster - std::string _uptime; + String _uptime; - std::map > _services; + std::map > _services; }; @@ -127,29 +127,29 @@ class Service { public: - Service(const std::string& name, - const std::string& clustername, + Service(const String& name, + const String& clustername, const Node& node, bool failed, bool autostart, - const std::string& time_since_transition); + const String& time_since_transition); virtual ~Service(); - std::string name() const; - std::string clustername() const; + String name() const; + String clustername() const; bool running() const; - std::string nodename() const; + String nodename() const; bool failed() const; bool autostart() const; - std::string time_since_transition() const; + String time_since_transition() const; private: - std::string _name; - std::string _clustername; - std::string _nodename; + String _name; + String _clustername; + String _nodename; bool _autostart; bool _failed; - std::string _time_since_transition; + String _time_since_transition; }; --- conga/ricci/modules/cluster/clumon/src/include/ClusterMonitor.h 2006/06/14 21:44:37 1.1 +++ conga/ricci/modules/cluster/clumon/src/include/ClusterMonitor.h 2006/08/10 22:53:08 1.2 @@ -28,7 +28,7 @@ #include "counting_auto_ptr.h" #include "clumond_globals.h" -#include +#include "String.h" namespace ClusterMonitoring @@ -38,13 +38,13 @@ class ClusterMonitor { public: - ClusterMonitor(const std::string& socket_path=MONITORING_CLIENT_SOCKET); + ClusterMonitor(const String& socket_path=MONITORING_CLIENT_SOCKET); virtual ~ClusterMonitor(); counting_auto_ptr get_cluster(); private: - std::string _sock_path; + String _sock_path; ClusterMonitor(const ClusterMonitor&); ClusterMonitor& operator= (const ClusterMonitor&); --- conga/ricci/modules/cluster/clumon/src/snmp-agent/clusterMIB.cpp 2006/06/19 21:21:54 1.2 +++ conga/ricci/modules/cluster/clumon/src/snmp-agent/clusterMIB.cpp 2006/08/10 22:53:08 1.3 @@ -34,7 +34,7 @@ static unsigned int getStatusCode(Cluster*); -static string getStatusDescription(unsigned int code); +static String getStatusDescription(unsigned int code); void @@ -241,7 +241,7 @@ return code; } -string +String getStatusDescription(unsigned int code) { if (code == 1) @@ -251,23 +251,23 @@ if (code & 16) return "Not quorate (all services stopped)"; - string descr; + String descr; if (code & 2) { - string c = "Some services failed"; + String c = "Some services failed"; if (descr.size() == 0) descr = c; else descr += ", " + c; } if (code & 4) { - string c = "Some services not running"; + String c = "Some services not running"; if (descr.size() == 0) descr = c; else descr += ", " + c; } if (code & 8) { - string c = "Some nodes unavailable"; + String c = "Some nodes unavailable"; if (descr.size() == 0) descr = c; else @@ -376,7 +376,7 @@ return SNMP_ERR_NOERROR; list > l = cluster->failedServices(); - string str; + String str; for (list >::iterator iter = l.begin(); iter != l.end(); iter++) @@ -429,7 +429,7 @@ return SNMP_ERR_NOERROR; unsigned int code = getStatusCode(cluster.get()); - string str = getStatusDescription(code); + String str = getStatusDescription(code); /* * We are never called for a GETNEXT if it's registered as a @@ -565,7 +565,7 @@ return SNMP_ERR_NOERROR; list > l = cluster->stoppedServices(); - string str; + String str; for (list >::iterator iter = l.begin(); iter != l.end(); iter++) @@ -663,7 +663,7 @@ return SNMP_ERR_NOERROR; list > l = cluster->clusteredNodes(); - string str; + String str; for (list >::iterator iter = l.begin(); iter != l.end(); iter++) @@ -761,7 +761,7 @@ return SNMP_ERR_NOERROR; list > l = cluster->services(); - string str; + String str; for (list >::iterator iter = l.begin(); iter != l.end(); iter++) @@ -813,7 +813,7 @@ if(cluster.get() == NULL) return SNMP_ERR_NOERROR; - string name = cluster->name(); + String name = cluster->name(); /* * We are never called for a GETNEXT if it's registered as a @@ -949,7 +949,7 @@ return SNMP_ERR_NOERROR; list > l = cluster->unclusteredNodes(); - string str; + String str; for (list >::iterator iter = l.begin(); iter != l.end(); iter++) @@ -1047,7 +1047,7 @@ return SNMP_ERR_NOERROR; list > l = cluster->nodes(); - string str; + String str; for (list >::iterator iter = l.begin(); iter != l.end(); iter++) @@ -1145,7 +1145,7 @@ return SNMP_ERR_NOERROR; list > l = cluster->runningServices(); - string str; + String str; for (list >::iterator iter = l.begin(); iter != l.end(); iter++) --- conga/ricci/modules/cluster/clumon/src/snmp-agent/nodesMIB_access.cpp 2006/06/14 21:44:37 1.1 +++ conga/ricci/modules/cluster/clumon/src/snmp-agent/nodesMIB_access.cpp 2006/08/10 22:53:08 1.2 @@ -41,7 +41,7 @@ static unsigned int getStatusCode(counting_auto_ptr); -static string getStatusDescription(unsigned int code); +static String getStatusDescription(unsigned int code); class LoopContext @@ -83,7 +83,7 @@ { return _node; } - string str_holder; + String str_holder; long long_holder; private: @@ -130,7 +130,7 @@ if (node.get() == NULL) return NULL; - const string& name = node->name(); + const String& name = node->name(); snmp_set_var_value(put_index_data, (u_char *) name.c_str(), name.size()); return put_index_data; } catch ( ... ) { @@ -160,7 +160,7 @@ if (node.get() == NULL) return NULL; - const string& name = node->name(); + const String& name = node->name(); snmp_set_var_value(put_index_data, (u_char *) name.c_str(), name.size()); return put_index_data; } catch ( ... ) { @@ -258,7 +258,7 @@ return NULL; list > l = node->services(); - string str; + String str; for (list >::iterator iter = l.begin(); iter != l.end(); iter++) @@ -292,7 +292,7 @@ // OK return 2; } -string +String getStatusDescription(unsigned int code) { switch(code) { --- conga/ricci/modules/cluster/clumon/src/snmp-agent/servicesMIB_access.cpp 2006/06/14 21:44:37 1.1 +++ conga/ricci/modules/cluster/clumon/src/snmp-agent/servicesMIB_access.cpp 2006/08/10 22:53:08 1.2 @@ -39,7 +39,7 @@ static unsigned int getStatusCode(counting_auto_ptr); -static string getStatusDescription(unsigned int code); +static String getStatusDescription(unsigned int code); @@ -83,7 +83,7 @@ { return _service; } - string str_holder; + String str_holder; long long_holder; private: @@ -130,7 +130,7 @@ if (service.get() == NULL) return NULL; - const string& name = service->name(); + const String& name = service->name(); snmp_set_var_value(put_index_data, (u_char *) name.c_str(), name.size()); return put_index_data; } catch ( ... ) { @@ -160,7 +160,7 @@ if (service.get() == NULL) return NULL; - const string& name = service->name(); + const String& name = service->name(); snmp_set_var_value(put_index_data, (u_char *) name.c_str(), name.size()); return put_index_data; } catch ( ... ) { @@ -288,7 +288,7 @@ // stopped return 1; } -string +String getStatusDescription(unsigned int code) { switch(code) { --- conga/ricci/modules/log/LogParser.cpp 2006/06/14 21:18:16 1.3 +++ conga/ricci/modules/log/LogParser.cpp 2006/08/10 22:53:08 1.4 @@ -81,14 +81,14 @@ class tag_set { public: - tag_set(const string& name, - const set& elements) : + tag_set(const String& name, + const set& elements) : name(name), elements(elements) {} - string name; - set elements; - set match; + String name; + set elements; + set match; }; @@ -103,25 +103,25 @@ if (!init) { init = true; tag_set clu("cluster", - set(cluster, + set(cluster, cluster + sizeof(cluster)/sizeof(char*))); clu.match.insert("fence_"); sets.push_back(clu); sets.push_back(tag_set("cluster service manager", - set(cluster_service_manager, + set(cluster_service_manager, cluster_service_manager + sizeof(cluster_service_manager)/sizeof(char*)))); sets.push_back(tag_set("lvs", - set(LVS, + set(LVS, LVS + sizeof(LVS)/sizeof(char*)))); sets.push_back(tag_set("storage", - set(storage, + set(storage, storage + sizeof(storage)/sizeof(char*)))); tag_set SEL("selinux", - set(selinux, + set(selinux, selinux + sizeof(selinux)/sizeof(char*))); SEL.match.insert("pam_"); sets.push_back(SEL); @@ -132,20 +132,20 @@ static time_t -parse_time(const string& time_rep) +parse_time(const String& time_rep) { struct tm tm; if (!strptime(time_rep.c_str(), "%b %d %T %Y", &tm)) - throw string("invalid log entry format"); + throw String("invalid log entry format"); return mktime(&tm); } -set& -get_files(const string& path_, - set& files) +set& +get_files(const String& path_, + set& files) { - string path = utils::rstrip(utils::strip(path_), "/"); + String path = utils::rstrip(utils::strip(path_), "/"); if (path.empty() || path.find_first_of(" ; & $ ` ? > < ' \" ; | \\ * \n \t") != path.npos) return files; if (path[0] != '/') @@ -153,7 +153,7 @@ struct stat st; if (stat(path.c_str(), &st)) - // throw string("unable to stat ") + path; + // throw String("unable to stat ") + path; return files; if (S_ISREG(st.st_mode)) { files.insert(path); @@ -170,7 +170,7 @@ DIR* d = opendir(path.c_str()); if (d == NULL) - throw string("unable to open directory ") + path; + throw String("unable to open directory ") + path; try { while (true) { struct dirent* ent = readdir(d); @@ -178,7 +178,7 @@ closedir(d); return files; } - string kid_path = ent->d_name; + String kid_path = ent->d_name; if (kid_path == "." || kid_path == "..") continue; kid_path = path + "/" + kid_path; @@ -194,13 +194,13 @@ -LogEntry::LogEntry(const string& entry) +LogEntry::LogEntry(const String& entry) { - vector words = utils::split(entry); + vector words = utils::split(entry); if (words.size() < 6) - throw string("invalid log entry format"); + throw String("invalid log entry format"); if (words[4] == "last" && words[5] == "message") - throw string("LogEntry: last message repeatition"); + throw String("LogEntry: last message repeatition"); // get current year (not present in log files) char buff[100]; @@ -208,9 +208,9 @@ struct tm tm; localtime_r(¤t_time, &tm); if (strftime(buff, sizeof(buff), "%Y", &tm) != 4) - throw string("failed to get current year"); - string year(buff, 4); - string time_rep = words[0] + " " + words[1] + " " + words[2] + " " + year; + throw String("failed to get current year"); + String year(buff, 4); + String time_rep = words[0] + " " + words[1] + " " + words[2] + " " + year; age = (long long) difftime(current_time, parse_time(time_rep)); if (age < 0) { // beginning of the year fix, since year is not present in log files @@ -220,11 +220,11 @@ age = (long long) difftime(current_time, parse_time(time_rep)); } if (age < 0) - throw string("error in LogEntry() - negative age"); + throw String("error in LogEntry() - negative age"); // domain & pid - string d = utils::rstrip(utils::to_lower(words[4]), ":"); - string::size_type i = d.find("["); + String d = utils::rstrip(utils::to_lower(words[4]), ":"); + String::size_type i = d.find("["); domain = d.substr(0, i); tags.insert(domain); if (i != d.npos) { @@ -233,7 +233,7 @@ pid = utils::rstrip(pid, "]"); tags.insert(pid); } - vector::size_type idx = 5; + vector::size_type idx = 5; if (domain == "kernel") if (words[5][words[5].size()-1] == ':') { domain = utils::rstrip(utils::to_lower(words[5]), ":"); @@ -261,8 +261,8 @@ } // tags (misc) - for (vector::size_type j=4; j<6; j++) { - string t(utils::strip(utils::to_lower(words[j]))); + for (vector::size_type j=4; j<6; j++) { + String t(utils::strip(utils::to_lower(words[j]))); if (t.empty()) continue; if (t[t.size()-1] != ':') @@ -271,7 +271,7 @@ tags.insert(t); if ((i = t.find("(")) != t.npos) { tags.insert(utils::strip(t.substr(0, i))); - string tmp_tag = utils::strip(t.substr(i)); + String tmp_tag = utils::strip(t.substr(i)); tmp_tag = tmp_tag.substr(0, tmp_tag.find(")")); tmp_tag = utils::lstrip(tmp_tag, "("); tmp_tag = utils::rstrip(tmp_tag, ")"); @@ -279,7 +279,7 @@ } if ((i = t.find("[")) != t.npos) { tags.insert(utils::strip(t.substr(0, i))); - string tmp_tag = utils::strip(t.substr(i)); + String tmp_tag = utils::strip(t.substr(i)); tmp_tag = tmp_tag.substr(0, tmp_tag.find("]")); tmp_tag = utils::lstrip(tmp_tag, "["); tmp_tag = utils::rstrip(tmp_tag, "]"); @@ -289,8 +289,8 @@ // tags (from tag sets) vector sets = get_sets(); - set tags_c(tags); - for (set::const_iterator iter = tags_c.begin(); + set tags_c(tags); + for (set::const_iterator iter = tags_c.begin(); iter != tags_c.end(); iter++) for (vector::const_iterator ts_iter = sets.begin(); @@ -298,7 +298,7 @@ ts_iter++) { if (ts_iter->elements.find(*iter) != ts_iter->elements.end()) tags.insert(ts_iter->name); - for (set::const_iterator m_iter = ts_iter->match.begin(); + for (set::const_iterator m_iter = ts_iter->match.begin(); m_iter != ts_iter->match.end(); m_iter++) if (iter->find(*m_iter) == 0) @@ -308,10 +308,10 @@ tags.erase(""); } -string +String LogEntry::compare_str() const { - string b(utils::to_string(age)); + String b(utils::to_string(age)); b += domain + pid + msg; return b; } @@ -331,7 +331,7 @@ x.set_attr("age", utils::to_string(age)); x.set_attr("msg", msg); - for (set::const_iterator iter = matched_tags.begin(); + for (set::const_iterator iter = matched_tags.begin(); iter != matched_tags.end(); iter++) { XMLObject t("match"); @@ -350,17 +350,17 @@ set LogParser::get_entries(long long age, - const std::list& domains, - const list& paths) + const std::list& domains, + const list& paths) { set ret; // set of requested tags - set req_tags(domains.begin(), domains.end()); + set req_tags(domains.begin(), domains.end()); // get log paths - set files; - for (list::const_iterator iter = paths.begin(); + set files; + for (list::const_iterator iter = paths.begin(); iter != paths.end(); iter++) get_files(*iter, files); @@ -370,7 +370,7 @@ } // process log files - for (set::const_iterator iter = files.begin(); + for (set::const_iterator iter = files.begin(); iter != files.end(); iter++) { ifstream log(iter->c_str()); @@ -385,7 +385,7 @@ ret.insert(e); else { bool add = false; - for (set::const_iterator t_iter = req_tags.begin(); + for (set::const_iterator t_iter = req_tags.begin(); t_iter != req_tags.end(); t_iter++) if (e.tags.find(*t_iter) != e.tags.end()) { --- conga/ricci/modules/log/LogParser.h 2006/06/05 19:54:40 1.2 +++ conga/ricci/modules/log/LogParser.h 2006/08/10 22:53:08 1.3 @@ -26,7 +26,7 @@ #include "XML.h" -#include +#include "String.h" #include #include @@ -34,15 +34,15 @@ class LogEntry { public: - LogEntry(const std::string& entry); + LogEntry(const String& entry); long long age; - std::string domain; - std::string msg; - std::string pid; + String domain; + String msg; + String pid; - std::set tags; - std::set matched_tags; + std::set tags; + std::set matched_tags; XMLObject xml() const; @@ -50,7 +50,7 @@ private: - std::string compare_str() const; + String compare_str() const; }; @@ -61,8 +61,8 @@ public: std::set get_entries(long long age, - const std::list& tags, - const std::list& paths); + const std::list& tags, + const std::list& paths); }; --- conga/ricci/modules/log/LoggingModule.cpp 2006/06/05 19:54:40 1.2 +++ conga/ricci/modules/log/LoggingModule.cpp 2006/08/10 22:53:08 1.3 @@ -59,8 +59,8 @@ get(const VarMap& args) { long long age; - list tags; - list paths; + list tags; + list paths; bool intersection = false; try { VarMap::const_iterator iter = args.find("age"); @@ -79,25 +79,25 @@ iter = args.find("intersection"); if (iter != args.end()) intersection = iter->second.get_bool(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } // clean up - list t; - for (list::const_iterator iter = tags.begin(); + list t; + for (list::const_iterator iter = tags.begin(); iter != tags.end(); iter++) { - string s(utils::strip(utils::to_lower(*iter))); + String s(utils::strip(utils::to_lower(*iter))); if (s.size()) t.push_back(s); } tags.swap(t); t.clear(); - for (list::const_iterator iter = paths.begin(); + for (list::const_iterator iter = paths.begin(); iter != paths.end(); iter++) { - string s(utils::strip(*iter)); + String s(utils::strip(*iter)); if (s.size()) t.push_back(s); } @@ -131,6 +131,6 @@ Variable var("log_entries", result_list); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } --- conga/ricci/modules/log/main.cpp 2006/06/02 00:14:29 1.1 +++ conga/ricci/modules/log/main.cpp 2006/08/10 22:53:08 1.2 @@ -32,7 +32,7 @@ try { LoggingModule m; return stdin_out_module_driver(m); - } catch (string e) { + } catch (String e) { cerr << e << endl; return 1; } --- conga/ricci/modules/rpm/PackageHandler.cpp 2006/05/23 17:45:38 1.3 +++ conga/ricci/modules/rpm/PackageHandler.cpp 2006/08/10 22:53:08 1.4 @@ -48,7 +48,7 @@ FC5(false) { char* buff = 0; - string release; + String release; try { ifstream is("/etc/redhat-release"); is.seekg(0, ios::end); @@ -57,7 +57,7 @@ buff = new char[length]; is.read(buff, length); - string rel(buff, length); + String rel(buff, length); delete [] buff; buff = 0; @@ -87,12 +87,12 @@ rhn_available = false; // check if there are subscribed channels if (rhn_available) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("--show-channels"); if (utils::execute(UP2DATE_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) rhn_available = false; } @@ -104,38 +104,38 @@ return false; } -map +map PackageInstaller::available_rpms() { - map rpms; + map rpms; if (!available()) return rpms; - string out, err; + String out, err; int status; - vector args; + vector args; if (RHEL4) { out = err = ""; args.clear(); args.push_back("--showall"); if (utils::execute(UP2DATE_PATH, args, out, err, status, false)) - throw string("execute failed"); - vector lines = utils::split(utils::strip(out), "\n"); - for (vector::const_iterator iter = lines.begin(); + throw String("execute failed"); + vector lines = utils::split(utils::strip(out), "\n"); + for (vector::const_iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line(*iter); + String line(*iter); line = utils::strip(line); - vector words = utils::split(line, "-"); - vector::size_type l = words.size(); + vector words = utils::split(line, "-"); + vector::size_type l = words.size(); if (l < 3) continue; - string name = words[0]; + String name = words[0]; for (unsigned int i=1; i lines = utils::split(utils::strip(out), "\n"); - for (vector::const_iterator iter = lines.begin(); + throw String("execute failed"); + vector lines = utils::split(utils::strip(out), "\n"); + for (vector::const_iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line(*iter); + String line(*iter); line = utils::strip(line); - vector words = utils::split(line); - vector::size_type l = words.size(); + vector words = utils::split(line); + vector::size_type l = words.size(); if (l != 3) continue; - string name = words[0]; - string::size_type idx = name.rfind('.'); - if (idx == string::npos) + String name = words[0]; + String::size_type idx = name.rfind('.'); + if (idx == String::npos) continue; name = name.substr(0, idx); - string version = words[1]; + String version = words[1]; rpms[name] = version; } } @@ -171,7 +171,7 @@ } bool -PackageInstaller::install(vector rpms) +PackageInstaller::install(vector rpms) { if (!available()) return rpms.empty(); @@ -179,42 +179,42 @@ if (rpms.empty()) return true; - string out, err; + String out, err; int status; - vector args; + vector args; if (RHEL4) { out = err = ""; args.clear(); - for (vector::size_type i=0; i::size_type i=0; i rpms_to_install; + vector rpms_to_install; out = err = ""; args.clear(); args.push_back("-y"); args.push_back("list"); args.push_back("installed"); if (utils::execute(YUM_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) return false; - vector lines = utils::split(utils::strip(out), "\n"); - for (vector::const_iterator rpm = rpms.begin(); + vector lines = utils::split(utils::strip(out), "\n"); + for (vector::const_iterator rpm = rpms.begin(); rpm != rpms.end(); rpm++) { bool install = true; - for (vector::const_iterator iter = lines.begin(); + for (vector::const_iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line(*iter); + String line(*iter); line = utils::strip(line); if (line.find(*rpm + ".") == 0) install = false; @@ -227,12 +227,12 @@ args.clear(); args.push_back("-y"); args.push_back("install"); - for (vector::const_iterator rpm = rpms_to_install.begin(); + for (vector::const_iterator rpm = rpms_to_install.begin(); rpm != rpms_to_install.end(); rpm++) args.push_back(*rpm); if (utils::execute(YUM_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) return false; } @@ -241,12 +241,12 @@ args.clear(); args.push_back("-y"); args.push_back("update"); - for (vector::const_iterator rpm = rpms.begin(); + for (vector::const_iterator rpm = rpms.begin(); rpm != rpms.end(); rpm++) args.push_back(*rpm); if (utils::execute(YUM_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) return false; return true; @@ -264,7 +264,7 @@ Package::Package() {} -Package::Package(const string& name) : +Package::Package(const String& name) : name(name) { @@ -295,7 +295,7 @@ upgradeable(false) {} -PackageSet::PackageSet(const string& name) : +PackageSet::PackageSet(const String& name) : name(name), installed(false), in_repo(false), @@ -330,25 +330,25 @@ // get installed packages - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("-qa"); if (utils::execute(RPM_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("rpm -qa failed"); - vector lines = utils::split(out, "\n"); - for (vector::const_iterator iter = lines.begin(); + throw String("rpm -qa failed"); + vector lines = utils::split(out, "\n"); + for (vector::const_iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line(*iter); + String line(*iter); line = utils::strip(line); - vector words = utils::split(line, "-"); - vector::size_type l = words.size(); + vector words = utils::split(line, "-"); + vector::size_type l = words.size(); if (l < 3) continue; - string name = words[0]; + String name = words[0]; for (unsigned int i=1; i avail_rpms = _pi.available_rpms(); - for (map::const_iterator iter = avail_rpms.begin(); + map avail_rpms = _pi.available_rpms(); + for (map::const_iterator iter = avail_rpms.begin(); iter != avail_rpms.end(); iter++) { - string name = iter->first; - string version = iter->second; + String name = iter->first; + String version = iter->second; Package& pack = _packages[name]; pack.name = name; pack.repo_version = version; @@ -373,7 +373,7 @@ // build sets _sets = build_sets(); - for (map::iterator iter = _sets.begin(); + for (map::iterator iter = _sets.begin(); iter != _sets.end(); iter++) populate_set(iter->second); @@ -383,23 +383,23 @@ {} -std::map& +std::map& PackageHandler::packages() { return _packages; } -std::map& +std::map& PackageHandler::sets() { return _sets; } -std::map +std::map PackageHandler::build_sets() { - map sets; + map sets; PackageSet set = build_cluster_base_set(); sets[set.name] = set; @@ -429,14 +429,14 @@ set.packages.push_back("fence"); // find kernel type - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("-r"); if (utils::execute(UNAME_PATH, args, out, err, status, true)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("uname -r failed"); + throw String("uname -r failed"); if (out.find("smp") != out.npos) { set.packages.push_back("cman-kernel-smp"); set.packages.push_back("dlm-kernel-smp"); @@ -478,14 +478,14 @@ set.packages.push_back("lvm2-cluster"); // find kernel type - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("-r"); if (utils::execute(UNAME_PATH, args, out, err, status, true)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("uname -r failed"); + throw String("uname -r failed"); if (out.find("smp") != out.npos) { set.packages.push_back("GFS-kernel-smp"); } else if (out.find("hugemem") != out.npos) { @@ -513,11 +513,11 @@ set.in_repo = true; set.upgradeable = false; - for (list::const_iterator name_iter = set.packages.begin(); + for (list::const_iterator name_iter = set.packages.begin(); name_iter != set.packages.end(); name_iter++) { - const string& name = *name_iter; - map::const_iterator iter = _packages.find(name); + const String& name = *name_iter; + map::const_iterator iter = _packages.find(name); if (iter == _packages.end()) { set.installed = false; set.in_repo = false; @@ -543,21 +543,21 @@ const std::list& sets) { if (!repo_available()) - throw string("System not configured to use repositories"); + throw String("System not configured to use repositories"); - vector rpms; + vector rpms; PackageHandler h_pre; for (list::const_iterator iter = packages.begin(); iter != packages.end(); iter++) { - string name(iter->name); - map::iterator pack_iter = h_pre.packages().find(name); + String name(iter->name); + map::iterator pack_iter = h_pre.packages().find(name); if (pack_iter == h_pre.packages().end()) - throw string("package ") + name + " not present in repository"; + throw String("package ") + name + " not present in repository"; else { if (pack_iter->second.repo_version.empty()) - throw string("package ") + name + " not present in repository"; + throw String("package ") + name + " not present in repository"; else rpms.push_back(name); } @@ -566,24 +566,24 @@ for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) { - string name(iter->name); - map::iterator set_iter = h_pre.sets().find(name); + String name(iter->name); + map::iterator set_iter = h_pre.sets().find(name); if (set_iter == h_pre.sets().end()) - throw string("set ") + name + " not present in repository"; + throw String("set ") + name + " not present in repository"; else { PackageSet& p_set = set_iter->second; if (p_set.in_repo) - for (list::const_iterator name_iter = p_set.packages.begin(); + for (list::const_iterator name_iter = p_set.packages.begin(); name_iter != p_set.packages.end(); name_iter++) rpms.push_back(*name_iter); else - throw string("packages of set ") + name + " not present in repository"; + throw String("packages of set ") + name + " not present in repository"; } } if (!_pi.install(rpms)) - throw string("unable to install packages"); + throw String("unable to install packages"); } --- conga/ricci/modules/rpm/PackageHandler.h 2006/05/23 17:45:38 1.2 +++ conga/ricci/modules/rpm/PackageHandler.h 2006/08/10 22:53:08 1.3 @@ -25,7 +25,7 @@ #define PackageHandler_h #include "XML.h" -#include +#include "String.h" #include #include @@ -34,14 +34,14 @@ { public: Package(); - Package(const std::string& name); + Package(const String& name); virtual ~Package(); - std::string name; - std::string summary; - std::string description; - std::string version; - std::string repo_version; + String name; + String summary; + String description; + String version; + String repo_version; XMLObject xml() const; @@ -54,17 +54,17 @@ { public: PackageSet(); - PackageSet(const std::string& name); + PackageSet(const String& name); virtual ~PackageSet(); - std::string name; - std::string summary; - std::string description; + String name; + String summary; + String description; bool installed; bool in_repo; bool upgradeable; - std::list packages; + std::list packages; XMLObject xml() const; @@ -80,8 +80,8 @@ virtual ~PackageInstaller(); bool available(); - std::map available_rpms(); - bool install(std::vector rpm_names); + std::map available_rpms(); + bool install(std::vector rpm_names); private: @@ -97,15 +97,15 @@ PackageHandler(); virtual ~PackageHandler(); - std::map& packages(); - std::map& sets(); + std::map& packages(); + std::map& sets(); void populate_set(PackageSet& set); static bool repo_available(); - static std::map build_sets(); + static std::map build_sets(); static PackageSet build_cluster_base_set(); static PackageSet build_cluster_base_gulm_set(); static PackageSet build_cluster_services_set(); @@ -117,8 +117,8 @@ private: - std::map _packages; - std::map _sets; + std::map _packages; + std::map _sets; static PackageInstaller _pi; --- conga/ricci/modules/rpm/RpmModule.cpp 2006/04/07 16:42:40 1.1 +++ conga/ricci/modules/rpm/RpmModule.cpp 2006/08/10 22:53:08 1.2 @@ -72,7 +72,7 @@ iter = args.find("sets"); if (iter != args.end()) sets_list = iter->second.get_list_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -82,7 +82,7 @@ iter != rpms_list.end(); iter++) if (iter->tag() == "rpm") { - string name(iter->get_attr("name")); + String name(iter->get_attr("name")); if (name.size()) { Package pack(name); rpms.push_back(pack); @@ -94,7 +94,7 @@ iter != sets_list.end(); iter++) if (iter->tag() == "set") { - string name(iter->get_attr("name")); + String name(iter->get_attr("name")); if (name.size()) { PackageSet set(name); sets.push_back(set); @@ -111,7 +111,7 @@ Variable var("repository_configured", PackageHandler::repo_available()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -144,7 +144,7 @@ iter = args.find("upgradeable"); if (iter != args.end()) upgradeable = iter->second.get_bool(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -156,7 +156,7 @@ if (rpms) { list rpm_list; - for (map::const_iterator iter = handler.packages().begin(); + for (map::const_iterator iter = handler.packages().begin(); iter != handler.packages().end(); iter++ ) { const Package& pack = iter->second; @@ -176,12 +176,12 @@ rpm_list.push_back(pack.xml()); } Variable var("rpms", rpm_list); - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); } if (sets) { list set_list; - for (map::const_iterator iter = handler.sets().begin(); + for (map::const_iterator iter = handler.sets().begin(); iter != handler.sets().end(); iter++ ) { const PackageSet& set = iter->second; @@ -201,7 +201,7 @@ set_list.push_back(set.xml()); } Variable var("sets", set_list); - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); } } @@ -217,7 +217,7 @@ if (iter == args.end()) throw APIerror("missing search variable"); search_list = iter->second.get_list_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -228,14 +228,14 @@ iter != search_list.end(); iter++) { if (iter->tag() == "rpm") { - string name(iter->get_attr("name")); + String name(iter->get_attr("name")); if (name.size()) { Package& pack = handler.packages()[name]; pack.name = name; result_list.push_back(pack.xml()); } } else if (iter->tag() == "set") { - string name(iter->get_attr("name")); + String name(iter->get_attr("name")); if (name.size()) { PackageSet& set = handler.sets()[name]; set.name = name; @@ -247,6 +247,6 @@ Variable var("result", result_list); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } --- conga/ricci/modules/rpm/main.cpp 2006/04/07 16:42:40 1.2 +++ conga/ricci/modules/rpm/main.cpp 2006/08/10 22:53:08 1.3 @@ -32,7 +32,7 @@ try { RpmModule m; return stdin_out_module_driver(m); - } catch (string e) { + } catch (String e) { cerr << e << endl; return 1; } --- conga/ricci/modules/service/ServiceManager.cpp 2006/04/12 15:47:09 1.2 +++ conga/ricci/modules/service/ServiceManager.cpp 2006/08/10 22:53:09 1.3 @@ -36,7 +36,7 @@ #define INITD_DIR_PATH "/etc/init.d/" -#define DESC_SIG string("# description:") +#define DESC_SIG String("# description:") @@ -44,12 +44,12 @@ Service::Service() {} -Service::Service(const string& name, bool enabled) : - _name(counting_auto_ptr(new string(name))), +Service::Service(const String& name, bool enabled) : + _name(counting_auto_ptr(new String(name))), _enabled(counting_auto_ptr(new bool(enabled))) { if (_name->empty()) - throw string("noname service???"); + throw String("noname service???"); } Service::~Service() @@ -60,7 +60,7 @@ Service::xml(bool descr) const { if (!_name.get()) - throw string("internal: service not initialized"); + throw String("internal: service not initialized"); XMLObject xml("service"); xml.set_attr("name", name()); @@ -70,11 +70,11 @@ return xml; } -string +String Service::name() const { if (!_name.get()) - throw string("internal: service not initialized"); + throw String("internal: service not initialized"); return *_name; } @@ -82,7 +82,7 @@ Service::enabled() const { if (!_enabled.get()) - throw string("internal: service not initialized"); + throw String("internal: service not initialized"); return *_enabled; } @@ -94,11 +94,11 @@ return *_running; } -string +String Service::description() const { if (!_descr.get()) { - string path(INITD_DIR_PATH); + String path(INITD_DIR_PATH); path += name(); char* buff = 0; @@ -109,15 +109,15 @@ is.seekg(0, ios::beg); buff = new char[length]; is.read(buff, length); - string initd(buff, length); + String initd(buff, length); - list desc_lines; + list desc_lines; - vector lines = utils::split(initd, "\n"); - for (vector::const_iterator iter = lines.begin(); + vector lines = utils::split(initd, "\n"); + for (vector::const_iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line(*iter); + String line(*iter); if (line.empty()) continue; if (line.find(DESC_SIG) != 0) @@ -132,11 +132,11 @@ break; } - string desc; - for (list::const_iterator l_iter = desc_lines.begin(); + String desc; + for (list::const_iterator l_iter = desc_lines.begin(); l_iter != desc_lines.end(); l_iter++) { - string s = utils::rstrip(*l_iter, "\\"); + String s = utils::rstrip(*l_iter, "\\"); s = utils::lstrip(s, DESC_SIG); s = utils::lstrip(s, "#"); s = utils::lstrip(s); @@ -144,11 +144,11 @@ } // remove " from desc - string::size_type i; + String::size_type i; while ((i = desc.find('"')) != desc.npos) desc[i] = '\''; - _descr = counting_auto_ptr(new string(desc)); + _descr = counting_auto_ptr(new String(desc)); delete [] buff; } catch ( ... ) { @@ -194,60 +194,60 @@ } void -Service::enable_service(const std::string& name, bool on) +Service::enable_service(const String& name, bool on) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back(name); if (on) args.push_back("on"); else args.push_back("off"); if (utils::execute(CHKCONFIG_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("chkconfig failed for service ") + name; + throw String("chkconfig failed for service ") + name; } bool -Service::service_running(const std::string& name) +Service::service_running(const String& name) { - string path(INITD_DIR_PATH); + String path(INITD_DIR_PATH); path += name; - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("status"); if (utils::execute(path, args, out, err, status, false) != 0) - throw string("execute failed"); + throw String("execute failed"); return status == 0; } void -Service::run_service(const std::string& name, bool on) +Service::run_service(const String& name, bool on) { - string path(INITD_DIR_PATH); + String path(INITD_DIR_PATH); path += name; - string out, err; + String out, err; int status; - vector args; + vector args; if (on) args.push_back("start"); else args.push_back("stop"); if (utils::execute(path, args, out, err, status, false) != 0) - throw string("execute failed"); + throw String("execute failed"); if (status) { bool running = service_running(name); if (on) { if (!running) - throw string("service ") + name + " " + string(on?"start":"stop") + " failed"; + throw String("service ") + name + " " + String(on?"start":"stop") + " failed"; } else { if (running) - throw string("service ") + name + " " + string(on?"start":"stop") + " failed"; + throw String("service ") + name + " " + String(on?"start":"stop") + " failed"; } } } @@ -263,13 +263,13 @@ ServiceSet::ServiceSet() {} -ServiceSet::ServiceSet(const string& name, - const string& description) : - _name(counting_auto_ptr(new string(name))), - _descr(counting_auto_ptr(new string(description))) +ServiceSet::ServiceSet(const String& name, + const String& description) : + _name(counting_auto_ptr(new String(name))), + _descr(counting_auto_ptr(new String(description))) { if (_name->empty()) - throw string("noname ServiceSet???"); + throw String("noname ServiceSet???"); } ServiceSet::~ServiceSet() @@ -287,11 +287,11 @@ return xml; } -string +String ServiceSet::name() const { if (!_name.get() || servs.empty()) - throw string("internal: ServiceSet not initialized"); + throw String("internal: ServiceSet not initialized"); return *_name; } @@ -319,7 +319,7 @@ return true; } -string +String ServiceSet::description() const { name(); @@ -335,8 +335,8 @@ iter != servs.end(); iter++) iter->enable(); - } catch (string e) { - throw string("service set '") + name() + "' failed to enable"; + } catch (String e) { + throw String("service set '") + name() + "' failed to enable"; } } @@ -349,8 +349,8 @@ iter != servs.end(); iter++) iter->disable(); - } catch (string e) { - throw string("service set '") + name() + "' failed to disable"; + } catch (String e) { + throw String("service set '") + name() + "' failed to disable"; } } @@ -363,8 +363,8 @@ iter != servs.end(); iter++) iter->start(); - } catch (string e) { - throw string("service set '") + name() + "' failed to start"; + } catch (String e) { + throw String("service set '") + name() + "' failed to start"; } } @@ -377,8 +377,8 @@ iter != servs.rend(); iter++) iter->stop(); - } catch (string e) { - throw string("service set '") + name() + "' failed to stop"; + } catch (String e) { + throw String("service set '") + name() + "' failed to stop"; } } @@ -389,27 +389,27 @@ ServiceManager::ServiceManager() { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("--list"); if (utils::execute(CHKCONFIG_PATH, args, out, err, status, true)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("chkconfig failed"); - vector lines = utils::split(out, "\n"); - for (vector::const_iterator iter = lines.begin(); + throw String("chkconfig failed"); + vector lines = utils::split(out, "\n"); + for (vector::const_iterator iter = lines.begin(); iter != lines.end(); iter++) { - vector words = utils::split(*iter); + vector words = utils::split(*iter); if (words.size() != 8) continue; - string name = words[0]; + String name = words[0]; bool enabled = false; - for (vector::size_type i=2; + for (vector::size_type i=2; i < words.size() - 1; i++) - if (words[i].find("on") != string::npos) + if (words[i].find("on") != String::npos) enabled = true; _servs[name] = Service(name, enabled); } @@ -421,16 +421,16 @@ {} -map +map ServiceManager::generate_sets() { // TODO: set descriptions - map sets; + map sets; - list servs; - string name = "Cluster Base"; - string descr = "Cluster infrastructure: ccs, cman, fence"; + list servs; + String name = "Cluster Base"; + String descr = "Cluster infrastructure: ccs, cman, fence"; ServiceSet s(name, descr); servs.push_back("ccsd"); servs.push_back("cman"); @@ -484,9 +484,9 @@ bool ServiceManager::populate_set(ServiceSet& ss, - std::list servs) + std::list servs) { - for (list::iterator n_iter = servs.begin(); + for (list::iterator n_iter = servs.begin(); n_iter != servs.end(); n_iter++) { if (_servs.find(*n_iter) == _servs.end()) @@ -499,112 +499,112 @@ void -ServiceManager::enable(const std::list& services, - const std::list& sets) +ServiceManager::enable(const std::list& services, + const std::list& sets) { // check - for (list::const_iterator iter = services.begin(); + for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) if (_servs.find(*iter) == _servs.end()) - throw string("no such service: ") + *iter; - for (list::const_iterator iter = sets.begin(); + throw String("no such service: ") + *iter; + for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) if (_sets.find(*iter) == _sets.end()) - throw string("no such service set: ") + *iter; + throw String("no such service set: ") + *iter; // apply - for (list::const_iterator iter = services.begin(); + for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) _servs[*iter].enable(); - for (list::const_iterator iter = sets.begin(); + for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) _sets[*iter].enable(); } void -ServiceManager::disable(const std::list& services, - const std::list& sets) +ServiceManager::disable(const std::list& services, + const std::list& sets) { // check - for (list::const_iterator iter = services.begin(); + for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) if (_servs.find(*iter) == _servs.end()) - throw string("no such service: ") + *iter; - for (list::const_iterator iter = sets.begin(); + throw String("no such service: ") + *iter; + for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) if (_sets.find(*iter) == _sets.end()) - throw string("no such service set: ") + *iter; + throw String("no such service set: ") + *iter; // apply - for (list::const_iterator iter = services.begin(); + for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) _servs[*iter].disable(); - for (list::const_iterator iter = sets.begin(); + for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) _sets[*iter].disable(); } void -ServiceManager::start(const std::list& services, - const std::list& sets) +ServiceManager::start(const std::list& services, + const std::list& sets) { // check - for (list::const_iterator iter = services.begin(); + for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) if (_servs.find(*iter) == _servs.end()) - throw string("no such service: ") + *iter; - for (list::const_iterator iter = sets.begin(); + throw String("no such service: ") + *iter; + for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) if (_sets.find(*iter) == _sets.end()) - throw string("no such service set: ") + *iter; + throw String("no such service set: ") + *iter; // apply - for (list::const_iterator iter = services.begin(); + for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) _servs[*iter].start(); - for (list::const_iterator iter = sets.begin(); + for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) _sets[*iter].start(); } void -ServiceManager::stop(const std::list& services, - const std::list& sets) +ServiceManager::stop(const std::list& services, + const std::list& sets) { // check - for (list::const_iterator iter = services.begin(); + for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) if (_servs.find(*iter) == _servs.end()) - throw string("no such service: ") + *iter; - for (list::const_iterator iter = sets.begin(); + throw String("no such service: ") + *iter; + for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) if (_sets.find(*iter) == _sets.end()) - throw string("no such service set: ") + *iter; + throw String("no such service set: ") + *iter; // apply - for (list::const_iterator iter = services.begin(); + for (list::const_iterator iter = services.begin(); iter != services.end(); iter++) _servs[*iter].stop(); - for (list::const_iterator iter = sets.begin(); + for (list::const_iterator iter = sets.begin(); iter != sets.end(); iter++) _sets[*iter].stop(); @@ -617,33 +617,33 @@ services.clear(); sets.clear(); - for (map::const_iterator iter = _servs.begin(); + for (map::const_iterator iter = _servs.begin(); iter != _servs.end(); iter++) services.push_back(iter->second); - for (map::const_iterator iter = _sets.begin(); + for (map::const_iterator iter = _sets.begin(); iter != _sets.end(); iter++) sets.push_back(iter->second); } void -ServiceManager::query(const std::list& serv_names, - const std::list& set_names, +ServiceManager::query(const std::list& serv_names, + const std::list& set_names, std::list& services, std::list& sets) { services.clear(); sets.clear(); - for (list::const_iterator iter = serv_names.begin(); + for (list::const_iterator iter = serv_names.begin(); iter != serv_names.end(); iter++) if (_servs.find(*iter) != _servs.end()) services.push_back(_servs[*iter]); - for (list::const_iterator iter = set_names.begin(); + for (list::const_iterator iter = set_names.begin(); iter != set_names.end(); iter++) if (_sets.find(*iter) != _sets.end()) --- conga/ricci/modules/service/ServiceManager.h 2006/04/04 19:42:51 1.1 +++ conga/ricci/modules/service/ServiceManager.h 2006/08/10 22:53:09 1.2 @@ -28,7 +28,7 @@ #include "counting_auto_ptr.h" #include -#include +#include "String.h" #include @@ -41,10 +41,10 @@ Service(); virtual ~Service(); - std::string name() const; + String name() const; bool enabled() const; bool running() const; - std::string description() const; + String description() const; void enable(); void disable(); @@ -54,16 +54,16 @@ XMLObject xml(bool descriptions) const; private: - Service(const std::string& name, bool enabled); + Service(const String& name, bool enabled); - mutable counting_auto_ptr _name; - mutable counting_auto_ptr _descr; + mutable counting_auto_ptr _name; + mutable counting_auto_ptr _descr; mutable counting_auto_ptr _enabled; mutable counting_auto_ptr _running; - static void enable_service(const std::string& name, bool on); - static bool service_running(const std::string& name); - static void run_service(const std::string& name, bool on); + static void enable_service(const String& name, bool on); + static bool service_running(const String& name); + static void run_service(const String& name, bool on); friend class ServiceManager; @@ -73,13 +73,13 @@ { public: ServiceSet(); - ServiceSet(const std::string& name, const std::string& description); + ServiceSet(const String& name, const String& description); virtual ~ServiceSet(); - std::string name() const; + String name() const; bool enabled() const; bool running() const; - std::string description() const; + String description() const; void enable(); void disable(); @@ -91,8 +91,8 @@ XMLObject xml(bool descriptions) const; private: - mutable counting_auto_ptr _name; - mutable counting_auto_ptr _descr; + mutable counting_auto_ptr _name; + mutable counting_auto_ptr _descr; }; @@ -103,27 +103,27 @@ ServiceManager(); virtual ~ServiceManager(); - void enable(const std::list& services, const std::list& sets); - void disable(const std::list& services, const std::list& sets); + void enable(const std::list& services, const std::list& sets); + void disable(const std::list& services, const std::list& sets); - void start(const std::list& services, const std::list& sets); - void stop(const std::list& services, const std::list& sets); + void start(const std::list& services, const std::list& sets); + void stop(const std::list& services, const std::list& sets); void lists(std::list& services, std::list& sets); - void query(const std::list& serv_names, - const std::list& set_names, + void query(const std::list& serv_names, + const std::list& set_names, std::list& services, std::list& sets); private: - std::map _servs; - std::map _sets; + std::map _servs; + std::map _sets; - std::map generate_sets(); + std::map generate_sets(); - bool populate_set(ServiceSet& ss, std::list servs); + bool populate_set(ServiceSet& ss, std::list servs); }; --- conga/ricci/modules/service/ServiceModule.cpp 2006/04/12 15:47:09 1.2 +++ conga/ricci/modules/service/ServiceModule.cpp 2006/08/10 22:53:09 1.3 @@ -73,11 +73,11 @@ if (iter == args.end()) throw APIerror("missing services variable"); serv_list = iter->second.get_list_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } - list services, sets; + list services, sets; for (list::const_iterator iter = serv_list.begin(); iter != serv_list.end(); iter++) { @@ -101,11 +101,11 @@ if (iter == args.end()) throw APIerror("missing services variable"); serv_list = iter->second.get_list_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } - list services, sets; + list services, sets; for (list::const_iterator iter = serv_list.begin(); iter != serv_list.end(); iter++) { @@ -129,11 +129,11 @@ if (iter == args.end()) throw APIerror("missing services variable"); serv_list = iter->second.get_list_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } - list services, sets; + list services, sets; for (list::const_iterator iter = serv_list.begin(); iter != serv_list.end(); iter++) { @@ -157,11 +157,11 @@ if (iter == args.end()) throw APIerror("missing services variable"); serv_list = iter->second.get_list_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } - list services, sets; + list services, sets; for (list::const_iterator iter = serv_list.begin(); iter != serv_list.end(); iter++) { @@ -185,7 +185,7 @@ VarMap::const_iterator iter = args.find("description"); if (iter != args.end()) descr = iter->second.get_bool(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -209,7 +209,7 @@ Variable var("services", xml_list); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -228,13 +228,13 @@ iter = args.find("description"); if (iter != args.end()) descr = iter->second.get_bool(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } // command - list serv_names, set_names; + list serv_names, set_names; for (list::const_iterator iter = search_list.begin(); iter != search_list.end(); iter++) { @@ -266,6 +266,6 @@ Variable var("result", result_list); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } --- conga/ricci/modules/service/main.cpp 2006/04/07 16:42:40 1.2 +++ conga/ricci/modules/service/main.cpp 2006/08/10 22:53:09 1.3 @@ -32,7 +32,7 @@ try { ServiceModule m; return stdin_out_module_driver(m); - } catch (string e) { + } catch (String e) { cerr << e << endl; return 1; } --- conga/ricci/modules/storage/BD.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/BD.cpp 2006/08/10 22:53:09 1.3 @@ -41,10 +41,10 @@ // ##### BD ##### -BD::BD(const std::string& mapper_type, - const std::string& mapper_id, - const std::string& bd_type, - const std::string& path, +BD::BD(const String& mapper_type, + const String& mapper_id, + const String& bd_type, + const String& path, bool check_path) : content(ContentFactory().probe(path)), _mapper_type(mapper_type), @@ -54,27 +54,27 @@ { if (check_path) { // if (access(path.c_str(), F_OK) != 0) - // throw string("file non-existant"); + // throw String("file non-existant"); // size (can be overwritten by descendants) - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("--getss"); args.push_back("--getsize"); args.push_back(path); if (utils::execute("/sbin/blockdev", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("blockdev failed"); + throw String("blockdev failed"); out = utils::strip(out); - vector lines = utils::split(out, "\n"); + vector lines = utils::split(out, "\n"); if (lines.size() != 2) - throw string("invalid output from blockdev"); + throw String("invalid output from blockdev"); long long size = utils::to_long(utils::strip(lines[0])); size *= utils::to_long(utils::strip(lines[1])); if (size == 0) - throw string("invalid size"); + throw String("invalid size"); else _props.set(Variable("size", size)); } @@ -88,7 +88,7 @@ {} -string +String BD::path() const { return _props.get("path").get_string(); @@ -100,7 +100,7 @@ return _props.get("size").get_int(); } -string +String BD::state_ind() const { XMLObject t; @@ -110,13 +110,13 @@ return utils::hash_str(generateXML(t) + path() + _mapper_id); } -string +String BD::mapper_id() const { return _mapper_id; } -string +String BD::mapper_type() const { return _mapper_type; @@ -224,10 +224,10 @@ // ##### BDTemplate ##### -BDTemplate::BDTemplate(const std::string& mapper_type, - const std::string& mapper_id, - const std::string& mapper_state_ind, - const std::string& bd_type) : +BDTemplate::BDTemplate(const String& mapper_type, + const String& mapper_id, + const String& mapper_state_ind, + const String& bd_type) : mapper_type(mapper_type), mapper_id(mapper_id), mapper_state_ind(mapper_state_ind), @@ -240,7 +240,7 @@ BDTemplate::BDTemplate(const XMLObject& xml) { if (xml.tag() != BD_TEMPLATE_TYPE_TAG) - throw string("not BD template"); + throw String("not BD template"); mapper_type = xml.get_attr("mapper_type"); mapper_id = xml.get_attr("mapper_id"); @@ -255,7 +255,7 @@ else if (mapper_type == MAPPER_PT_TYPE) bd_type = BD_PART_TYPE; else - throw string("BDTemplate(): not implemented"); + throw String("BDTemplate(): not implemented"); XMLObject content_xml; const list& kids = xml.children(); @@ -328,13 +328,13 @@ BDParsed::BDParsed(const XMLObject& xml) { if (xml.tag() != BD_TYPE_TAG) - throw string("not BD"); + throw String("not BD"); path = xml.get_attr("path"); state_ind = xml.get_attr("state_ind"); if (path.empty() || state_ind.empty()) - throw string("BDParsed missing identification"); + throw String("BDParsed missing identification"); // get BD try { @@ -362,7 +362,7 @@ throw MidAir(); bd->_props.validate(props);; if (!content.get()) - throw string("missing content tag"); + throw String("missing content tag"); // content validated self --- conga/ricci/modules/storage/BD.h 2006/07/12 19:47:50 1.3 +++ conga/ricci/modules/storage/BD.h 2006/08/10 22:53:09 1.4 @@ -24,7 +24,7 @@ #ifndef bd_h #define bd_h -#include +#include "String.h" #include "defines.h" #include "Content.h" @@ -46,10 +46,10 @@ Props props; // MapperType mapper_type; - // std::string mapper_id; + // String mapper_id; // BDType bd_type; - std::string path; - std::string state_ind; + String path; + String state_ind; counting_auto_ptr bd; @@ -63,11 +63,11 @@ public: virtual ~BD(); - std::string path() const; - virtual std::string state_ind() const; + String path() const; + virtual String state_ind() const; virtual long long size() const; - std::string mapper_id() const; - std::string mapper_type() const; + String mapper_id() const; + String mapper_type() const; XMLObject xml() const; @@ -85,16 +85,16 @@ protected: - BD(const std::string& mapper_type, - const std::string& mapper_id, - const std::string& bd_type, - const std::string& path, + BD(const String& mapper_type, + const String& mapper_id, + const String& bd_type, + const String& path, bool check_path = true); - std::string _mapper_type; - std::string _mapper_id; - std::string _bd_type; - std::string _path; + String _mapper_type; + String _mapper_id; + String _bd_type; + String _path; virtual void shrink(unsigned long long new_size, @@ -102,8 +102,8 @@ virtual void expand(unsigned long long new_size, const Props& new_props) = 0; - virtual std::string apply_props_before_resize(const Props& new_props) = 0; // return path - virtual std::string apply_props_after_resize(const Props& new_props) = 0; // return path + virtual String apply_props_before_resize(const Props& new_props) = 0; // return path + virtual String apply_props_after_resize(const Props& new_props) = 0; // return path @@ -122,10 +122,10 @@ - std::string mapper_type; - std::string mapper_id; - std::string mapper_state_ind; - std::string bd_type; + String mapper_type; + String mapper_id; + String mapper_state_ind; + String bd_type; Props props; @@ -134,10 +134,10 @@ counting_auto_ptr content_parsed; // valid only if constructed from XML protected: - BDTemplate(const std::string& mapper_type, - const std::string& mapper_id, - const std::string& mapper_state_ind, - const std::string& bd_type); + BDTemplate(const String& mapper_type, + const String& mapper_id, + const String& mapper_state_ind, + const String& bd_type); private: --- conga/ricci/modules/storage/BDFactory.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/BDFactory.cpp 2006/08/10 22:53:09 1.3 @@ -37,7 +37,7 @@ counting_auto_ptr -BDFactory::get_bd(const std::string& path) +BDFactory::get_bd(const String& path) { try { return counting_auto_ptr(new LV(path)); @@ -62,7 +62,7 @@ return create_LV(bd_temp); if (bd_temp.bd_type == BD_PART_TYPE) return create_partition(bd_temp); - throw string("no such mapper type"); + throw String("no such mapper type"); } @@ -82,7 +82,7 @@ if (old_bd->state_ind() != parsed_bd.state_ind) throw MidAir(); if (!old_bd->removable()) - throw string("invalid call: bd not removable"); + throw String("invalid call: bd not removable"); old_bd->remove(); return MapperFactory::get_mapper(old_bd->mapper_type(), --- conga/ricci/modules/storage/BDFactory.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/BDFactory.h 2006/08/10 22:53:09 1.3 @@ -28,7 +28,7 @@ #include "BD.h" #include "Mapper.h" -#include +#include "String.h" class BDFactory @@ -37,7 +37,7 @@ static counting_auto_ptr create_bd(const BDTemplate& bd_temp); - static counting_auto_ptr get_bd(const std::string& path); + static counting_auto_ptr get_bd(const String& path); static counting_auto_ptr modify_bd(const BDParsed& bd); --- conga/ricci/modules/storage/ClusterNotQuorateError.h 2006/07/12 16:52:56 1.1 +++ conga/ricci/modules/storage/ClusterNotQuorateError.h 2006/08/10 22:53:09 1.2 @@ -31,7 +31,7 @@ { public: ClusterNotQuorateError() - : Except(5, std::string("Quorum required, but cluster not quorate")) {} + : Except(5, String("Quorum required, but cluster not quorate")) {} virtual ~ClusterNotQuorateError() {} --- conga/ricci/modules/storage/ClvmdError.h 2006/06/28 20:09:08 1.1 +++ conga/ricci/modules/storage/ClvmdError.h 2006/08/10 22:53:09 1.2 @@ -31,7 +31,7 @@ { public: ClvmdError() - : Except(4, std::string("clvmd required, but unable to start. Start cluster infrastructure.")) {} + : Except(4, String("clvmd required, but unable to start. Start cluster infrastructure.")) {} virtual ~ClvmdError() {} --- conga/ricci/modules/storage/Content.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/Content.cpp 2006/08/10 22:53:09 1.3 @@ -33,7 +33,7 @@ // ### class Content ### -Content::Content(const std::string& type, const std::string& path) : +Content::Content(const String& type, const String& path) : type(type) { _props.set(Variable("path", path)); @@ -43,13 +43,13 @@ {} -std::string +String Content::path() const { return _props.get("path").get_string(); } -std::string +String Content::state_ind() const { XMLObject xml; @@ -99,7 +99,7 @@ // ### class ContentTemplate ### -ContentTemplate::ContentTemplate(const std::string& type) : +ContentTemplate::ContentTemplate(const String& type) : type(type) { attrs["type"] = type; @@ -109,7 +109,7 @@ counting_auto_ptr& content) { if (xml.tag() != CONTENT_TEMPLATE_TYPE_TAG) - throw string("not Content template"); + throw String("not Content template"); attrs = xml.attrs(); @@ -150,7 +150,7 @@ XMLObject xml(CONTENT_TEMPLATE_TYPE_TAG); xml.set_attr("type", type); - for (map::const_iterator iter = attrs.begin(); + for (map::const_iterator iter = attrs.begin(); iter != attrs.end(); iter++) xml.set_attr(iter->first, iter->second); @@ -170,16 +170,16 @@ content(content) { if (xml.tag() != CONTENT_TYPE_TAG) - throw string("not Content") + xml.tag(); + throw String("not Content") + xml.tag(); if (!content.get()) - throw string("content null pointer!!!"); + throw String("content null pointer!!!"); const XMLObject& orig_xml = content->xml(); - for (std::map::const_iterator iter = orig_xml.attrs().begin(); + for (std::map::const_iterator iter = orig_xml.attrs().begin(); iter != orig_xml.attrs().end(); iter++) if (xml.get_attr(iter->first) != iter->second) - throw string("not a matching content"); + throw String("not a matching content"); for (list::const_iterator iter = xml.children().begin(); iter != xml.children().end(); @@ -192,7 +192,7 @@ // replacement if (iter->tag() == CONTENT_NEW_CONTENT_TAG) { if (iter->children().size() > 1) - throw string("invalid number of replacement contents"); + throw String("invalid number of replacement contents"); else if (iter->children().size() == 1) _replacement = counting_auto_ptr(new ContentTemplate(iter->children().front(), content)); --- conga/ricci/modules/storage/Content.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/Content.h 2006/08/10 22:53:09 1.3 @@ -54,12 +54,12 @@ public: virtual ~Content(); - std::string path() const; - std::string state_ind() const; + String path() const; + String state_ind() const; virtual XMLObject xml() const; - const std::string type; + const String type; Props _props; @@ -76,18 +76,18 @@ // modifying fcns - virtual void shrink(const std::string& path, + virtual void shrink(const String& path, unsigned long long new_size, const Props& new_props) = 0; - virtual void expand(const std::string& path, + virtual void expand(const String& path, unsigned long long new_size, const Props& new_props) = 0; - virtual void apply_props_before_resize(const std::string& path, + virtual void apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) = 0; - virtual void apply_props_after_resize(const std::string& path, + virtual void apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) = 0; @@ -97,7 +97,7 @@ protected: - Content(const std::string& type, const std::string& path); + Content(const String& type, const String& path); private: @@ -116,12 +116,12 @@ Props _props; - std::string type; + String type; - std::map attrs; // update if necessary + std::map attrs; // update if necessary protected: - ContentTemplate(const std::string& type); + ContentTemplate(const String& type); }; --- conga/ricci/modules/storage/ContentExtendedPartition.cpp 2006/03/10 17:50:11 1.1 +++ conga/ricci/modules/storage/ContentExtendedPartition.cpp 2006/08/10 22:53:09 1.2 @@ -28,7 +28,7 @@ using namespace std; -ContentExtendedPartition::ContentExtendedPartition(const std::string& path) : +ContentExtendedPartition::ContentExtendedPartition(const String& path) : ContentUnusable(path) {} --- conga/ricci/modules/storage/ContentExtendedPartition.h 2006/03/10 17:50:11 1.1 +++ conga/ricci/modules/storage/ContentExtendedPartition.h 2006/08/10 22:53:09 1.2 @@ -30,7 +30,7 @@ class ContentExtendedPartition : public ContentUnusable { public: - ContentExtendedPartition(const std::string& path); + ContentExtendedPartition(const String& path); virtual ~ContentExtendedPartition(); virtual bool removable() const; --- conga/ricci/modules/storage/ContentFS.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/ContentFS.cpp 2006/08/10 22:53:09 1.3 @@ -32,7 +32,7 @@ using namespace std; -ContentFS::ContentFS(const std::string& fs_name, const std::string& path) : +ContentFS::ContentFS(const String& fs_name, const String& path) : Content(CONTENT_FS_TYPE, path), _name(fs_name) { @@ -53,7 +53,7 @@ ContentFS::remove() { if (!this->removable()) - throw string("FS not removable"); + throw String("FS not removable"); FstabLocker lock; MountHandler mh; @@ -98,7 +98,7 @@ -ContentFSTemplate::ContentFSTemplate(const std::string& name) : +ContentFSTemplate::ContentFSTemplate(const String& name) : ContentTemplate(CONTENT_FS_TYPE), name(name) { --- conga/ricci/modules/storage/ContentFS.h 2006/07/12 18:27:26 1.4 +++ conga/ricci/modules/storage/ContentFS.h 2006/08/10 22:53:09 1.5 @@ -25,7 +25,7 @@ #define ContentFS_h #include "Content.h" -#include +#include "String.h" class ContentFS : public Content @@ -40,8 +40,8 @@ protected: - ContentFS(const std::string& name, const std::string& path); - std::string _name; + ContentFS(const String& name, const String& path); + String _name; @@ -54,8 +54,8 @@ virtual ~ContentFSTemplate(); protected: - ContentFSTemplate(const std::string& name); - std::string name; + ContentFSTemplate(const String& name); + String name; }; --- conga/ricci/modules/storage/ContentFactory.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/ContentFactory.cpp 2006/08/10 22:53:09 1.3 @@ -35,7 +35,7 @@ counting_auto_ptr -ContentFactory::probe(const std::string& path) +ContentFactory::probe(const String& path) { try { return counting_auto_ptr(new PV(path)); @@ -73,7 +73,7 @@ return probe(bd->path()); } } - throw string("creation of content ") + content->_replacement->type + + throw String("creation of content ") + content->_replacement->type + " not implemented"; } --- conga/ricci/modules/storage/ContentFactory.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/ContentFactory.h 2006/08/10 22:53:09 1.3 @@ -28,14 +28,14 @@ #include "BD.h" #include "counting_auto_ptr.h" -#include +#include "String.h" class ContentFactory { public: - counting_auto_ptr probe(const std::string& path); + counting_auto_ptr probe(const String& path); counting_auto_ptr create_content(const counting_auto_ptr& bd, --- conga/ricci/modules/storage/ContentNone.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/ContentNone.cpp 2006/08/10 22:53:09 1.3 @@ -33,7 +33,7 @@ using namespace std; -ContentNone::ContentNone(const std::string& path) : +ContentNone::ContentNone(const String& path) : Content(CONTENT_NONE_TYPE, path) { _props = Props(); @@ -59,26 +59,26 @@ } void -ContentNone::shrink(const std::string& path, +ContentNone::shrink(const String& path, unsigned long long new_size, const Props& new_props) {} void -ContentNone::expand(const std::string& path, +ContentNone::expand(const String& path, unsigned long long new_size, const Props& new_props) {} void -ContentNone::apply_props_before_resize(const std::string& path, +ContentNone::apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) {} void -ContentNone::apply_props_after_resize(const std::string& path, +ContentNone::apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) @@ -124,19 +124,19 @@ if (size > 2 * 1024 * 1024) size = 2 * 1024 * 1024; - vector args; - string out, err; + vector args; + String out, err; int status; args.push_back("if=/dev/zero"); - args.push_back(string("of=") + bd->path()); - args.push_back(string("bs=") + utils::to_string(size)); + args.push_back(String("of=") + bd->path()); + args.push_back(String("bs=") + utils::to_string(size)); args.push_back("count=1"); if (utils::execute("/bin/dd", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("dd failed: ") + out + " " + err + " " + utils::to_string(status); + throw String("dd failed: ") + out + " " + err + " " + utils::to_string(status); } --- conga/ricci/modules/storage/ContentNone.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/ContentNone.h 2006/08/10 22:53:09 1.3 @@ -27,7 +27,7 @@ #include "Content.h" #include "counting_auto_ptr.h" #include "BD.h" -#include +#include "String.h" #include @@ -38,7 +38,7 @@ class ContentNone : public Content { public: - ContentNone(const std::string& path); + ContentNone(const String& path); virtual ~ContentNone(); virtual XMLObject xml() const; @@ -47,17 +47,17 @@ virtual bool expandable(long long& max_size) const; virtual bool shrinkable(long long& min_size) const; - virtual void shrink(const std::string& path, + virtual void shrink(const String& path, unsigned long long new_size, const Props& new_props); - virtual void expand(const std::string& path, + virtual void expand(const String& path, unsigned long long new_size, const Props& new_props); - virtual void apply_props_before_resize(const std::string& path, + virtual void apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); - virtual void apply_props_after_resize(const std::string& path, + virtual void apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); --- conga/ricci/modules/storage/ContentUnusable.cpp 2006/03/10 17:50:11 1.1 +++ conga/ricci/modules/storage/ContentUnusable.cpp 2006/08/10 22:53:09 1.2 @@ -28,7 +28,7 @@ using namespace std; -ContentUnusable::ContentUnusable(const std::string& path) : +ContentUnusable::ContentUnusable(const String& path) : Content(CONTENT_UNUSABLE_TYPE, path) { _props = Props(); @@ -51,30 +51,30 @@ } void -ContentUnusable::shrink(const std::string& path, +ContentUnusable::shrink(const String& path, unsigned long long new_size, const Props& new_props) { - throw string("ContentUnusable is not shrinkable"); + throw String("ContentUnusable is not shrinkable"); } void -ContentUnusable::expand(const std::string& path, +ContentUnusable::expand(const String& path, unsigned long long new_size, const Props& new_props) { - throw string("ContentUnusable is not expandable"); + throw String("ContentUnusable is not expandable"); } void -ContentUnusable::apply_props_before_resize(const std::string& path, +ContentUnusable::apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) {} void -ContentUnusable::apply_props_after_resize(const std::string& path, +ContentUnusable::apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) @@ -89,7 +89,7 @@ void ContentUnusable::remove() { - throw string("ContentUnusable is not removable"); + throw String("ContentUnusable is not removable"); } --- conga/ricci/modules/storage/ContentUnusable.h 2006/03/10 17:50:11 1.1 +++ conga/ricci/modules/storage/ContentUnusable.h 2006/08/10 22:53:09 1.2 @@ -30,7 +30,7 @@ class ContentUnusable : public Content { public: - ContentUnusable(const std::string& path); + ContentUnusable(const String& path); virtual ~ContentUnusable(); virtual XMLObject xml() const; @@ -39,17 +39,17 @@ virtual bool expandable(long long& max_size) const; virtual bool shrinkable(long long& min_size) const; - virtual void shrink(const std::string& path, + virtual void shrink(const String& path, unsigned long long new_size, const Props& new_props); - virtual void expand(const std::string& path, + virtual void expand(const String& path, unsigned long long new_size, const Props& new_props); - virtual void apply_props_before_resize(const std::string& path, + virtual void apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); - virtual void apply_props_after_resize(const std::string& path, + virtual void apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); --- conga/ricci/modules/storage/ExtendedFS.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/ExtendedFS.cpp 2006/08/10 22:53:09 1.3 @@ -38,39 +38,39 @@ -ExtendedFS::ExtendedFS(const std::string& path) : +ExtendedFS::ExtendedFS(const String& path) : ContentFS("extended_fs", path), _journaled(false) { - vector args; + vector args; args.push_back("-s"); args.push_back("-L"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute("/usr/bin/file", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("file failed"); + throw String("file failed"); if (out.find("ext3") == out.npos && out.find("ext2") == out.npos) - throw string("not extended_fs"); + throw String("not extended_fs"); // dumpe2fs args.clear(); args.push_back("-h"); args.push_back(path); if (utils::execute("/sbin/dumpe2fs", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("dumpe2fs failed"); - vector lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + throw String("dumpe2fs failed"); + vector lines = utils::split(out, "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string& line = *iter; - vector words = utils::split(utils::strip(line)); + String& line = *iter; + vector words = utils::split(utils::strip(line)); if (words.size() < 3) continue; @@ -92,17 +92,17 @@ else if (words[0] == "Filesystem" && words[1] == "state:") _props.set(Variable("state", words[2])); else if (words[0] == "Filesystem" && words[1] == "UUID:") { - string uuid(words[2]); + String uuid(words[2]); if (uuid == "") uuid.clear(); _props.set(Variable("uuid", uuid)); } } else if (words.size() == 4) { if (words[0] == "Filesystem" && words[1] == "volume" && words[2] == "name:") { - string label = words[3]; + String label = words[3]; if (label == "") label.clear(); - // _props.set(Variable("label", label, 0, 16, illegal_label_chars, list())); + // _props.set(Variable("label", label, 0, 16, illegal_label_chars, list())); _props.set(Variable("label", label)); } } @@ -112,14 +112,14 @@ MountHandler mh; pair maj_min = mh.maj_min(path); list mounts = mh.mounts(maj_min); - string mountpoint; + String mountpoint; if (mounts.size()) mountpoint = mounts.front().mountpoint; - list ill_mnts = mh.used_dirs(); + list ill_mnts = mh.used_dirs(); ill_mnts.remove(mountpoint); // fstab list fstabs = mh.fstabs(maj_min); - string fstabpoint; + String fstabpoint; if (fstabs.size()) fstabpoint = fstabs.front().mountpoint; ill_mnts.remove(fstabpoint); @@ -160,19 +160,19 @@ } void -ExtendedFS::expand(const std::string& path, +ExtendedFS::expand(const String& path, unsigned long long new_size, const Props& new_props) { - vector args; + vector args; args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute("/usr/sbin/ext2online", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("ext2online failed"); + throw String("ext2online failed"); } bool @@ -182,13 +182,13 @@ } void -ExtendedFS::shrink(const std::string& path, +ExtendedFS::shrink(const String& path, unsigned long long new_size, const Props& new_props) {} void -ExtendedFS::apply_props_before_resize(const std::string& path, +ExtendedFS::apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) @@ -203,8 +203,8 @@ bool index_old = _props.get("dir_index").get_bool(); bool index_new = new_props.get("dir_index").get_bool(); if (index_old != index_new) { - vector args; - string out, err, bin = "/sbin/tune2fs"; + vector args; + String out, err, bin = "/sbin/tune2fs"; int status; if (!index_old && index_new) { args.push_back("-O"); @@ -215,7 +215,7 @@ } args.push_back(path); if (utils::execute(bin, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status) throw bin + " failed"; } @@ -224,45 +224,45 @@ // label /* - string old_label = _props.get("label").get_string(); - string new_label = new_props.get("label").get_string(); + String old_label = _props.get("label").get_string(); + String new_label = new_props.get("label").get_string(); if (old_label != new_label) { FstabLocker lock; MountHandler mh; list l = mh.fstabs(mh.maj_min(path)); - vector args; + vector args; args.push_back("-L"); args.push_back(new_label); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute("/sbin/tune2fs", args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("tune2fs failed"); + throw String("tune2fs failed"); args.clear(); args.push_back("1"); if (utils::execute("/bin/sleep", args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("sleep failed"); + throw String("sleep failed"); for (list::const_iterator iter = l.begin(); iter != l.end(); iter++) - if (iter->devname == (string("LABEL=") + old_label)) { + if (iter->devname == (String("LABEL=") + old_label)) { mh.fstab_remove(iter->devname, iter->mountpoint); - mh.fstab_add(string("LABEL=") + new_label, iter->mountpoint, "ext3"); + mh.fstab_add(String("LABEL=") + new_label, iter->mountpoint, "ext3"); } } */ } void -ExtendedFS::enable_journal(const string& path) +ExtendedFS::enable_journal(const String& path) { MountHandler mh; FstabLocker lock; @@ -282,13 +282,13 @@ } // add journal - vector args; - string out, err, bin = "/sbin/tune2fs"; + vector args; + String out, err, bin = "/sbin/tune2fs"; int status; args.push_back("-j"); args.push_back(path); if (utils::execute(bin, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status) throw bin + " failed"; } catch ( ... ) { @@ -314,11 +314,11 @@ iter != mounts.end(); iter++) if (!mh.mount(iter->devname, iter->mountpoint, "ext3")) - throw string("mount failed"); + throw String("mount failed"); } void -ExtendedFS::apply_props_after_resize(const std::string& path, +ExtendedFS::apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) @@ -326,8 +326,8 @@ FstabLocker l; // mountpoint - string mnt_curr = _props.get("mountpoint").get_string(); - string mnt_new = new_props.get("mountpoint").get_string(); + String mnt_curr = _props.get("mountpoint").get_string(); + String mnt_new = new_props.get("mountpoint").get_string(); if (mnt_curr != mnt_new) { MountHandler mh; if (mnt_curr.size()) @@ -335,7 +335,7 @@ throw UMountError(mnt_curr); if (mnt_new.size()) if (!mh.mount(path, mnt_new, "ext3")) - throw string("mount failed"); + throw String("mount failed"); } // fstab mountpoint @@ -367,18 +367,18 @@ void -create_extended_fs(const std::string& path, +create_extended_fs(const String& path, const counting_auto_ptr& templ) { - string label = templ->_props.get("label").get_string(); - string bs = utils::to_string(templ->_props.get("block_size").get_int()); - string mountpoint = templ->_props.get("mountpoint").get_string(); + String label = templ->_props.get("label").get_string(); + String bs = utils::to_string(templ->_props.get("block_size").get_int()); + String mountpoint = templ->_props.get("mountpoint").get_string(); bool mount = templ->_props.get("mount").get_bool(); bool fstab = templ->_props.get("fstab").get_bool(); bool dir_index = templ->_props.get("dir_index").get_bool(); bool has_journal = templ->_props.get("has_journal").get_bool(); - vector args; + vector args; if (!label.empty()) { args.push_back("-L"); args.push_back(label); @@ -395,21 +395,21 @@ args.push_back("-j"); args.push_back(path); - string out, err, bin("/sbin/mke2fs"); + String out, err, bin("/sbin/mke2fs"); int status; if (utils::execute(bin, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) throw bin + " failed"; - string fstype = (has_journal) ? "ext3" : "ext2"; + String fstype = (has_journal) ? "ext3" : "ext2"; if (mountpoint.size()) { if (mount) MountHandler().mount(path, mountpoint, fstype); if (fstab) - MountHandler().fstab_add(label.empty() ? path : string("LABEL=") + label, + MountHandler().fstab_add(label.empty() ? path : String("LABEL=") + label, mountpoint, fstype); } @@ -419,7 +419,7 @@ ContentFSTemplate("extended_fs") { // label - _props.set(Variable("label", "", 0, 16, illegal_label_chars, list())); + _props.set(Variable("label", "", 0, 16, illegal_label_chars, list())); // dir_index _props.set(Variable("dir_index", true, true)); @@ -428,7 +428,7 @@ _props.set(Variable("has_journal", true, true)); // mountpoint - list illegal_mps = MountHandler().used_dirs(); + list illegal_mps = MountHandler().used_dirs(); _props.set(Variable("mountpoint", "", 0, 128, ";? *!", illegal_mps)); _props.set(Variable("fstab", false, true)); _props.set(Variable("mount", false, true)); --- conga/ricci/modules/storage/ExtendedFS.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/ExtendedFS.h 2006/08/10 22:53:09 1.3 @@ -25,34 +25,34 @@ #define ExtendedFS_h #include "ContentFS.h" -#include +#include "String.h" -void create_extended_fs(const std::string& path, +void create_extended_fs(const String& path, const counting_auto_ptr& templ); class ExtendedFS : public ContentFS { public: - ExtendedFS(const std::string& path); + ExtendedFS(const String& path); virtual ~ExtendedFS(); virtual bool expandable(long long& max_size) const; virtual bool shrinkable(long long& min_size) const; - virtual void shrink(const std::string& path, + virtual void shrink(const String& path, unsigned long long new_size, const Props& new_props); - virtual void expand(const std::string& path, + virtual void expand(const String& path, unsigned long long new_size, const Props& new_props); - virtual void apply_props_before_resize(const std::string& path, + virtual void apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); - virtual void apply_props_after_resize(const std::string& path, + virtual void apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); @@ -63,7 +63,7 @@ bool _journaled; - void enable_journal(const std::string& path); + void enable_journal(const String& path); }; --- conga/ricci/modules/storage/FSController.cpp 2006/07/12 18:27:26 1.4 +++ conga/ricci/modules/storage/FSController.cpp 2006/08/10 22:53:09 1.5 @@ -31,7 +31,7 @@ counting_auto_ptr -FSController::get_fs(const std::string& path) +FSController::get_fs(const String& path) { try { return counting_auto_ptr(new ExtendedFS(path)); @@ -42,7 +42,7 @@ try { // return counting_auto_ptr(new gfs(path)); } catch ( ... ) {} - throw string("not FS"); + throw String("not FS"); } @@ -70,15 +70,15 @@ const counting_auto_ptr& cont_templ) { if (cont_templ->type != CONTENT_FS_TYPE) - throw string("content_template not of filesystem type"); + throw String("content_template not of filesystem type"); - string fs_type = cont_templ->attrs["fs_type"]; + String fs_type = cont_templ->attrs["fs_type"]; if (fs_type == "extended_fs") create_extended_fs(bd->path(), cont_templ); else if (fs_type == "swap") create_swap_fs(bd->path(), cont_templ); else - throw string("unknown fs type \"") + fs_type + "\""; + throw String("unknown fs type \"") + fs_type + "\""; utils::clear_cache(); return get_fs(bd->path()); --- conga/ricci/modules/storage/FSController.h 2006/03/06 21:48:05 1.1 +++ conga/ricci/modules/storage/FSController.h 2006/08/10 22:53:09 1.2 @@ -34,7 +34,7 @@ { public: - counting_auto_ptr get_fs(const std::string& path); + counting_auto_ptr get_fs(const String& path); std::list > get_available_fss(); --- conga/ricci/modules/storage/HD.cpp 2006/05/16 19:59:56 1.3 +++ conga/ricci/modules/storage/HD.cpp 2006/08/10 22:53:09 1.4 @@ -31,14 +31,14 @@ using namespace std; -HD::HD(const std::string& path) : +HD::HD(const String& path) : BD(MAPPER_SYS_TYPE, SYS_PREFIX, BD_HD_TYPE, path) { - vector args; - string out, err; + vector args; + String out, err; int status; /* @@ -47,13 +47,13 @@ args.push_back("--getsize"); args.push_back(path); if (utils::execute("/sbin/blockdev", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("blockdev failed"); + throw String("blockdev failed"); out = utils::strip(out); - vector lines = utils::split(out, "\n"); + vector lines = utils::split(out, "\n"); if (lines.size() != 2) - throw string("invalid output from blockdev"); + throw String("invalid output from blockdev"); long long size = utils::to_long(utils::strip(lines[0])); size *= utils::to_long(utils::strip(lines[1])); _props.set(Variable("size", size)); @@ -61,42 +61,42 @@ // vendor & model - string vendor("unknown"); - string model(vendor); + String vendor("unknown"); + String model(vendor); args.clear(); out.clear(); - args.push_back(string("/proc/ide") + path.substr(string("/dev").size()) + "/model"); + args.push_back(String("/proc/ide") + path.substr(String("/dev").size()) + "/model"); if (utils::execute("/bin/cat", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status == 0) { - vector words = utils::split(utils::strip(out)); + vector words = utils::split(utils::strip(out)); if (words.size() == 1) model = words[0]; if (words.size() > 1) { vendor = words[0]; model = ""; - for (vector::size_type i=1; i::size_type i=1; i words = utils::split(out); + vector words = utils::split(out); if (words.size() == 2) { type = "scsi"; - string scsi_id = words[1]; + String scsi_id = words[1]; if (scsi_id.size()) _props.set(Variable("scsi_id", scsi_id)); - string scsi_addr = words[0]; + String scsi_addr = words[0]; if (scsi_addr.size()) { if (scsi_addr[scsi_addr.size() - 1] == ':') scsi_addr = scsi_addr.substr(0, scsi_addr.size() - 1); @@ -136,20 +136,20 @@ HD::shrink(unsigned long long new_size, const Props& new_props) { - throw string("HD::shrink() not implemented"); + throw String("HD::shrink() not implemented"); } void HD::expand(unsigned long long new_size, const Props& new_props) { - throw string("HD::expand() not implemented"); + throw String("HD::expand() not implemented"); } -string +String HD::apply_props_before_resize(const Props& new_props) { return path(); } -string +String HD::apply_props_after_resize(const Props& new_props) { return path(); @@ -158,5 +158,5 @@ void HD::remove() { - throw string("HD remove not implemented"); + throw String("HD remove not implemented"); } --- conga/ricci/modules/storage/HD.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/HD.h 2006/08/10 22:53:09 1.3 @@ -30,7 +30,7 @@ class HD : public BD { public: - HD(const std::string& path); + HD(const String& path); virtual ~HD(); virtual void remove(); @@ -41,8 +41,8 @@ virtual void expand(unsigned long long new_size, const Props& new_props); - virtual std::string apply_props_before_resize(const Props& new_props); // return path - virtual std::string apply_props_after_resize(const Props& new_props); // return path + virtual String apply_props_before_resize(const Props& new_props); // return path + virtual String apply_props_after_resize(const Props& new_props); // return path }; --- conga/ricci/modules/storage/LV.cpp 2006/07/12 19:47:50 1.4 +++ conga/ricci/modules/storage/LV.cpp 2006/08/10 22:53:09 1.5 @@ -41,7 +41,7 @@ { // everything is already validated :) - string vgname = bd_temp.props.get("vgname").get_string(); + String vgname = bd_temp.props.get("vgname").get_string(); // if VG is marked as clustered, but cluster locking is not available, throw @@ -50,26 +50,26 @@ throw ClvmdError(); - string lvname = bd_temp.props.get("lvname").get_string(); + String lvname = bd_temp.props.get("lvname").get_string(); long long size = bd_temp.props.get("size").get_int(); bool snapshot = bd_temp.props.get("snapshot").get_bool(); if (snapshot) { - string origin = bd_temp.props.get("snapshot_origin").get_string(); - string origin_path = string("/dev/") + vgname + "/" + origin; + String origin = bd_temp.props.get("snapshot_origin").get_string(); + String origin_path = String("/dev/") + vgname + "/" + origin; LVM::lvcreate_snap(lvname, origin_path, size); } else LVM::lvcreate(vgname, lvname, size); utils::clear_cache(); - counting_auto_ptr bd = BDFactory::get_bd(string("/dev/") + vgname + "/" + lvname); + counting_auto_ptr bd = BDFactory::get_bd(String("/dev/") + vgname + "/" + lvname); if (!snapshot) ContentFactory().create_content(bd, bd_temp.content_parsed); utils::clear_cache(); - return BDFactory::get_bd(string("/dev/") + vgname + "/" + lvname); + return BDFactory::get_bd(String("/dev/") + vgname + "/" + lvname); } @@ -78,7 +78,7 @@ // ##### LV ##### -LV::LV(const std::string& path) : +LV::LV(const String& path) : BD(MAPPER_VG_TYPE, VG_PREFIX + LVM::vgname_from_lvpath(path), BD_LV_TYPE, @@ -163,7 +163,7 @@ -string +String LV::state_ind() const { Props tmp_props(_props); @@ -231,12 +231,12 @@ { LVM::lvextend(_path, new_size); } -string +String LV::apply_props_before_resize(const Props& new_props) { return path(); } -string +String LV::apply_props_after_resize(const Props& new_props) { return path(); @@ -259,8 +259,8 @@ // ##### LVTemplate ##### -LVTemplate::LVTemplate(const std::string& mapper_id, - const std::string& mapper_state_ind) : +LVTemplate::LVTemplate(const String& mapper_id, + const String& mapper_state_ind) : BDTemplate(MAPPER_VG_TYPE, mapper_id, mapper_state_ind, --- conga/ricci/modules/storage/LV.h 2006/07/12 19:47:50 1.3 +++ conga/ricci/modules/storage/LV.h 2006/08/10 22:53:09 1.4 @@ -33,10 +33,10 @@ class LV : public BD { public: - LV(const std::string& path); + LV(const String& path); virtual ~LV(); - virtual std::string state_ind() const; + virtual String state_ind() const; virtual void remove(); @@ -49,8 +49,8 @@ virtual void expand(unsigned long long new_size, const Props& new_props); - virtual std::string apply_props_before_resize(const Props& new_props); // return path - virtual std::string apply_props_after_resize(const Props& new_props); // return path + virtual String apply_props_before_resize(const Props& new_props); // return path + virtual String apply_props_after_resize(const Props& new_props); // return path private: @@ -60,8 +60,8 @@ class LVTemplate : public BDTemplate { public: - LVTemplate(const std::string& mapper_id, - const std::string& mapper_state_ind); + LVTemplate(const String& mapper_id, + const String& mapper_state_ind); virtual ~LVTemplate(); --- conga/ricci/modules/storage/LVM.cpp 2006/07/12 16:52:56 1.4 +++ conga/ricci/modules/storage/LVM.cpp 2006/08/10 22:53:09 1.5 @@ -43,16 +43,16 @@ using namespace std; -static string +static String get_locking_type(); -static vector -vg_props(const string& vgname); +static vector +vg_props(const String& vgname); -static string PVS_OPTIONS = "pv_name,vg_name,pv_size,pv_free,pv_attr,pv_fmt,pv_uuid,vg_extent_size"; +static String PVS_OPTIONS = "pv_name,vg_name,pv_size,pv_free,pv_attr,pv_fmt,pv_uuid,vg_extent_size"; static unsigned int PVS_NAME_IDX = 0; static unsigned int PVS_VG_NAME_IDX = 1; static unsigned int PVS_SIZE_IDX = 2; @@ -64,7 +64,7 @@ static unsigned int PVS_OPTIONS_LENGTH = 8; // last -static string LVS_OPTIONS_STRING = "lv_name,vg_name,stripes,stripesize,lv_attr,lv_uuid,devices,origin,snap_percent,seg_start,seg_size,vg_extent_size,lv_size,vg_free_count,vg_attr"; +static String LVS_OPTIONS_STRING = "lv_name,vg_name,stripes,stripesize,lv_attr,lv_uuid,devices,origin,snap_percent,seg_start,seg_size,vg_extent_size,lv_size,vg_free_count,vg_attr"; static unsigned int LVS_NAME_IDX = 0; static unsigned int LVS_VG_NAME_IDX = 1; //static unsigned int LVS_STRIPES_NUM_IDX = 2; @@ -87,7 +87,7 @@ -static string VGS_OPTIONS_STRING = "vg_name,vg_attr,vg_size,vg_extent_size,vg_free_count,max_lv,max_pv,vg_uuid"; +static String VGS_OPTIONS_STRING = "vg_name,vg_attr,vg_size,vg_extent_size,vg_free_count,max_lv,max_pv,vg_uuid"; static unsigned int VGS_NAME_IDX = 0; static unsigned int VGS_ATTR_IDX = 1; static unsigned int VGS_SIZE_IDX = 2; @@ -101,40 +101,40 @@ -std::string -LVM::vgname_from_lvpath(const std::string& lvpath) +String +LVM::vgname_from_lvpath(const String& lvpath) { check_locking(); - vector args; + vector args; args.push_back("lvdisplay"); args.push_back("-c"); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvdisplay failed"); + throw String("lvdisplay failed"); - vector lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + vector lines = utils::split(out, "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string& line = *iter; - vector words = utils::split(utils::strip(line), ":"); + String& line = *iter; + vector words = utils::split(utils::strip(line), ":"); if (lvpath == words[0]) return words[1]; } - throw string("no such LV"); + throw String("no such LV"); } -std::string -LVM::vgname_from_pvpath(const std::string& path) +String +LVM::vgname_from_pvpath(const String& path) { check_locking(); - vector args; + vector args; args.push_back("pvs"); args.push_back("--nosuffix"); args.push_back("--noheadings"); @@ -144,19 +144,19 @@ args.push_back(";"); args.push_back("-o"); args.push_back(PVS_OPTIONS); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("pvs failed"); - vector lines = utils::split(out, "\n"); - vector words; - for (vector::iterator iter = lines.begin(); + throw String("pvs failed"); + vector lines = utils::split(out, "\n"); + vector words; + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line = utils::strip(*iter); - vector t_words = utils::split(line, ";"); + String line = utils::strip(*iter); + vector t_words = utils::split(line, ";"); if (t_words.size() < PVS_OPTIONS_LENGTH) continue; if (t_words[PVS_NAME_IDX] == path) { @@ -165,18 +165,18 @@ } } if (words.size() < PVS_OPTIONS_LENGTH) - throw string("no such pv"); + throw String("no such pv"); return words[PVS_VG_NAME_IDX]; } void -LVM::probe_lv(const std::string& lvpath, Props& props) +LVM::probe_lv(const String& lvpath, Props& props) { check_locking(); - vector args; + vector args; args.push_back("lvs"); args.push_back("--nosuffix"); args.push_back("--noheadings"); @@ -190,22 +190,22 @@ // arglist.append("--all") args.push_back(lvpath); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvs failed"); + throw String("lvs failed"); - string line = utils::strip(out); - vector words = utils::split(line, ";"); + String line = utils::strip(out); + vector words = utils::split(line, ";"); if (words.size() < LVS_OPTIONS_LENGTH) - throw string("lvs failed, missing words"); + throw String("lvs failed, missing words"); - string vgname(utils::strip(words[LVS_VG_NAME_IDX])); + String vgname(utils::strip(words[LVS_VG_NAME_IDX])); props.set(Variable("vgname", vgname)); - string lvname(utils::strip(words[LVS_NAME_IDX])); + String lvname(utils::strip(words[LVS_NAME_IDX])); // remove [] if there (used to mark hidden lvs) lvname = utils::lstrip(lvname, "["); lvname = utils::rstrip(lvname, "]"); @@ -222,24 +222,24 @@ props.set(Variable("uuid", words[LVS_UUID_IDX])); - string attrs = words[LVS_ATTR_IDX]; + String attrs = words[LVS_ATTR_IDX]; props.set(Variable("attrs", attrs)); props.set(Variable("mirrored", attrs[0] == 'm')); // clustered - string vg_attrs = words[LVS_VG_ATTR_IDX]; + String vg_attrs = words[LVS_VG_ATTR_IDX]; props.set(Variable("clustered", vg_attrs[5] == 'c')); // snapshots - string origin = words[LVS_SNAP_ORIGIN_IDX]; + String origin = words[LVS_SNAP_ORIGIN_IDX]; props.set(Variable("snapshot", origin != "")); if (props.get("snapshot").get_bool()) { props.set(Variable("snapshot_origin", origin)); long long usage = utils::to_long(words[LVS_SNAP_PERCENT_IDX]); props.set(Variable("snapshot_usage_percent", usage)); } - list snapshots; + list snapshots; args.clear(); args.push_back("lvs"); args.push_back("--noheadings"); @@ -248,15 +248,15 @@ args.push_back("-o"); args.push_back("lv_name,vg_name,origin"); if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvs failed"); - vector lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + throw String("lvs failed"); + vector lines = utils::split(out, "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line = utils::strip(*iter); - vector words = utils::split(line, ";"); + String line = utils::strip(*iter); + vector words = utils::split(line, ";"); if (words.size() != 3) continue; if (words[1] == vgname && words[2] == lvname) @@ -270,11 +270,11 @@ void -LVM::probe_pv(const std::string& path, Props& props) +LVM::probe_pv(const String& path, Props& props) { check_locking(); - vector args; + vector args; args.push_back("pvs"); args.push_back("--nosuffix"); args.push_back("--noheadings"); @@ -284,19 +284,19 @@ args.push_back(";"); args.push_back("-o"); args.push_back(PVS_OPTIONS); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("pvs failed"); - vector lines = utils::split(out, "\n"); - vector words; - for (vector::iterator iter = lines.begin(); + throw String("pvs failed"); + vector lines = utils::split(out, "\n"); + vector words; + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line = utils::strip(*iter); - vector t_words = utils::split(line, ";"); + String line = utils::strip(*iter); + vector t_words = utils::split(line, ";"); if (t_words.size() < PVS_OPTIONS_LENGTH) continue; if (t_words[PVS_NAME_IDX] == path) { @@ -305,9 +305,9 @@ } } if (words.size() < PVS_OPTIONS_LENGTH) - throw string("no such pv"); + throw String("no such pv"); - string vgname(utils::strip(words[PVS_VG_NAME_IDX])); + String vgname(utils::strip(words[PVS_VG_NAME_IDX])); props.set(Variable("vgname", vgname)); long long extent_size = utils::to_long(words[PVS_EXTENT_SIZE_IDX]); @@ -330,7 +330,7 @@ void -LVM::probe_vg(const std::string& vgname, +LVM::probe_vg(const String& vgname, Props& props, list >& sources, list >& targets) @@ -338,8 +338,8 @@ check_locking(); // pv to vg mappings - map pv_to_vg; - vector args; + map pv_to_vg; + vector args; args.push_back("pvs"); args.push_back("--nosuffix"); args.push_back("--noheadings"); @@ -349,18 +349,18 @@ args.push_back(";"); args.push_back("-o"); args.push_back(PVS_OPTIONS); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("pvs failed"); - vector lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + throw String("pvs failed"); + vector lines = utils::split(out, "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string& line = *iter; - vector words = utils::split(utils::strip(line), ";"); + String& line = *iter; + vector words = utils::split(utils::strip(line), ";"); if (words.size() >= PVS_OPTIONS_LENGTH) pv_to_vg[words[PVS_NAME_IDX]] = words[PVS_VG_NAME_IDX]; } @@ -368,11 +368,11 @@ // probe vg if (!vgname.empty()) { - vector words = vg_props(vgname); + vector words = vg_props(vgname); props.set(Variable("vgname", words[VGS_NAME_IDX])); - string vg_attrs(words[VGS_ATTR_IDX]); + String vg_attrs(words[VGS_ATTR_IDX]); props.set(Variable("attrs", vg_attrs)); long long size = utils::to_long(words[VGS_SIZE_IDX]); @@ -401,14 +401,14 @@ } // PVS - for (map::iterator iter = pv_to_vg.begin(); + for (map::iterator iter = pv_to_vg.begin(); iter != pv_to_vg.end(); iter++) { if (iter->second == vgname) sources.push_back(BDFactory::get_bd(iter->first)); } if (sources.empty() && !vgname.empty()) - throw string("invalid mapper_id"); + throw String("invalid mapper_id"); // LVS @@ -417,15 +417,15 @@ args.push_back("-c"); out = err = ""; if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvdisplay failed"); + throw String("lvdisplay failed"); lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string& line = *iter; - vector words = utils::split(utils::strip(line), ":"); + String& line = *iter; + vector words = utils::split(utils::strip(line), ":"); if (words.size() > 2) if (words[1] == vgname) targets.push_back(counting_auto_ptr(new LV(words[0]))); @@ -434,156 +434,156 @@ void -LVM::pvcreate(const std::string& path) +LVM::pvcreate(const String& path) { - vector args; + vector args; args.push_back("pvcreate"); args.push_back("-y"); args.push_back("-f"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("pvcreate failed"); + throw String("pvcreate failed"); utils::clear_cache(); } void -LVM::pvremove(const std::string& path) +LVM::pvremove(const String& path) { - vector args; + vector args; args.push_back("pvremove"); args.push_back("-y"); args.push_back("-f"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("pvremove failed"); + throw String("pvremove failed"); utils::clear_cache(); } void -LVM::vgcreate(const std::string& vgname, +LVM::vgcreate(const String& vgname, long long extent_size, bool clustered, - const list& pv_paths) + const list& pv_paths) { if (clustered && !clustered_available()) throw ClvmdError(); - vector args; + vector args; args.push_back("vgcreate"); args.push_back("--physicalextentsize"); args.push_back(utils::to_string(extent_size/1024) + "k"); args.push_back("-c"); args.push_back(clustered ? "y" : "n"); args.push_back(vgname); - for (list::const_iterator iter = pv_paths.begin(); + for (list::const_iterator iter = pv_paths.begin(); iter != pv_paths.end(); iter++) args.push_back(*iter); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("vgcreate failed"); + throw String("vgcreate failed"); utils::clear_cache(); } void -LVM::vgremove(const std::string& vgname) +LVM::vgremove(const String& vgname) { - vector args; + vector args; args.push_back("vgremove"); args.push_back(vgname); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("vgremove failed"); + throw String("vgremove failed"); utils::clear_cache(); } void -LVM::vgextend(const std::string& vgname, - const std::list& pv_paths) +LVM::vgextend(const String& vgname, + const std::list& pv_paths) { - vector args; + vector args; args.push_back("vgextend"); args.push_back(vgname); - for (list::const_iterator iter = pv_paths.begin(); + for (list::const_iterator iter = pv_paths.begin(); iter != pv_paths.end(); iter++) args.push_back(*iter); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("vgextend failed"); + throw String("vgextend failed"); utils::clear_cache(); } void -LVM::vgreduce(const std::string& vgname, - const std::string& pv_path) +LVM::vgreduce(const String& vgname, + const String& pv_path) { - vector args; + vector args; args.push_back("vgreduce"); args.push_back(vgname); args.push_back(pv_path); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("vgreduce failed"); + throw String("vgreduce failed"); utils::clear_cache(); } void -LVM::vgchange(const std::string& vgname, +LVM::vgchange(const String& vgname, bool clustered) { if (clustered && !clustered_available()) throw ClvmdError(); - vector args; + vector args; args.push_back("vgchange"); args.push_back("-c"); args.push_back(clustered ? "y" : "n"); args.push_back(vgname); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("vgchange failed"); + throw String("vgchange failed"); utils::clear_cache(); } void -LVM::lvcreate(const std::string& vgname, - const std::string& lvname, +LVM::lvcreate(const String& vgname, + const String& lvname, long long size) { - vector args; + vector args; args.push_back("lvcreate"); args.push_back("--name"); args.push_back(lvname); @@ -591,20 +591,20 @@ args.push_back(utils::to_string(size / 1024) + "k"); args.push_back(vgname); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvcreate failed"); + throw String("lvcreate failed"); utils::clear_cache(); } void -LVM::lvcreate_snap(const std::string& lvname, - const std::string& origin_path, +LVM::lvcreate_snap(const String& lvname, + const String& origin_path, long long size) { - vector args; + vector args; args.push_back("lvcreate"); args.push_back("--snapshot"); args.push_back("--name"); @@ -613,70 +613,70 @@ args.push_back(utils::to_string(size / 1024) + "k"); args.push_back(origin_path); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvcreate failed"); + throw String("lvcreate failed"); utils::clear_cache(); } void -LVM::lvremove(const std::string& path) +LVM::lvremove(const String& path) { - vector args; + vector args; args.push_back("lvremove"); args.push_back("--force"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvremove failed"); + throw String("lvremove failed"); utils::clear_cache(); } void -LVM::lvreduce(const std::string& path, long long new_size) +LVM::lvreduce(const String& path, long long new_size) { long long size_k = new_size / 1024; - vector args; + vector args; args.push_back("lvreduce"); args.push_back("-f"); args.push_back("-L"); args.push_back(utils::to_string(size_k) + "k"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvreduce failed"); + throw String("lvreduce failed"); utils::clear_cache(); } void -LVM::lvextend(const std::string& path, long long new_size) +LVM::lvextend(const String& path, long long new_size) { long long size_k = new_size / 1024; - vector args; + vector args; args.push_back("lvextend"); args.push_back("-L"); args.push_back(utils::to_string(size_k) + "k"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("lvextend failed"); + throw String("lvextend failed"); utils::clear_cache(); } @@ -692,14 +692,14 @@ { if (get_locking_type() == "2") { // check if quorate - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("quorum"); if (utils::execute("/sbin/magma_tool", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("cluster tools: magma_tool errored"); + throw String("cluster tools: magma_tool errored"); if (out.find("Quorate") == out.npos) throw ClusterNotQuorateError(); @@ -708,27 +708,27 @@ args.push_back("clvmd"); args.push_back("start"); if (utils::execute("/sbin/service", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) throw ClvmdError(); } } -string +String get_locking_type() { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("locking_type"); args.push_back("/etc/lvm/lvm.conf"); if (utils::execute("/bin/grep", args, out, err, status)) - throw string("execute failed"); - vector lines(utils::split(utils::strip(out), "\n")); - for (vector::const_iterator line = lines.begin(); + throw String("execute failed"); + vector lines(utils::split(utils::strip(out), "\n")); + for (vector::const_iterator line = lines.begin(); line != lines.end(); line++) { - vector words(utils::split(utils::strip(*line))); + vector words(utils::split(utils::strip(*line))); if (words.size() < 3) continue; if (words[0] == "locking_type" && @@ -736,15 +736,15 @@ return words[2]; } } - throw string("locking_type not found in lvm.conf!!!"); + throw String("locking_type not found in lvm.conf!!!"); } -vector -vg_props(const string& vgname) +vector +vg_props(const String& vgname) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("vgs"); args.push_back("--nosuffix"); args.push_back("--noheadings"); @@ -756,27 +756,27 @@ args.push_back(VGS_OPTIONS_STRING); // args.push_back(vgname); if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("vgs failed"); + throw String("vgs failed"); - vector lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + vector lines = utils::split(out, "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line = utils::strip(*iter); - vector words = utils::split(line, ";"); + String line = utils::strip(*iter); + vector words = utils::split(line, ";"); if (words.size() < VGS_OPTIONS_LENGTH) continue; if (words[VGS_NAME_IDX] == vgname) { return words; } } - throw string("no such vg"); + throw String("no such vg"); } bool -LVM::vg_clustered(const string& vgname) +LVM::vg_clustered(const String& vgname) { if (vgname.empty()) return false; --- conga/ricci/modules/storage/LVM.h 2006/06/28 20:09:08 1.3 +++ conga/ricci/modules/storage/LVM.h 2006/08/10 22:53:09 1.4 @@ -28,7 +28,7 @@ #include "counting_auto_ptr.h" #include "BD.h" -#include +#include "String.h" #include @@ -36,46 +36,46 @@ { public: - static std::string vgname_from_lvpath(const std::string& lvpath); - static std::string vgname_from_pvpath(const std::string& pvpath); - static void probe_lv(const std::string& lvpath, Props& props); - static void probe_pv(const std::string& pvpath, Props& props); + static String vgname_from_lvpath(const String& lvpath); + static String vgname_from_pvpath(const String& pvpath); + static void probe_lv(const String& lvpath, Props& props); + static void probe_pv(const String& pvpath, Props& props); - static void probe_vg(const std::string& vgname, + static void probe_vg(const String& vgname, Props& props, std::list >& sources, std::list >& targets); - static void pvcreate(const std::string& path); - static void pvremove(const std::string& path); + static void pvcreate(const String& path); + static void pvremove(const String& path); - static void vgcreate(const std::string& vgname, + static void vgcreate(const String& vgname, long long extent_size, bool clustered, - const std::list& pv_paths); - static void vgremove(const std::string& vgname); - static void vgextend(const std::string& vgname, - const std::list& pv_paths); - static void vgreduce(const std::string& vgname, - const std::string& pv_path); - static void vgchange(const std::string& vgname, + const std::list& pv_paths); + static void vgremove(const String& vgname); + static void vgextend(const String& vgname, + const std::list& pv_paths); + static void vgreduce(const String& vgname, + const String& pv_path); + static void vgchange(const String& vgname, bool clustered); - static void lvcreate(const std::string& vgname, - const std::string& lvname, + static void lvcreate(const String& vgname, + const String& lvname, long long size); - static void lvcreate_snap(const std::string& lvname, - const std::string& origin_path, + static void lvcreate_snap(const String& lvname, + const String& origin_path, long long size); - static void lvremove(const std::string& path); + static void lvremove(const String& path); - static void lvreduce(const std::string& path, long long new_size); - static void lvextend(const std::string& path, long long new_size); + static void lvreduce(const String& path, long long new_size); + static void lvextend(const String& path, long long new_size); static void check_locking(); static bool clustered_available(); - static bool vg_clustered(const std::string& vgname); + static bool vg_clustered(const String& vgname); }; --- conga/ricci/modules/storage/MDRaid.cpp 2006/07/12 18:27:26 1.5 +++ conga/ricci/modules/storage/MDRaid.cpp 2006/08/10 22:53:09 1.6 @@ -29,10 +29,10 @@ using namespace std; -list +list get_MDRaid_ids() { - list ids; + list ids; try { list raids = mdadm::raids(); @@ -50,13 +50,13 @@ // ##### MDRaid ##### -MDRaid::MDRaid(const std::string& id) : +MDRaid::MDRaid(const String& id) : Mapper(MAPPER_MDRAID_TYPE, id) { - string raid_path = id.substr(MDRAID_PREFIX.size()); + String raid_path = id.substr(MDRAID_PREFIX.size()); _raid = mdadm::probe_path(raid_path); if (_raid.path != raid_path) - throw string("not mdraid"); + throw String("not mdraid"); for (list::const_iterator iter = _raid.devices.begin(); iter != _raid.devices.end(); @@ -136,7 +136,7 @@ void MDRaid::__remove() { - // throw string("MDRaid::_remove() not yet implemented"); + // throw String("MDRaid::_remove() not yet implemented"); mdadm::stop_raid(_raid); @@ -153,31 +153,31 @@ counting_auto_ptr create_MDRaid(const MapperTemplate& temp) { - // throw string("create_MDRaid() not yet implemented"); + // throw String("create_MDRaid() not yet implemented"); // everything is already validated, but number of sources if (temp.sources.size() < 2) - throw string("create_MDRaid requires at least two sources"); + throw String("create_MDRaid requires@least two sources"); - list devs; + list devs; for (list >::const_iterator iter = temp.sources.begin(); iter != temp.sources.end(); iter++) devs.push_back((*iter)->path()); - string raid_path = mdadm::create_raid(temp.props.get("level").get_string(), + String raid_path = mdadm::create_raid(temp.props.get("level").get_string(), devs); return counting_auto_ptr(new MDRaid(MDRAID_PREFIX + raid_path)); /* - string vgname = temp.props.get("vgname").get_string(); + String vgname = temp.props.get("vgname").get_string(); long long extent_size = temp.props.get("extent_size").get_int(); try { utils::clear_cache(); - list pv_paths; + list pv_paths; for (list >::const_iterator iter = temp.sources.begin(); iter != temp.sources.end(); iter++) { @@ -214,7 +214,7 @@ MDRaidTemplate::MDRaidTemplate() : MapperTemplate(MAPPER_MDRAID_TYPE) { - // throw string("MDRaidTemplate() not yet implemented"); + // throw String("MDRaidTemplate() not yet implemented"); list > mappers = MapperFactory::get_mappers(MAPPER_PT_TYPE); @@ -230,11 +230,11 @@ } } if (new_sources.size() < 2) - throw string("not enough sources for mdraid"); + throw String("not enough sources for mdraid"); props.set(Variable("min_sources", (long long) 2)); props.set(Variable("max_sources", (long long) new_sources.size())); - list levels = mdadm::valid_raid_levels(); + list levels = mdadm::valid_raid_levels(); props.set(Variable("level", levels.front(), levels)); } --- conga/ricci/modules/storage/MDRaid.h 2006/03/10 17:50:11 1.1 +++ conga/ricci/modules/storage/MDRaid.h 2006/08/10 22:53:09 1.2 @@ -27,17 +27,17 @@ #include "Mapper.h" #include "mdadm_wrapper.h" #include -#include +#include "String.h" -std::list get_MDRaid_ids(); +std::list get_MDRaid_ids(); counting_auto_ptr create_MDRaid(const MapperTemplate& temp); class MDRaid : public Mapper { public: - MDRaid(const std::string& id); + MDRaid(const String& id); virtual ~MDRaid(); virtual void apply(const MapperParsed&); --- conga/ricci/modules/storage/MDRaidSource.cpp 2006/05/16 20:12:00 1.2 +++ conga/ricci/modules/storage/MDRaidSource.cpp 2006/08/10 22:53:09 1.3 @@ -27,7 +27,7 @@ using namespace std; -MDRaidSource::MDRaidSource(const std::string& path) : +MDRaidSource::MDRaidSource(const String& path) : MapperSource(MAPPER_MDRAID_TYPE, "BUG", SOURCE_MDRAID_TYPE, @@ -35,21 +35,21 @@ _raid(mdadm::probe_path(path)) { if (_raid.path == path) - throw string("not MDRaidSource, but target"); + throw String("not MDRaidSource, but target"); for (list::const_iterator iter = _raid.devices.begin(); iter != _raid.devices.end(); iter++) if (iter->path == path) _raid_source = counting_auto_ptr(new mdraid_source(*iter)); if ( ! _raid_source.get()) - throw string("MDRaidSource, null pointer"); + throw String("MDRaidSource, null pointer"); _mapper_id = MDRAID_PREFIX + _raid.path; _props.set(Variable("raid", _raid.name)); _props.set(Variable("raid_level", _raid.level)); - string state; + String state; switch (_raid_source->type) { case MDRAID_S_ACTIVE: state = "active"; @@ -61,7 +61,7 @@ state = "failed"; break; default: - throw string("invalid mdraid_source_type"); + throw String("invalid mdraid_source_type"); } _props.set(Variable("state", state)); @@ -89,12 +89,12 @@ MDRaidSource::remove() { if ( ! removable()) - throw string("MDRaidSource::remove() called on unremovable mdraid source"); + throw String("MDRaidSource::remove() called on unremovable mdraid source"); mdadm::remove_source(_raid.path, path()); } void -MDRaidSource::apply_props_before_resize(const std::string& path, +MDRaidSource::apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) --- conga/ricci/modules/storage/MDRaidSource.h 2006/03/10 17:50:11 1.1 +++ conga/ricci/modules/storage/MDRaidSource.h 2006/08/10 22:53:09 1.2 @@ -31,14 +31,14 @@ class MDRaidSource : public MapperSource { public: - MDRaidSource(const std::string& path); + MDRaidSource(const String& path); virtual ~MDRaidSource(); virtual bool removable() const; virtual void remove(); - virtual void apply_props_before_resize(const std::string& path, + virtual void apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); --- conga/ricci/modules/storage/MDRaidTarget.cpp 2006/05/16 20:12:00 1.2 +++ conga/ricci/modules/storage/MDRaidTarget.cpp 2006/08/10 22:53:09 1.3 @@ -34,7 +34,7 @@ -MDRaidTarget::MDRaidTarget(const std::string& path) : +MDRaidTarget::MDRaidTarget(const String& path) : BD(MAPPER_MDRAID_TYPE, "BUG", BD_MDRAID_TYPE, @@ -42,7 +42,7 @@ { _raid = mdadm::probe_path(path); if (_raid.path != path) - throw string("not MDRaidTarget, but source"); + throw String("not MDRaidTarget, but source"); _mapper_id = MDRAID_PREFIX + _raid.path; // props @@ -73,20 +73,20 @@ MDRaidTarget::shrink(unsigned long long new_size, const Props& new_props) { - throw string("MDRaidTarget not resizable"); + throw String("MDRaidTarget not resizable"); } void MDRaidTarget::expand(unsigned long long new_size, const Props& new_props) { - throw string("MDRaidTarget not resizable"); + throw String("MDRaidTarget not resizable"); } -string +String MDRaidTarget::apply_props_before_resize(const Props& new_props) { return path(); } -string +String MDRaidTarget::apply_props_after_resize(const Props& new_props) { return path(); --- conga/ricci/modules/storage/MDRaidTarget.h 2006/03/10 17:50:11 1.1 +++ conga/ricci/modules/storage/MDRaidTarget.h 2006/08/10 22:53:09 1.2 @@ -32,7 +32,7 @@ class MDRaidTarget : public BD { public: - MDRaidTarget(const std::string& path); + MDRaidTarget(const String& path); virtual ~MDRaidTarget(); virtual void remove(); @@ -44,8 +44,8 @@ virtual void expand(unsigned long long new_size, const Props& new_props); - virtual std::string apply_props_before_resize(const Props& new_props); // return path - virtual std::string apply_props_after_resize(const Props& new_props); // return path + virtual String apply_props_before_resize(const Props& new_props); // return path + virtual String apply_props_after_resize(const Props& new_props); // return path private: --- conga/ricci/modules/storage/Mapper.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/Mapper.cpp 2006/08/10 22:53:09 1.3 @@ -33,7 +33,7 @@ // ##### Mapper ##### -Mapper::Mapper(const std::string& type, const std::string& id) : +Mapper::Mapper(const String& type, const String& id) : _mapper_type(type), _mapper_id(id) { @@ -60,7 +60,7 @@ void Mapper::add_sources(const list& parsed_bds) { - list paths; + list paths; list > bds; for (list::const_iterator iter = parsed_bds.begin(); iter != parsed_bds.end(); @@ -95,7 +95,7 @@ Mapper::remove() { if (!_props.get("removable").get_bool()) - throw string("mapper not removable"); + throw String("mapper not removable"); for (list >::const_iterator iter = targets.begin(); iter != targets.end(); @@ -106,7 +106,7 @@ } -string +String Mapper::state_ind() const { XMLObject xml("hash"); @@ -179,7 +179,7 @@ MapperParsed::MapperParsed(const XMLObject& xml) { if (xml.tag() != MAPPER_TYPE_TAG) - throw string("not Mapper"); + throw String("not Mapper"); mapper_type = xml.get_attr("mapper_type"); mapper_id = xml.get_attr("mapper_id"); @@ -187,7 +187,7 @@ if (mapper_type.empty() || mapper_id.empty() || state_ind.empty()) - throw string("MapperParsed missing identification"); + throw String("MapperParsed missing identification"); // get Mapper try { @@ -220,19 +220,19 @@ // ##### MapperTemplate ##### -MapperTemplate::MapperTemplate(const std::string& type) : +MapperTemplate::MapperTemplate(const String& type) : mapper_type(type) {} MapperTemplate::MapperTemplate(const XMLObject& xml) { if (xml.tag() != MAPPER_TEMPLATE_TYPE_TAG) - throw string("not mapper template"); + throw String("not mapper template"); list > mapper_temps = MapperFactory::get_mapper_templates(xml.get_attr("mapper_type")); if (mapper_temps.size() != 1) - throw string("invalid number of mapper_templates returned"); + throw String("invalid number of mapper_templates returned"); counting_auto_ptr orig_mapp = mapper_temps.front(); mapper_type = orig_mapp->mapper_type; --- conga/ricci/modules/storage/Mapper.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/Mapper.h 2006/08/10 22:53:09 1.3 @@ -30,7 +30,7 @@ #include "Props.h" #include "counting_auto_ptr.h" -#include +#include "String.h" #include @@ -42,7 +42,7 @@ public: virtual ~Mapper(); - std::string state_ind() const; + String state_ind() const; Props _props; @@ -65,10 +65,10 @@ virtual void add_sources(const std::list& bds); protected: - Mapper(const std::string& type, const std::string& id); + Mapper(const String& type, const String& id); - std::string _mapper_type; - std::string _mapper_id; + String _mapper_type; + String _mapper_id; virtual void __add_sources(const std::list >& bds) = 0; virtual void __remove() = 0; @@ -88,9 +88,9 @@ Props props; - std::string mapper_type; - std::string mapper_id; - std::string state_ind; + String mapper_type; + String mapper_id; + String state_ind; counting_auto_ptr mapper; @@ -113,12 +113,12 @@ std::list > new_targets; - std::string mapper_type; + String mapper_type; Props props; protected: - MapperTemplate(const std::string& type); + MapperTemplate(const String& type); private: --- conga/ricci/modules/storage/MapperFactory.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/MapperFactory.cpp 2006/08/10 22:53:09 1.3 @@ -35,44 +35,44 @@ -list > -MapperFactory::get_mapper_ids(const std::string& mapper_type) +list > +MapperFactory::get_mapper_ids(const String& mapper_type) { - list > id_pairs; + list > id_pairs; if (mapper_type == MAPPER_VG_TYPE || mapper_type.empty()) { - list ids = get_VG_ids(); - for (list::iterator iter = ids.begin(); + list ids = get_VG_ids(); + for (list::iterator iter = ids.begin(); iter != ids.end(); iter++) - id_pairs.push_back(pair(MAPPER_VG_TYPE, *iter)); + id_pairs.push_back(pair(MAPPER_VG_TYPE, *iter)); } if (mapper_type == MAPPER_SYS_TYPE || mapper_type.empty()) { - list ids = get_SYS_ids(); - for (list::iterator iter = ids.begin(); + list ids = get_SYS_ids(); + for (list::iterator iter = ids.begin(); iter != ids.end(); iter++) - id_pairs.push_back(pair(MAPPER_SYS_TYPE, *iter)); + id_pairs.push_back(pair(MAPPER_SYS_TYPE, *iter)); } if (mapper_type == MAPPER_PT_TYPE || mapper_type.empty()) { - list ids = get_PT_ids(); - for (list::iterator iter = ids.begin(); + list ids = get_PT_ids(); + for (list::iterator iter = ids.begin(); iter != ids.end(); iter++) - id_pairs.push_back(pair(MAPPER_PT_TYPE, *iter)); + id_pairs.push_back(pair(MAPPER_PT_TYPE, *iter)); } if (mapper_type == MAPPER_MDRAID_TYPE || mapper_type.empty()) { - list ids = get_MDRaid_ids(); - for (list::iterator iter = ids.begin(); + list ids = get_MDRaid_ids(); + for (list::iterator iter = ids.begin(); iter != ids.end(); iter++) - id_pairs.push_back(pair(MAPPER_MDRAID_TYPE, *iter)); + id_pairs.push_back(pair(MAPPER_MDRAID_TYPE, *iter)); } return id_pairs; } counting_auto_ptr -MapperFactory::get_mapper(const std::string& mapper_type, - const std::string& mapper_id) +MapperFactory::get_mapper(const String& mapper_type, + const String& mapper_id) { if (mapper_type == MAPPER_VG_TYPE) return counting_auto_ptr(new VG(mapper_id)); @@ -82,23 +82,23 @@ return counting_auto_ptr(new PartitionTable(mapper_id)); if (mapper_type == MAPPER_MDRAID_TYPE) return counting_auto_ptr(new MDRaid(mapper_id)); - throw string("no such mapper type"); + throw String("no such mapper type"); } list > -MapperFactory::get_mappers(const std::string& mapper_type, - const std::string& mapper_id) +MapperFactory::get_mappers(const String& mapper_type, + const String& mapper_id) { list > mappers; - list > id_pairs = get_mapper_ids(""); - for (list >::iterator iter = id_pairs.begin(); + list > id_pairs = get_mapper_ids(""); + for (list >::iterator iter = id_pairs.begin(); iter != id_pairs.end(); iter++) { if ((mapper_type.empty() || mapper_type == iter->first) && (mapper_id.empty() || mapper_id == iter->second)) try { mappers.push_back(get_mapper(iter->first, iter->second)); - // } catch ( string e ) { + // } catch ( String e ) { // cout << e << endl; } catch ( ... ) {} } @@ -106,7 +106,7 @@ } list > -MapperFactory::get_mapper_templates(const std::string& mapper_type) +MapperFactory::get_mapper_templates(const String& mapper_type) { list > temps; if (mapper_type == MAPPER_VG_TYPE || @@ -137,7 +137,7 @@ return create_PT(mapper_temp); if (mapper_temp.mapper_type == MAPPER_MDRAID_TYPE) return create_MDRaid(mapper_temp); - throw string("no such mapper type"); + throw String("no such mapper type"); } counting_auto_ptr @@ -155,9 +155,9 @@ counting_auto_ptr -MapperFactory::add_sources(const std::string& mapper_type, - const std::string& mapper_id, - const std::string& mapper_state_ind, +MapperFactory::add_sources(const String& mapper_type, + const String& mapper_id, + const String& mapper_state_ind, const list& bds) { counting_auto_ptr mapper = get_mapper(mapper_type, mapper_id); --- conga/ricci/modules/storage/MapperFactory.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/MapperFactory.h 2006/08/10 22:53:09 1.3 @@ -32,19 +32,19 @@ { public: - static std::list > - get_mapper_ids(const std::string& mapper_type=""); + static std::list > + get_mapper_ids(const String& mapper_type=""); static counting_auto_ptr - get_mapper(const std::string& mapper_type, - const std::string& mapper_id); + get_mapper(const String& mapper_type, + const String& mapper_id); static std::list > - get_mappers(const std::string& mapper_type="", - const std::string& mapper_id=""); + get_mappers(const String& mapper_type="", + const String& mapper_id=""); static std::list > - get_mapper_templates(const std::string& mapper_type); + get_mapper_templates(const String& mapper_type); static counting_auto_ptr create_mapper(const MapperTemplate& mapper_temp); @@ -55,9 +55,9 @@ static void remove_mapper(const MapperParsed& mapper); static counting_auto_ptr - add_sources(const std::string& mapper_type, - const std::string& mapper_id, - const std::string& mapper_state_ind, + add_sources(const String& mapper_type, + const String& mapper_id, + const String& mapper_state_ind, const std::list& bds); }; --- conga/ricci/modules/storage/MapperSource.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/MapperSource.cpp 2006/08/10 22:53:09 1.3 @@ -28,10 +28,10 @@ using namespace std; -MapperSource::MapperSource(const std::string& mapper_type, - const std::string& mapper_id, - const std::string& type, - const std::string& path) : +MapperSource::MapperSource(const String& mapper_type, + const String& mapper_id, + const String& type, + const String& path) : Content(CONTENT_MS_TYPE, path), _mapper_type(mapper_type), _mapper_id(mapper_id), @@ -55,26 +55,26 @@ } void -MapperSource::shrink(const std::string& path, +MapperSource::shrink(const String& path, unsigned long long new_size, const Props& new_props) {} void -MapperSource::expand(const std::string& path, +MapperSource::expand(const String& path, unsigned long long new_size, const Props& new_props) {} void -MapperSource::apply_props_before_resize(const std::string& path, +MapperSource::apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) {} void -MapperSource::apply_props_after_resize(const std::string& path, +MapperSource::apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) @@ -90,7 +90,7 @@ void MapperSource::remove() { - throw string("MapperSource not removable"); + throw String("MapperSource not removable"); } @@ -108,7 +108,7 @@ -MapperSourceTemplate::MapperSourceTemplate(const string& mapper_type) : +MapperSourceTemplate::MapperSourceTemplate(const String& mapper_type) : ContentTemplate(CONTENT_MS_TYPE), _mapper_type(mapper_type) { --- conga/ricci/modules/storage/MapperSource.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/MapperSource.h 2006/08/10 22:53:09 1.3 @@ -26,16 +26,16 @@ #include "Content.h" #include "XML.h" -#include +#include "String.h" class MapperSource : public Content { public: - MapperSource(const std::string& mapper_type, - const std::string& mapper_id, - const std::string& type, - const std::string& path); + MapperSource(const String& mapper_type, + const String& mapper_id, + const String& type, + const String& path); virtual ~MapperSource(); XMLObject xml() const; @@ -44,17 +44,17 @@ virtual bool expandable(long long& max_size) const; virtual bool shrinkable(long long& min_size) const; - virtual void shrink(const std::string& path, + virtual void shrink(const String& path, unsigned long long new_size, const Props& new_props); - virtual void expand(const std::string& path, + virtual void expand(const String& path, unsigned long long new_size, const Props& new_props); - virtual void apply_props_before_resize(const std::string& path, + virtual void apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); - virtual void apply_props_after_resize(const std::string& path, + virtual void apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); @@ -63,9 +63,9 @@ virtual void remove(); protected: - std::string _mapper_type; - std::string _mapper_id; - std::string _type; + String _mapper_type; + String _mapper_id; + String _type; private: @@ -80,9 +80,9 @@ virtual ~MapperSourceTemplate(); protected: - MapperSourceTemplate(const std::string& mapper_type); + MapperSourceTemplate(const String& mapper_type); - std::string _mapper_type; + String _mapper_type; }; --- conga/ricci/modules/storage/MountHandler.cpp 2006/04/03 19:30:21 1.2 +++ conga/ricci/modules/storage/MountHandler.cpp 2006/08/10 22:53:09 1.3 @@ -43,10 +43,10 @@ -static string mtab_path("/etc/mtab"); -static string fstab_path("/etc/fstab"); -static string mounts_path("/proc/mounts"); -static string findfs_path("/sbin/findfs"); +static String mtab_path("/etc/mtab"); +static String fstab_path("/etc/fstab"); +static String mounts_path("/proc/mounts"); +static String findfs_path("/sbin/findfs"); static Mutex mutex; @@ -54,18 +54,18 @@ static int locker_counter = 0; -static list -follow_links(const std::string& path); -static string -find_path(const std::string& devname); +static list +follow_links(const String& path); +static String +find_path(const String& devname); static void -create_dir(const std::string& path); +create_dir(const String& path); -Mountpoint::Mountpoint(const std::string& devname, - const std::string& mountpoint, - const std::string& fstype, +Mountpoint::Mountpoint(const String& devname, + const String& mountpoint, + const String& fstype, const std::pair& major_minor) : devname(devname), mountpoint(mountpoint), @@ -87,15 +87,15 @@ std::pair -MountHandler::maj_min(const std::string& devname) const +MountHandler::maj_min(const String& devname) const { MutexLocker l1(mutex); - string path(follow_links(find_path(devname)).back()); + String path(follow_links(find_path(devname)).back()); struct stat st; if (stat(path.c_str(), &st)) - throw string("stat(") + path + ") failed"; + throw String("stat(") + path + ") failed"; if (!S_ISBLK(st.st_mode)) throw path + " is not a block device"; @@ -104,7 +104,7 @@ } std::list -MountHandler::get_entries(const std::string& filename) const +MountHandler::get_entries(const String& filename) const { MutexLocker l1(mutex); FstabLocker l2; @@ -115,7 +115,7 @@ FILE* fstab = setmntent(filename.c_str(), "r"); if (!fstab) - throw string("unable to open ") + filename; + throw String("unable to open ") + filename; try { while (getmntent_r(fstab, &mntbuff, buff, sizeof(buff))) try { @@ -143,7 +143,7 @@ FILE* file = fopen("/proc/swaps", "r"); if (!file) - throw string("unable to open /proc/swaps"); + throw String("unable to open /proc/swaps"); try { bool done = false; while (!done) { @@ -157,12 +157,12 @@ continue; } else { free(ptr); - throw string("error reading /proc/swaps"); + throw String("error reading /proc/swaps"); } } - string line; + String line; try { - line = utils::strip(string(ptr, size)); + line = utils::strip(String(ptr, size)); free(ptr); } catch ( ... ) { free(ptr); @@ -172,7 +172,7 @@ if (line.empty()) continue; if (line[0] == '/') { - string path(utils::split(line)[0]); + String path(utils::split(line)[0]); ret.push_back(Mountpoint(path, "swap", "swap", @@ -227,15 +227,15 @@ } bool -MountHandler::mount(const std::string& devname, - const std::string& mountpoint, - const std::string& fstype) const +MountHandler::mount(const String& devname, + const String& mountpoint, + const String& fstype) const { MutexLocker l1(mutex); - string out, err, bin; + String out, err, bin; int status; - vector args; + vector args; if (fstype == "swap") { bin = "/sbin/swapon"; @@ -259,19 +259,19 @@ err, status, false)) - throw string("execute failed"); + throw String("execute failed"); return !status; } bool -MountHandler::umount(const std::string& devname, - const std::string& mountpoint) const +MountHandler::umount(const String& devname, + const String& mountpoint) const { MutexLocker l1(mutex); - string out, err, bin; + String out, err, bin; int status; - vector args; + vector args; if (mountpoint == "swap") { bin = "/sbin/swapoff"; @@ -289,21 +289,21 @@ err, status, false)) - throw string("execute failed"); + throw String("execute failed"); return !status; } bool -MountHandler::fstab_add(const std::string& devname, - const std::string& mountpoint, - const std::string& fstype) const +MountHandler::fstab_add(const String& devname, + const String& mountpoint, + const String& fstype) const { MutexLocker l1(mutex); FstabLocker l2; - string dev(utils::strip(devname)); - string mnt(utils::strip(mountpoint)); - string type(utils::strip(fstype)); + String dev(utils::strip(devname)); + String mnt(utils::strip(mountpoint)); + String type(utils::strip(fstype)); // verify devname pair mm = maj_min(dev); @@ -321,12 +321,12 @@ return true; else if (mnt != "swap") - throw string("dir already in fstab"); + throw String("dir already in fstab"); } FILE* fstab = setmntent(fstab_path.c_str(), "r+"); if (!fstab) - throw string("unable to open ") + fstab_path; + throw String("unable to open ") + fstab_path; bool success; try { struct mntent st; @@ -347,19 +347,19 @@ } void -MountHandler::fstab_remove(const std::string& devname, - const std::string& mountpoint) const +MountHandler::fstab_remove(const String& devname, + const String& mountpoint) const { MutexLocker l1(mutex); FstabLocker l2; - string dev(utils::strip(devname)); - string mnt(utils::strip(mountpoint)); + String dev(utils::strip(devname)); + String mnt(utils::strip(mountpoint)); FILE* fstab = fopen(fstab_path.c_str(), "r"); if (!fstab) - throw string("unable to open ") + fstab_path; - string buff; + throw String("unable to open ") + fstab_path; + String buff; bool modified = false; try { bool done = false; @@ -374,19 +374,19 @@ continue; } else { free(ptr); - throw string("error reading fstab"); + throw String("error reading fstab"); } } - string line; + String line; try { - line = string(ptr, size); + line = String(ptr, size); free(ptr); } catch ( ... ) { free(ptr); throw; } - vector words = utils::split(utils::strip(line)); + vector words = utils::split(utils::strip(line)); if (words.size() < 2) buff += line; else if (words[0].empty()) @@ -410,10 +410,10 @@ if (modified) { fstab = fopen(fstab_path.c_str(), "w"); if (!fstab) - throw string("unable to open ") + fstab_path; + throw String("unable to open ") + fstab_path; try { if (!fwrite(buff.c_str(), buff.size(), 1, fstab)) - throw string("error writing fstab"); + throw String("error writing fstab"); while (fclose(fstab) && errno == EINTR) ; } catch ( ... ) { @@ -424,17 +424,17 @@ } } -std::list +std::list MountHandler::fstypes() const { MutexLocker l1(mutex); - list fss; + list fss; fss.push_back("swap"); FILE* file = fopen("/proc/filesystems", "r"); if (!file) - throw string("unable to open /proc/filesystems"); + throw String("unable to open /proc/filesystems"); try { bool done = false; while (!done) { @@ -448,12 +448,12 @@ continue; } else { free(ptr); - throw string("error reading /proc/filesystems"); + throw String("error reading /proc/filesystems"); } } - string line; + String line; try { - line = utils::strip(string(ptr, size)); + line = utils::strip(String(ptr, size)); free(ptr); } catch ( ... ) { free(ptr); @@ -476,22 +476,22 @@ return fss; } -static std::list -_used_dirs(const string& filename) +static std::list +_used_dirs(const String& filename) { MutexLocker l1(mutex); FstabLocker l2; char buff[1024]; struct mntent mntbuff; - list ret; + list ret; FILE* fstab = setmntent(filename.c_str(), "r"); if (!fstab) - throw string("unable to open ") + filename; + throw String("unable to open ") + filename; try { while (getmntent_r(fstab, &mntbuff, buff, sizeof(buff))) { - string mp(mntbuff.mnt_dir); + String mp(mntbuff.mnt_dir); if (!mp.empty()) if (mp[0] == '/') ret.push_back(mp); @@ -503,23 +503,23 @@ endmntent(fstab); return ret; } -std::list +std::list MountHandler::used_dirs() const { MutexLocker l1(mutex); FstabLocker l2; - list ret = _used_dirs(fstab_path.c_str()); + list ret = _used_dirs(fstab_path.c_str()); - list tmp = _used_dirs(mtab_path.c_str()); - for (list::const_iterator iter = tmp.begin(); + list tmp = _used_dirs(mtab_path.c_str()); + for (list::const_iterator iter = tmp.begin(); iter != tmp.end(); iter++) if (find(ret.begin(), ret.end(), *iter) == ret.end()) ret.push_back(*iter); tmp = _used_dirs(mounts_path.c_str()); - for (list::const_iterator iter = tmp.begin(); + for (list::const_iterator iter = tmp.begin(); iter != tmp.end(); iter++) if (find(ret.begin(), ret.end(), *iter) == ret.end()) @@ -539,14 +539,14 @@ if (locker_counter == 0) { locker_fd = open(fstab_path.c_str(), O_RDWR); if (locker_fd == -1) - throw string("unable to open fstab"); + throw String("unable to open fstab"); int ret; while ((ret = flock(locker_fd, LOCK_EX)) && errno == EINTR) ; if (ret) { while (close(locker_fd) == -1 && errno == EINTR) ; - throw string("unable to flock fstab"); + throw String("unable to flock fstab"); } } @@ -562,7 +562,7 @@ while ((ret = flock(locker_fd, LOCK_UN)) && errno == EINTR) ; if (ret) - throw string("unable to unflock fstab"); + throw String("unable to unflock fstab"); while (close(locker_fd) == -1 && errno == EINTR) ; } @@ -574,58 +574,58 @@ -list -follow_links(const std::string& path) +list +follow_links(const String& path) { char buff[1024]; - list paths; + list paths; paths.push_back(path); int ret; while ((ret = readlink(paths.back().c_str(), buff, sizeof(buff))) > 0) - paths.push_back(string(buff, ret)); + paths.push_back(String(buff, ret)); return paths; } -string -find_path(const std::string& devname) +String +find_path(const String& devname) { if (devname.find("LABEL=") == 0) { - string out, err; + String out, err; int status; if (utils::execute(findfs_path, - vector(1, devname), + vector(1, devname), out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("unable to find path for ") + devname + + throw String("unable to find path for ") + devname + " " + out + " " + err + " " + utils::to_string(status); - string path = utils::split(out, "\n")[0]; + String path = utils::split(out, "\n")[0]; return utils::strip(path); } else if (devname[0] == '/') return devname; else - throw string("find_path(") + devname + ") not implemented"; + throw String("find_path(") + devname + ") not implemented"; } void -create_dir(const std::string& path) +create_dir(const String& path) { MutexLocker l1(mutex); if (path.empty()) - throw string("dir path is empty :-/"); + throw String("dir path is empty :-/"); if (path[0] != '/') - throw string("dir has to be an absolute path"); + throw String("dir has to be an absolute path"); - string out, err, bin; + String out, err, bin; int status; - vector args; + vector args; args.push_back("-p"); args.push_back(utils::strip(path)); if (utils::execute("/bin/mkdir", @@ -634,7 +634,7 @@ err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("creation of ") + path + " failed"; + throw String("creation of ") + path + " failed"; } --- conga/ricci/modules/storage/MountHandler.h 2006/03/10 17:50:11 1.1 +++ conga/ricci/modules/storage/MountHandler.h 2006/08/10 22:53:09 1.2 @@ -25,7 +25,7 @@ #define MountHandler_h -#include +#include "String.h" #include @@ -46,15 +46,15 @@ public: virtual ~Mountpoint(); - const std::string devname; - const std::string mountpoint; - const std::string fstype; + const String devname; + const String mountpoint; + const String fstype; const std::pair major_minor; private: - Mountpoint(const std::string& devname, - const std::string& mountpoint, - const std::string& fstype, + Mountpoint(const String& devname, + const String& mountpoint, + const String& fstype, const std::pair& major_minor); @@ -67,7 +67,7 @@ MountHandler(); virtual ~MountHandler(); - std::pair maj_min(const std::string& devname) const; + std::pair maj_min(const String& devname) const; std::list mounts() const; std::list mounts(const std::pair fstabs(const std::pair& maj_min) const; - bool mount(const std::string& devname, - const std::string& mountpoint, - const std::string& fstype) const; - bool umount(const std::string& devname, - const std::string& mountpoint) const; - - bool fstab_add(const std::string& devname, - const std::string& mountpoint, - const std::string& fstype) const; - void fstab_remove(const std::string& devname, - const std::string& mountpoint) const; + bool mount(const String& devname, + const String& mountpoint, + const String& fstype) const; + bool umount(const String& devname, + const String& mountpoint) const; + + bool fstab_add(const String& devname, + const String& mountpoint, + const String& fstype) const; + void fstab_remove(const String& devname, + const String& mountpoint) const; - std::list fstypes() const; // /proc/filesystems + std::list fstypes() const; // /proc/filesystems - std::list used_dirs() const; // list of mounpoints from fstab, mtab & mounts + std::list used_dirs() const; // list of mounpoints from fstab, mtab & mounts private: - std::list get_entries(const std::string& filename) const; + std::list get_entries(const String& filename) const; }; --- conga/ricci/modules/storage/PTSource.cpp 2006/03/06 21:48:05 1.1 +++ conga/ricci/modules/storage/PTSource.cpp 2006/08/10 22:53:09 1.2 @@ -29,17 +29,17 @@ using namespace std; -PTSource::PTSource(const std::string& path) : +PTSource::PTSource(const String& path) : MapperSource(MAPPER_PT_TYPE, PT_PREFIX + path, SOURCE_PT_TYPE, path) { - list hds = Parted::possible_paths(); + list hds = Parted::possible_paths(); if (find(hds.begin(), hds.end(), path) == hds.end()) - throw string(path + "not a partition table"); + throw String(path + "not a partition table"); - std::pair > p = Parted::partitions(path); + std::pair > p = Parted::partitions(path); _props.set(Variable("disklabel", p.first)); } --- conga/ricci/modules/storage/PTSource.h 2006/03/06 21:48:05 1.1 +++ conga/ricci/modules/storage/PTSource.h 2006/08/10 22:53:09 1.2 @@ -31,7 +31,7 @@ class PTSource : public MapperSource { public: - PTSource(const std::string& path); + PTSource(const String& path); virtual ~PTSource(); --- conga/ricci/modules/storage/PV.cpp 2006/06/28 20:09:08 1.3 +++ conga/ricci/modules/storage/PV.cpp 2006/08/10 22:53:09 1.4 @@ -31,7 +31,7 @@ using namespace std; -PV::PV(const std::string& path) : +PV::PV(const String& path) : MapperSource(MAPPER_VG_TYPE, VG_PREFIX + LVM::vgname_from_pvpath(path), SOURCE_PV_TYPE, @@ -40,17 +40,17 @@ LVM::probe_pv(path, _props); if (unused()) { - list vgnames; + list vgnames; - string vgname(_props.get("vgname").get_string()); + String vgname(_props.get("vgname").get_string()); vgnames.push_back(vgname); - list > vg_pairs = + list > vg_pairs = MapperFactory::get_mapper_ids(MAPPER_VG_TYPE); - for (list >::const_iterator iter = vg_pairs.begin(); + for (list >::const_iterator iter = vg_pairs.begin(); iter != vg_pairs.end(); iter++) { - string vgname_alt(iter->second.substr(VG_PREFIX.size())); + String vgname_alt(iter->second.substr(VG_PREFIX.size())); if (find(vgnames.begin(), vgnames.end(), vgname_alt) == vgnames.end()) @@ -84,13 +84,13 @@ PV::remove() { if (!removable()) - throw string("PV::remove() called, while pv not removable"); + throw String("PV::remove() called, while pv not removable"); counting_auto_ptr vg = MapperFactory::get_mapper(_mapper_type, _mapper_id); - string vgname = _props.get("vgname").get_string(); + String vgname = _props.get("vgname").get_string(); // if VG is marked as clustered, but cluster locking is not available, throw @@ -111,13 +111,13 @@ } void -PV::apply_props_before_resize(const std::string& path, +PV::apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) { - string vgname_old(_props.get("vgname").get_string()); - string vgname_new(new_props.get("vgname").get_string()); + String vgname_old(_props.get("vgname").get_string()); + String vgname_new(new_props.get("vgname").get_string()); // if VG is marked as clustered, but cluster locking is not available, throw @@ -139,17 +139,17 @@ LVM::vgreduce(vgname_old, path); } if (vgname_new.size()) - LVM::vgextend(vgname_new, list(1, path)); + LVM::vgextend(vgname_new, list(1, path)); } } void -create_content_pv(const std::string& path, +create_content_pv(const String& path, const counting_auto_ptr& templ) { - string vgname(templ->_props.get("vgname").get_string()); + String vgname(templ->_props.get("vgname").get_string()); // if VG is marked as clustered, but cluster locking is not available, throw @@ -161,7 +161,7 @@ LVM::pvcreate(path); try { if (vgname.size()) - LVM::vgextend(vgname, list(1, path)); + LVM::vgextend(vgname, list(1, path)); } catch ( ... ) { LVM::pvremove(path); throw; @@ -172,13 +172,13 @@ PVTemplate::PVTemplate() : MapperSourceTemplate(MAPPER_VG_TYPE) { - list vgnames; - list > vg_pairs = + list vgnames; + list > vg_pairs = MapperFactory::get_mapper_ids(MAPPER_VG_TYPE); - for (list >::const_iterator iter = vg_pairs.begin(); + for (list >::const_iterator iter = vg_pairs.begin(); iter != vg_pairs.end(); iter++) { - string vgname(iter->second.substr(VG_PREFIX.size())); + String vgname(iter->second.substr(VG_PREFIX.size())); vgnames.push_back(vgname); } --- conga/ricci/modules/storage/PV.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/PV.h 2006/08/10 22:53:09 1.3 @@ -28,14 +28,14 @@ -void create_content_pv(const std::string& path, +void create_content_pv(const String& path, const counting_auto_ptr& templ); class PV : public MapperSource { public: - PV(const std::string& path); + PV(const String& path); virtual ~PV(); @@ -43,7 +43,7 @@ virtual bool removable() const; virtual void remove(); - virtual void apply_props_before_resize(const std::string& path, + virtual void apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); --- conga/ricci/modules/storage/Partition.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/Partition.cpp 2006/08/10 22:53:09 1.3 @@ -37,7 +37,7 @@ -Partition::Partition(const std::string& path) : +Partition::Partition(const String& path) : BD(MAPPER_PT_TYPE, PT_PREFIX + Parted::extract_pt_path(path), BD_PART_TYPE, @@ -45,7 +45,7 @@ false), _pt_path(Parted::extract_pt_path(path)) { - pair > p = Parted::partitions(_pt_path); + pair > p = Parted::partitions(_pt_path); list parts = p.second; for (list::iterator iter = parts.begin(); iter != parts.end(); @@ -69,10 +69,10 @@ } } } - throw string(_path + " not a partition"); + throw String(_path + " not a partition"); } -Partition::Partition(const std::string& path, +Partition::Partition(const String& path, const PartedPartition& parted_part) : BD(MAPPER_PT_TYPE, PT_PREFIX + Parted::extract_pt_path(path), @@ -129,7 +129,7 @@ // TODO: logical removal changes paths, fix it out // for now, only last logical can be removed int max_logical = part.partnum(); - pair > p = Parted::partitions(_pt_path); + pair > p = Parted::partitions(_pt_path); const list parts = p.second; for (list::const_iterator iter = parts.begin(); iter != parts.end(); @@ -148,7 +148,7 @@ } // if label not supported, parts not removable - list supp_labels = Parted::supported_labels(); + list supp_labels = Parted::supported_labels(); bool label_supported = (find(supp_labels.begin(), supp_labels.end(), part.label()) != supp_labels.end()); @@ -165,20 +165,20 @@ Partition::shrink(unsigned long long new_size, const Props& new_props) { - throw string("Partition::shrink() not implemented"); + throw String("Partition::shrink() not implemented"); } void Partition::expand(unsigned long long new_size, const Props& new_props) { - throw string("Partition::expand() not implemented"); + throw String("Partition::expand() not implemented"); } -string +String Partition::apply_props_before_resize(const Props& new_props) { return path(); } -string +String Partition::apply_props_after_resize(const Props& new_props) { return path(); @@ -188,7 +188,7 @@ Partition::remove() { if (!partition.get()) - throw string("Partition::remove() null pointer"); + throw String("Partition::remove() null pointer"); content->remove(); Parted::remove_partition(_pt_path, @@ -202,14 +202,14 @@ { // everything is already validated :) - string pt_path = bd_temp.mapper_id.substr(PT_PREFIX.size()); + String pt_path = bd_temp.mapper_id.substr(PT_PREFIX.size()); - string part_type = bd_temp.props.get("partition_type").get_string(); + String part_type = bd_temp.props.get("partition_type").get_string(); long long seg_begin = bd_temp.props.get("partition_begin").get_int(); long long size = bd_temp.props.get("size").get_int(); - string part_path = Parted::create_partition(pt_path, + String part_path = Parted::create_partition(pt_path, part_type, seg_begin, size); @@ -223,8 +223,8 @@ } -PartitionTemplate::PartitionTemplate(const std::string& mapper_id, - const std::string& mapper_state_ind, +PartitionTemplate::PartitionTemplate(const String& mapper_id, + const String& mapper_state_ind, const PartedPartition& part) : BDTemplate(MAPPER_PT_TYPE, mapper_id, @@ -232,11 +232,11 @@ BD_PART_TYPE) { if (!part.unused_space()) - throw string("not unused space"); + throw String("not unused space"); props.set(Variable("partition_begin", part.begin())); - string type; + String type; if (part.primary()) type = "primary"; else if (part.extended()) @@ -244,7 +244,7 @@ else if (part.logical()) type = "logical"; else - throw string("uncreatable"); + throw String("uncreatable"); props.set(Variable("partition_type", type)); long long min_part_size = Parted::min_part_size(part.label()); --- conga/ricci/modules/storage/Partition.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/Partition.h 2006/08/10 22:53:09 1.3 @@ -34,8 +34,8 @@ class Partition : public BD { public: - Partition(const std::string& path); - Partition(const std::string& path, const PartedPartition& parted_part); + Partition(const String& path); + Partition(const String& path, const PartedPartition& parted_part); virtual ~Partition(); virtual void remove(); @@ -46,13 +46,13 @@ virtual void expand(unsigned long long new_size, const Props& new_props); - virtual std::string apply_props_before_resize(const Props& new_props); // return path - virtual std::string apply_props_after_resize(const Props& new_props); // return path + virtual String apply_props_before_resize(const Props& new_props); // return path + virtual String apply_props_after_resize(const Props& new_props); // return path private: void initialize(const PartedPartition& part); - std::string _pt_path; + String _pt_path; counting_auto_ptr partition; @@ -63,8 +63,8 @@ class PartitionTemplate : public BDTemplate { public: - PartitionTemplate(const std::string& mapper_id, - const std::string& mapper_state_ind, + PartitionTemplate(const String& mapper_id, + const String& mapper_state_ind, const PartedPartition& part); virtual ~PartitionTemplate(); --- conga/ricci/modules/storage/PartitionTable.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/PartitionTable.cpp 2006/08/10 22:53:09 1.3 @@ -35,13 +35,13 @@ using namespace std; -list get_PT_ids() +list get_PT_ids() { - list hds = Parted::possible_paths(); + list hds = Parted::possible_paths(); // check if a partition table is on the path - list ids; - for (list::iterator iter = hds.begin(); + list ids; + for (list::iterator iter = hds.begin(); iter != hds.end(); iter ++) { try { @@ -57,11 +57,11 @@ { // everything is already validated, but number of sources if (temp.sources.size() != 1) - throw string("create_PT requires exactly one source"); + throw String("create_PT requires exactly one source"); utils::clear_cache(); - string path = temp.sources.front()->path(); + String path = temp.sources.front()->path(); Parted::create_label(path, temp.props.get("label").get_string()); utils::clear_cache(); @@ -74,33 +74,33 @@ // ##### PartitionTable ##### static void -generate_targets(const string& pt_path, +generate_targets(const String& pt_path, const list& parts, list >& targets); static void -generate_new_targets(const string& mapper_id, - const std::string& mapper_state_ind, +generate_new_targets(const String& mapper_id, + const String& mapper_state_ind, const list& parts, list >& new_targets); -PartitionTable::PartitionTable(const std::string& id) : +PartitionTable::PartitionTable(const String& id) : Mapper(MAPPER_PT_TYPE, id) { _pt_path = _mapper_id; _pt_path.replace(0, PT_PREFIX.size(), ""); - list hds = Parted::possible_paths(); + list hds = Parted::possible_paths(); if (find(hds.begin(), hds.end(), _pt_path) == hds.end()) - throw string(_pt_path + "not a partition table"); + throw String(_pt_path + "not a partition table"); - pair > p = Parted::partitions(_pt_path); + pair > p = Parted::partitions(_pt_path); const list parts = p.second; _label = p.first; _props.set(Variable("disklabel", _label)); // label supported - list supp_labels = Parted::supported_labels(); + list supp_labels = Parted::supported_labels(); bool label_supported = (find(supp_labels.begin(), supp_labels.end(), _label) != supp_labels.end()); @@ -140,7 +140,7 @@ void PartitionTable::__add_sources(const list >& bds) { - throw string("PartitionTable can have only one source"); + throw String("PartitionTable can have only one source"); } void @@ -152,7 +152,7 @@ static void -generate_targets(const string& pt_path, +generate_targets(const String& pt_path, const list& parts, list >& targets) { @@ -160,7 +160,7 @@ iter != parts.end(); iter++) { if (!iter->unused_space()) { - string part_path = Parted::generate_part_path(pt_path, *iter); + String part_path = Parted::generate_part_path(pt_path, *iter); targets.push_back(counting_auto_ptr(new Partition(part_path, *iter))); if (iter->extended()) generate_targets(pt_path, iter->kids(), targets); @@ -169,8 +169,8 @@ } static void -generate_new_targets(const string& mapper_id, - const std::string& mapper_state_ind, +generate_new_targets(const String& mapper_id, + const String& mapper_state_ind, const list& parts, list >& new_targets) { @@ -215,7 +215,7 @@ p)); new_targets.push_back(ptt); } - } catch ( string e ) { + } catch ( String e ) { cout << e << endl; } catch ( ... ) {} } else if (iter->extended()) @@ -233,7 +233,7 @@ PTTemplate::PTTemplate() : MapperTemplate(MAPPER_PT_TYPE) { - Variable labels("label", string("gpt"), Parted::supported_labels()); + Variable labels("label", String("gpt"), Parted::supported_labels()); props.set(labels); // new sources @@ -249,7 +249,7 @@ } if (new_sources.empty()) - throw string("no available new sources"); + throw String("no available new sources"); props.set(Variable("min_sources", (long long) 1)); props.set(Variable("max_sources", (long long) 1)); } --- conga/ricci/modules/storage/PartitionTable.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/PartitionTable.h 2006/08/10 22:53:09 1.3 @@ -27,14 +27,14 @@ #include "Mapper.h" -std::list get_PT_ids(); +std::list get_PT_ids(); counting_auto_ptr create_PT(const MapperTemplate& temp); class PartitionTable : public Mapper { public: - PartitionTable(const std::string& id); + PartitionTable(const String& id); virtual ~PartitionTable(); virtual void apply(const MapperParsed&); @@ -45,8 +45,8 @@ virtual void __remove(); private: - std::string _pt_path; - std::string _label; + String _pt_path; + String _label; }; // PartitionTable --- conga/ricci/modules/storage/Props.cpp 2006/03/06 21:48:05 1.1 +++ conga/ricci/modules/storage/Props.cpp 2006/08/10 22:53:09 1.2 @@ -35,7 +35,7 @@ Props::Props(const XMLObject& xml) { if (xml.tag() != PROPERTIES_TAG) - throw string("not properties"); + throw String("not properties"); for (list::const_iterator iter = xml.children().begin(); iter != xml.children().end(); @@ -52,28 +52,28 @@ const Variable& -Props::get(const std::string& name) const +Props::get(const String& name) const { - map::const_iterator iter = _vars.find(name); + map::const_iterator iter = _vars.find(name); if (iter == _vars.end()) - throw string("Props: no such variable") + name; + throw String("Props: no such variable") + name; return iter->second; } Variable& -Props::get(const std::string& name) +Props::get(const String& name) { - map::iterator iter = _vars.find(name); + map::iterator iter = _vars.find(name); if (iter == _vars.end()) - throw string("Props: no such variable - ") + name; + throw String("Props: no such variable - ") + name; return iter->second; } void Props::set(const Variable& var) { - pair p(var.name(), var); - pair::iterator, bool> i = _vars.insert(p); + pair p(var.name(), var); + pair::iterator, bool> i = _vars.insert(p); if (i.second == false) i.first->second = var; @@ -88,7 +88,7 @@ void Props::validate(const Props& props) const { - for (map::const_iterator iter = _vars.begin(); + for (map::const_iterator iter = _vars.begin(); iter != _vars.end(); iter++) { const Variable& v1 = iter->second; @@ -108,7 +108,7 @@ Props::xml() const { XMLObject props(PROPERTIES_TAG); - for (map::const_iterator iter = _vars.begin(); + for (map::const_iterator iter = _vars.begin(); iter != _vars.end(); iter++) props.add_child(iter->second.xml()); --- conga/ricci/modules/storage/Props.h 2006/03/06 21:48:05 1.1 +++ conga/ricci/modules/storage/Props.h 2006/08/10 22:53:09 1.2 @@ -27,10 +27,10 @@ #include "Variable.h" #include "XML.h" #include -#include +#include "String.h" -#define PROPERTIES_TAG std::string("properties") +#define PROPERTIES_TAG String("properties") class Props @@ -40,8 +40,8 @@ Props(const XMLObject&); virtual ~Props(); - const Variable& get(const std::string& name) const; - Variable& get(const std::string& name); + const Variable& get(const String& name) const; + Variable& get(const String& name); void set(const Variable& var); void validate() const; @@ -53,7 +53,7 @@ private: - std::map _vars; + std::map _vars; }; --- conga/ricci/modules/storage/StorageModule.cpp 2006/05/16 20:10:39 1.3 +++ conga/ricci/modules/storage/StorageModule.cpp 2006/08/10 22:53:09 1.4 @@ -29,9 +29,9 @@ using namespace std; -static list _mapper_ids(const string& mapper_type); -static list _mappers(const string& mapper_type, const string& mapper_id); -static list _mapper_templates(const string& mapper_type); +static list _mapper_ids(const String& mapper_type); +static list _mappers(const String& mapper_type, const String& mapper_id); +static list _mapper_templates(const String& mapper_type); static VarMap report(const VarMap& args); static VarMap get_mapper_ids(const VarMap& args); @@ -94,34 +94,34 @@ Variable temps("mapper_templates", _mapper_templates("")); VarMap ret; - ret.insert(pair(ids.name(), ids)); - ret.insert(pair(mappers.name(), mappers)); - ret.insert(pair(temps.name(), temps)); + ret.insert(pair(ids.name(), ids)); + ret.insert(pair(mappers.name(), mappers)); + ret.insert(pair(temps.name(), temps)); return ret; } VarMap get_mapper_ids(const VarMap& args) { - string mapper_type; + String mapper_type; try { VarMap::const_iterator iter = args.find("mapper_type"); if (iter != args.end()) mapper_type = iter->second.get_string(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } Variable var("mapper_ids", _mapper_ids(mapper_type)); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } VarMap get_mappers(const VarMap& args) { - string mapper_type, mapper_id; + String mapper_type, mapper_id; try { VarMap::const_iterator iter = args.find("mapper_type"); if (iter != args.end()) @@ -130,31 +130,31 @@ iter = args.find("mapper_id"); if (iter != args.end()) mapper_id = iter->second.get_string(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } Variable var("mappers", _mappers(mapper_type, mapper_id)); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } VarMap get_mapper_templates(const VarMap& args) { - string mapper_type; + String mapper_type; try { VarMap::const_iterator iter = args.find("mapper_type"); if (iter != args.end()) mapper_type = iter->second.get_string(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } Variable var("mapper_templates", _mapper_templates(mapper_type)); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -167,7 +167,7 @@ if (iter == args.end()) throw APIerror("missing mapper variable"); mapper_xml = iter->second.get_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -176,7 +176,7 @@ Variable var("mapper", mapper->xml()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -189,7 +189,7 @@ if (iter == args.end()) throw APIerror("missing mapper variable"); mapper_xml = iter->second.get_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -209,7 +209,7 @@ if (iter == args.end()) throw APIerror("missing mapper variable"); mapper_xml = iter->second.get_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -218,14 +218,14 @@ Variable var("mapper", mapper->xml()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } VarMap add_sources(const VarMap& args) { - string mapper_type, mapper_id, mapper_state_ind; + String mapper_type, mapper_id, mapper_state_ind; list bds_list; try { VarMap::const_iterator iter = args.find("mapper_type"); @@ -247,7 +247,7 @@ if (iter == args.end()) throw APIerror("missing bds variable"); bds_list = iter->second.get_list_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -263,7 +263,7 @@ Variable var("mapper", mapper->xml()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -277,7 +277,7 @@ if (iter == args.end()) throw APIerror("missing bd variable"); bd_xml = iter->second.get_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -292,21 +292,21 @@ Variable var_bd("bd", bd->xml()); Variable var_map("mapper", mapper->xml()); VarMap ret; - ret.insert(pair(var_bd.name(), var_bd)); - ret.insert(pair(var_map.name(), var_map)); + ret.insert(pair(var_bd.name(), var_bd)); + ret.insert(pair(var_map.name(), var_map)); return ret; } VarMap get_bd(const VarMap& args) { - string path; + String path; try { VarMap::const_iterator iter = args.find("path"); if (iter == args.end()) throw APIerror("missing path variable"); path = iter->second.get_string(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -314,7 +314,7 @@ Variable var("bd", bd->xml()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -327,7 +327,7 @@ if (iter == args.end()) throw APIerror("missing bd variable"); bd_xml = iter->second.get_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -336,7 +336,7 @@ Variable var("bd", bd->xml()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -349,7 +349,7 @@ if (iter == args.end()) throw APIerror("missing bd variable"); bd_xml = iter->second.get_XML(); - } catch ( string e ) { + } catch ( String e ) { throw APIerror(e); } @@ -358,7 +358,7 @@ Variable var("mapper", mapper->xml()); VarMap ret; - ret.insert(pair(var.name(), var)); + ret.insert(pair(var.name(), var)); return ret; } @@ -367,13 +367,13 @@ list -_mapper_ids(const string& mapper_type) +_mapper_ids(const String& mapper_type) { list ids_list; - list > id_pairs = MapperFactory::get_mapper_ids(mapper_type); - for (list >::iterator iter = id_pairs.begin(); + list > id_pairs = MapperFactory::get_mapper_ids(mapper_type); + for (list >::iterator iter = id_pairs.begin(); iter != id_pairs.end(); iter++) { XMLObject id_xml("mapper_id"); @@ -386,7 +386,7 @@ } list -_mappers(const string& mapper_type, const string& mapper_id) +_mappers(const String& mapper_type, const String& mapper_id) { list mapper_list; @@ -402,7 +402,7 @@ } list -_mapper_templates(const string& mapper_type) +_mapper_templates(const String& mapper_type) { list temp_list; --- conga/ricci/modules/storage/SwapFS.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/SwapFS.cpp 2006/08/10 22:53:09 1.3 @@ -30,23 +30,23 @@ using namespace std; -SwapFS::SwapFS(const std::string& path) : +SwapFS::SwapFS(const String& path) : ContentFS("swap", path) { - vector args; + vector args; args.push_back("-s"); args.push_back("-L"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute("/usr/bin/file", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("file failed"); + throw String("file failed"); if (out.find("swap") == out.npos) - throw string(path + "not swap"); + throw String(path + "not swap"); // swapon MountHandler mh; @@ -79,19 +79,19 @@ } void -SwapFS::shrink(const std::string& path, +SwapFS::shrink(const String& path, unsigned long long new_size, const Props& new_props) {} void -SwapFS::expand(const std::string& path, +SwapFS::expand(const String& path, unsigned long long new_size, const Props& new_props) {} void -SwapFS::apply_props_before_resize(const std::string& path, +SwapFS::apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) @@ -127,7 +127,7 @@ } void -SwapFS::apply_props_after_resize(const std::string& path, +SwapFS::apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props) @@ -142,39 +142,39 @@ void -create_swap_fs(const std::string& path, +create_swap_fs(const String& path, const counting_auto_ptr& templ) { - string label = templ->_props.get("label").get_string(); + String label = templ->_props.get("label").get_string(); bool swapon = templ->_props.get("swapon").get_bool(); bool fstab = templ->_props.get("fstab").get_bool(); - vector args; + vector args; if (label.size()) { args.push_back("-L"); args.push_back(label); } args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute("/sbin/mkswap", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("mkswap failed"); + throw String("mkswap failed"); if (swapon) { args.clear(); args.push_back(path); if (utils::execute("/sbin/swapon", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("swapon failed"); + throw String("swapon failed"); } if (fstab) { /* - MountHandler().fstab_add(label.empty() ? path : string("LABEL=") + label, + MountHandler().fstab_add(label.empty() ? path : String("LABEL=") + label, "swap", "swap"); */ @@ -187,7 +187,7 @@ ContentFSTemplate("swap") { // label - _props.set(Variable("label", "", 0, 16, illegal_label_chars, list())); + _props.set(Variable("label", "", 0, 16, illegal_label_chars, list())); // swapon _props.set(Variable("swapon", true, true)); --- conga/ricci/modules/storage/SwapFS.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/SwapFS.h 2006/08/10 22:53:09 1.3 @@ -25,35 +25,35 @@ #define SwapFS_h #include "ContentFS.h" -#include +#include "String.h" -void create_swap_fs(const std::string& path, +void create_swap_fs(const String& path, const counting_auto_ptr& templ); class SwapFS : public ContentFS { public: - SwapFS(const std::string& path); + SwapFS(const String& path); virtual ~SwapFS(); virtual bool expandable(long long& max_size) const; virtual bool shrinkable(long long& min_size) const; - virtual void shrink(const std::string& path, + virtual void shrink(const String& path, unsigned long long new_size, const Props& new_props); - virtual void expand(const std::string& path, + virtual void expand(const String& path, unsigned long long new_size, const Props& new_props); - virtual void apply_props_before_resize(const std::string& path, + virtual void apply_props_before_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); - virtual void apply_props_after_resize(const std::string& path, + virtual void apply_props_after_resize(const String& path, unsigned long long old_size, unsigned long long new_size, const Props& new_props); --- conga/ricci/modules/storage/System.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/System.cpp 2006/08/10 22:53:09 1.3 @@ -33,41 +33,41 @@ using namespace std; -list +list get_SYS_ids() { - list ids; + list ids; ids.push_back(SYS_PREFIX); return ids; } -System::System(const std::string& id) : +System::System(const String& id) : Mapper(MAPPER_SYS_TYPE, id) { if (_mapper_id != SYS_PREFIX) - throw string("invalid mapper_id"); + throw String("invalid mapper_id"); // parse blockdev - vector args; + vector args; args.push_back("--report"); - string out, err; + String out, err; int status; if (utils::execute("/sbin/blockdev", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("blockdev failed"); + throw String("blockdev failed"); - vector lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + vector lines = utils::split(out, "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - vector words = utils::split(utils::strip(*iter)); + vector words = utils::split(utils::strip(*iter)); if (words.size() != 7 || words[0] == "RO") continue; - string path = words[6]; + String path = words[6]; if ( ! isdigit(path[path.size()-1])) targets.push_back(counting_auto_ptr(new HD(path))); } @@ -86,11 +86,11 @@ void System::__add_sources(const list >& bds) { - throw string("System can have no sources"); + throw String("System can have no sources"); } void System::__remove() { - throw string("System mapper is not removable"); + throw String("System mapper is not removable"); } --- conga/ricci/modules/storage/System.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/System.h 2006/08/10 22:53:09 1.3 @@ -29,13 +29,13 @@ #include -std::list get_SYS_ids(); +std::list get_SYS_ids(); class System : public Mapper { public: - System(const std::string& id); + System(const String& id); virtual ~System(); virtual void apply(const MapperParsed&); --- conga/ricci/modules/storage/UMountError.h 2006/04/07 16:42:40 1.2 +++ conga/ricci/modules/storage/UMountError.h 2006/08/10 22:53:09 1.3 @@ -30,8 +30,8 @@ class UMountError : public Except { public: - UMountError(const std::string& mountpoint) - : Except(3, std::string("Unmount of ") + mountpoint + " failed") {} + UMountError(const String& mountpoint) + : Except(3, String("Unmount of ") + mountpoint + " failed") {} virtual ~UMountError() {} --- conga/ricci/modules/storage/VG.cpp 2006/06/28 20:09:08 1.4 +++ conga/ricci/modules/storage/VG.cpp 2006/08/10 22:53:09 1.5 @@ -39,30 +39,30 @@ -list +list get_VG_ids() { LVM::check_locking(); - list vgids; + list vgids; - vector args; + vector args; args.push_back("vgs"); args.push_back("--noheadings"); args.push_back("-o"); args.push_back("vg_name"); - string out, err; + String out, err; int status; if (utils::execute(LVM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("vgdisplay failed"); - vector lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + throw String("vgdisplay failed"); + vector lines = utils::split(out, "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string line = utils::strip(*iter); - vector words = utils::split(line, " "); + String line = utils::strip(*iter); + vector words = utils::split(line, " "); if (words.size() == 1) if (!words[0].empty()) vgids.push_back(VG_PREFIX + words[0]); @@ -78,7 +78,7 @@ // ##### VG ##### -VG::VG(const std::string& id) : +VG::VG(const String& id) : Mapper(MAPPER_VG_TYPE, id), _vgname(id.substr(VG_PREFIX.size())) { @@ -135,15 +135,15 @@ free_size, _props.get("extent_size").get_int())); - list lvnames; + list lvnames; for (list >::const_iterator iter = targets.begin(); iter != targets.end(); iter++) { - string lvname = (*iter)->_props.get("lvname").get_string(); + String lvname = (*iter)->_props.get("lvname").get_string(); lvnames.push_back(lvname); } new_lv->props.set(Variable("lvname", - string("new_lv"), + String("new_lv"), 1, 36, "-?/$%!", @@ -158,7 +158,7 @@ counting_auto_ptr new_snap(new LVTemplate(_mapper_id, state_ind())); new_snap->props = new_lv->props; new_snap->props.set(Variable("lvname", - string("new_snapshot"), + String("new_snapshot"), 1, 36, "-?/$%!", @@ -167,7 +167,7 @@ new_snap->content->_avail_replacements.clear(); new_snap->props.set(Variable("snapshot", true)); - list snap_origs; + list snap_origs; for (list >::const_iterator iter = targets.begin(); iter != targets.end(); iter++) @@ -189,7 +189,7 @@ void VG::apply(const MapperParsed& mp) { - string vgname(mp.props.get("vgname").get_string()); + String vgname(mp.props.get("vgname").get_string()); // clustered bool clustered_old = _props.get("clustered").get_bool(); @@ -206,7 +206,7 @@ !LVM::clustered_available()) throw ClvmdError(); - string vgname; + String vgname; try { vgname = _props.get("vgname").get_string(); } catch ( ... ) {} @@ -214,7 +214,7 @@ try { utils::clear_cache(); - list pv_paths; + list pv_paths; for (list >::const_iterator iter = bds.begin(); iter != bds.end(); iter++) { @@ -251,7 +251,7 @@ !LVM::clustered_available()) throw ClvmdError(); - string vgname = _props.get("vgname").get_string(); + String vgname = _props.get("vgname").get_string(); LVM::vgremove(vgname); for (list >::const_iterator iter = sources.begin(); iter != sources.end(); @@ -267,9 +267,9 @@ { // everything is already validated, but number of sources if (temp.sources.size() == 0) - throw string("create_VG requires at least one source"); + throw String("create_VG requires at least one source"); - string vgname = temp.props.get("vgname").get_string(); + String vgname = temp.props.get("vgname").get_string(); long long extent_size = temp.props.get("extent_size").get_int(); bool clustered = temp.props.get("clustered").get_bool(); @@ -280,7 +280,7 @@ try { utils::clear_cache(); - list pv_paths; + list pv_paths; for (list >::const_iterator iter = temp.sources.begin(); iter != temp.sources.end(); iter++) { @@ -317,17 +317,17 @@ MapperTemplate(MAPPER_VG_TYPE) { // vgname - const list vgids = get_VG_ids(); - list vgnames; - for (list::const_iterator iter = vgids.begin(); + const list vgids = get_VG_ids(); + list vgnames; + for (list::const_iterator iter = vgids.begin(); iter != vgids.end(); iter++) { - string vgname = iter->substr(VG_PREFIX.size()); + String vgname = iter->substr(VG_PREFIX.size()); if (!vgname.empty()) vgnames.push_back(vgname); } Variable vgname("vgname", - string("new_vg"), + String("new_vg"), 1, 36, "-?/$%#", @@ -359,7 +359,7 @@ new_sources.push_back(*iter); if (new_sources.empty()) - throw string("no available new sources"); + throw String("no available new sources"); props.set(Variable("min_sources", (long long) 1)); props.set(Variable("max_sources", (long long) new_sources.size())); } --- conga/ricci/modules/storage/VG.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/VG.h 2006/08/10 22:53:09 1.3 @@ -26,17 +26,17 @@ #include "Mapper.h" #include -#include +#include "String.h" -std::list get_VG_ids(); +std::list get_VG_ids(); counting_auto_ptr create_VG(const MapperTemplate& temp); class VG : public Mapper { public: - VG(const std::string& id); + VG(const String& id); virtual ~VG(); virtual void apply(const MapperParsed&); @@ -48,7 +48,7 @@ private: - std::string _vgname; + String _vgname; }; // VG --- conga/ricci/modules/storage/defines.h 2006/05/16 20:10:39 1.4 +++ conga/ricci/modules/storage/defines.h 2006/08/10 22:53:09 1.5 @@ -24,10 +24,10 @@ #ifndef defines_h #define defines_h -#include +#include "String.h" -static std::string illegal_label_chars("| \\ /?.,"); +static String illegal_label_chars("| \\ /?.,"); @@ -35,56 +35,56 @@ -#define MAPPER_TYPE_TAG std::string("mapper") -#define MAPPER_SYS_TYPE std::string("hard_drives") -#define MAPPER_VG_TYPE std::string("volume_group") -#define MAPPER_PT_TYPE std::string("partition_table") -#define MAPPER_MDRAID_TYPE std::string("mdraid") -#define MAPPER_ATARAID_TYPE std::string("ataraid") -#define MAPPER_MULTIPATH_TYPE std::string("multipath") -#define MAPPER_CRYPTO_TYPE std::string("crypto") -#define MAPPER_iSCSI_TYPE std::string("iSCSI") +#define MAPPER_TYPE_TAG String("mapper") +#define MAPPER_SYS_TYPE String("hard_drives") +#define MAPPER_VG_TYPE String("volume_group") +#define MAPPER_PT_TYPE String("partition_table") +#define MAPPER_MDRAID_TYPE String("mdraid") +#define MAPPER_ATARAID_TYPE String("ataraid") +#define MAPPER_MULTIPATH_TYPE String("multipath") +#define MAPPER_CRYPTO_TYPE String("crypto") +#define MAPPER_iSCSI_TYPE String("iSCSI") -#define MAPPER_TEMPLATE_TYPE_TAG std::string("mapper_template") +#define MAPPER_TEMPLATE_TYPE_TAG String("mapper_template") -#define MAPPER_SOURCES_TAG std::string("sources") -#define MAPPER_TARGETS_TAG std::string("targets") -#define MAPPER_MAPPINGS_TAG std::string("mappings") -#define MAPPER_NEW_SOURCES_TAG std::string("new_sources") -#define MAPPER_NEW_TARGETS_TAG std::string("new_targets") +#define MAPPER_SOURCES_TAG String("sources") +#define MAPPER_TARGETS_TAG String("targets") +#define MAPPER_MAPPINGS_TAG String("mappings") +#define MAPPER_NEW_SOURCES_TAG String("new_sources") +#define MAPPER_NEW_TARGETS_TAG String("new_targets") -#define BD_TYPE_TAG std::string("block_device") -#define BD_HD_TYPE std::string("hard_drive") -#define BD_LV_TYPE std::string("logical_volume") -#define BD_PART_TYPE std::string("partition") -#define BD_MDRAID_TYPE std::string("mdraid_target") +#define BD_TYPE_TAG String("block_device") +#define BD_HD_TYPE String("hard_drive") +#define BD_LV_TYPE String("logical_volume") +#define BD_PART_TYPE String("partition") +#define BD_MDRAID_TYPE String("mdraid_target") -#define BD_TEMPLATE_TYPE_TAG std::string("block_device_template") +#define BD_TEMPLATE_TYPE_TAG String("block_device_template") -#define CONTENT_TYPE_TAG std::string("content") -#define CONTENT_MS_TYPE std::string("mapper_source") -#define CONTENT_FS_TYPE std::string("filesystem") -#define CONTENT_NONE_TYPE std::string("none") -#define CONTENT_UNUSABLE_TYPE std::string("hidden") +#define CONTENT_TYPE_TAG String("content") +#define CONTENT_MS_TYPE String("mapper_source") +#define CONTENT_FS_TYPE String("filesystem") +#define CONTENT_NONE_TYPE String("none") +#define CONTENT_UNUSABLE_TYPE String("hidden") -#define CONTENT_TEMPLATE_TYPE_TAG std::string("content_template") +#define CONTENT_TEMPLATE_TYPE_TAG String("content_template") -#define CONTENT_REPLACEMENTS_TAG std::string("available_contents") -#define CONTENT_NEW_CONTENT_TAG std::string("new_content") +#define CONTENT_REPLACEMENTS_TAG String("available_contents") +#define CONTENT_NEW_CONTENT_TAG String("new_content") -#define SOURCE_PV_TYPE std::string("physical_volume") -#define SOURCE_PT_TYPE std::string("partition_table_source") -#define SOURCE_MDRAID_TYPE std::string("mdraid_source") +#define SOURCE_PV_TYPE String("physical_volume") +#define SOURCE_PT_TYPE String("partition_table_source") +#define SOURCE_MDRAID_TYPE String("mdraid_source") -#define LVM_BIN_PATH std::string("/sbin/lvm") +#define LVM_BIN_PATH String("/sbin/lvm") #define SYS_PREFIX (MAPPER_SYS_TYPE + ":") @@ -94,13 +94,13 @@ -#define REQUEST_TAG std::string("request") -#define RESPONSE_TAG std::string("response") -#define SEQUENCE_TAG std::string("sequence") +#define REQUEST_TAG String("request") +#define RESPONSE_TAG String("response") +#define SEQUENCE_TAG String("sequence") -#define FUNC_CALL_TAG std::string("function_call") -#define FUNC_RESPONSE_TAG std::string("function_response") +#define FUNC_CALL_TAG String("function_call") +#define FUNC_RESPONSE_TAG String("function_response") --- conga/ricci/modules/storage/main.cpp 2006/04/07 16:42:40 1.2 +++ conga/ricci/modules/storage/main.cpp 2006/08/10 22:53:09 1.3 @@ -32,7 +32,7 @@ try { StorageModule m; return stdin_out_module_driver(m); - } catch (string e) { + } catch (String e) { cerr << e << endl; return 1; } --- conga/ricci/modules/storage/mdadm_wrapper.cpp 2006/05/16 20:12:00 1.3 +++ conga/ricci/modules/storage/mdadm_wrapper.cpp 2006/08/10 22:53:09 1.4 @@ -25,7 +25,7 @@ #include "utils.h" -#define MDADM_BIN_PATH string("/sbin/mdadm") +#define MDADM_BIN_PATH String("/sbin/mdadm") #include @@ -33,11 +33,11 @@ static list probe_raids(); -static list probe_sources(vector paths); -static pair > probe_source(const string& path); +static list probe_sources(vector paths); +static pair > probe_source(const String& path); -mdraid_source::mdraid_source(const std::string& path, +mdraid_source::mdraid_source(const String& path, mdraid_source_type type) : path(path), type(type) @@ -51,10 +51,10 @@ -std::list +std::list mdadm::valid_raid_levels() { - list levels; + list levels; levels.push_back("raid5"); levels.push_back("raid1"); return levels; @@ -71,7 +71,7 @@ } mdraid -mdadm::probe_path(const std::string& path) +mdadm::probe_path(const String& path) { list raids = mdadm::raids(); @@ -89,122 +89,122 @@ return *iter; } - throw string("not mdraid path"); + throw String("not mdraid path"); } void -mdadm::remove_source(const std::string& raid_path, - const std::string& path) +mdadm::remove_source(const String& raid_path, + const String& path) { - vector args; + vector args; args.push_back(raid_path); args.push_back("--remove"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); utils::clear_cache(); zero_superblock(path); } void -mdadm::zero_superblock(const std::string& path) +mdadm::zero_superblock(const String& path) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("--zero-superblock"); args.push_back(path); if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); utils::clear_cache(); } void -mdadm::add_source(const std::string& raid_path, - const std::string& path) +mdadm::add_source(const String& raid_path, + const String& path) { - vector args; + vector args; args.push_back(raid_path); args.push_back("--add"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); utils::clear_cache(); } void -mdadm::fail_source(const std::string& raid_path, - const std::string& path) +mdadm::fail_source(const String& raid_path, + const String& path) { - vector args; + vector args; args.push_back(raid_path); args.push_back("--fail"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); utils::clear_cache(); } void mdadm::start_raid(const mdraid& raid) { - vector args; + vector args; args.push_back("--assemble"); args.push_back(raid.path); for (list::const_iterator iter = raid.devices.begin(); iter != raid.devices.end(); iter++) args.push_back(iter->path); - string out, err; + String out, err; int status; if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); utils::clear_cache(); } void mdadm::stop_raid(const mdraid& raid) { - vector args; + vector args; args.push_back("--stop"); args.push_back(raid.path); - string out, err; + String out, err; int status; if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); utils::clear_cache(); } -string -mdadm::create_raid(const string& level, - const list& dev_paths) +String +mdadm::create_raid(const String& level, + const list& dev_paths) { - string md_path_templ = "/dev/md"; - string new_md_path = md_path_templ; + String md_path_templ = "/dev/md"; + String new_md_path = md_path_templ; list raids = mdadm::raids(); for (long long i=1; i<30; i++) { - string tmp_path = md_path_templ + utils::to_string(i); + String tmp_path = md_path_templ + utils::to_string(i); bool found = false; for (list::const_iterator iter = raids.begin(); iter != raids.end(); @@ -217,25 +217,25 @@ } } if (new_md_path == md_path_templ) - throw string("no more raid devices allowed"); + throw String("no more raid devices allowed"); - list::size_type raid_devices = 3; + list::size_type raid_devices = 3; if (level == "raid1") raid_devices = 2; else if (level == "raid5") raid_devices = 3; else - throw string("unsupported raid level"); + throw String("unsupported raid level"); raid_devices = (raid_devices < dev_paths.size()) ? dev_paths.size() : raid_devices; - vector args; + vector args; args.push_back("--create"); args.push_back(new_md_path); args.push_back("-R"); - args.push_back(string("--level=") + level); - args.push_back(string("--raid-devices=") + utils::to_string((long long) raid_devices)); - args.push_back(string("--spare-devices=0")); - for (list::const_iterator iter = dev_paths.begin(); + args.push_back(String("--level=") + level); + args.push_back(String("--raid-devices=") + utils::to_string((long long) raid_devices)); + args.push_back(String("--spare-devices=0")); + for (list::const_iterator iter = dev_paths.begin(); iter != dev_paths.end(); iter++) args.push_back(*iter); @@ -244,12 +244,12 @@ i++) args.push_back("missing"); - string out, err; + String out, err; int status; if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); utils::clear_cache(); return new_md_path; @@ -263,27 +263,27 @@ list probe_raids() { - vector args; + vector args; args.push_back("--examine"); args.push_back("--scan"); args.push_back("--brief"); args.push_back("--config=partitions"); - string out, err; + String out, err; int status; if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); // remove '\n' - string::size_type i = 0; + String::size_type i = 0; while ((i = out.find('\n', i)) != out.npos) out.replace(i, 1, " "); list raids; - vector words = utils::split(utils::strip(out)); - for (vector::iterator iter = words.begin(); + vector words = utils::split(utils::strip(out)); + for (vector::iterator iter = words.begin(); iter != words.end(); iter++) { if (iter->empty()) @@ -299,14 +299,14 @@ if ((*iter)[0] == '/') raid.path = *iter; else if (iter->find("level=") == 0) - raid.level = iter->substr(string("level=").size()); + raid.level = iter->substr(String("level=").size()); else if (iter->find("num-devices=") == 0) - raid.num_devices = utils::to_long(iter->substr(string("num-devices=").size())); + raid.num_devices = utils::to_long(iter->substr(String("num-devices=").size())); else if (iter->find("UUID=") == 0) - raid.uuid = iter->substr(string("UUID=").size()); + raid.uuid = iter->substr(String("UUID=").size()); else if (iter->find("devices=") == 0) { - string devices = iter->substr(string("devices=").size()); - vector devs = utils::split(devices, ","); + String devices = iter->substr(String("devices=").size()); + vector devs = utils::split(devices, ","); raid.devices = probe_sources(devs); } } @@ -314,8 +314,8 @@ for (list::iterator iter = raids.begin(); iter != raids.end(); iter++) { - string path = iter->path; - iter->name = path.replace(0, string("/dev/").size(), ""); + String path = iter->path; + iter->name = path.replace(0, String("/dev/").size(), ""); } return raids; @@ -324,17 +324,17 @@ list -probe_sources(vector paths) +probe_sources(vector paths) { list devs; - string date("0000"); + String date("0000"); list probed_sources; - for (vector::const_iterator iter = paths.begin(); + for (vector::const_iterator iter = paths.begin(); iter != paths.end(); iter++) { - pair > tmp = + pair > tmp = probe_source(*iter); if (tmp.first > date) { date = tmp.first; @@ -342,7 +342,7 @@ } } - for (vector::const_iterator path_iter = paths.begin(); + for (vector::const_iterator path_iter = paths.begin(); path_iter != paths.end(); path_iter++) { bool path_found = false; @@ -360,30 +360,30 @@ return devs; } -pair > -probe_source(const string& path) +pair > +probe_source(const String& path) { - vector args; + vector args; args.push_back("--examine"); args.push_back(path); - string out, err; + String out, err; int status; if (utils::execute(MDADM_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("mdadm failed"); + throw String("mdadm failed"); - string update_time; + String update_time; list devs; bool devs_section = false; - vector lines = utils::split(utils::strip(out), "\n"); - for (vector::iterator iter = lines.begin(); + vector lines = utils::split(utils::strip(out), "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - string& line = *iter; - vector words = utils::split(utils::strip(line)); + String& line = *iter; + vector words = utils::split(utils::strip(line)); if (words.empty()) continue; @@ -401,10 +401,10 @@ if (words.size() < 8) continue; if (words[0] == "Update" && words[1] == "Time") { - string month = words[4]; - string day = words[5]; - string time = words[6]; - string year = words[7]; + String month = words[4]; + String day = words[5]; + String time = words[6]; + String year = words[7]; if (month == "Jan") month = "01"; else if (month == "Feb") month = "02"; @@ -422,9 +422,9 @@ if (day.size() == 1) day = "0" + day; - vector time_words = utils::split(time, ":"); + vector time_words = utils::split(time, ":"); if (time_words.size() != 3) - throw string("invalid mdadm output"); + throw String("invalid mdadm output"); if (time_words[0].size() == 1) time_words[0] = "0" + time_words[0]; if (time_words[1].size() == 1) time_words[1] = "0" + time_words[1]; if (time_words[2].size() == 1) time_words[2] = "0" + time_words[2]; @@ -435,6 +435,6 @@ } - return pair >(update_time, + return pair >(update_time, devs); } --- conga/ricci/modules/storage/mdadm_wrapper.h 2006/05/16 20:12:00 1.2 +++ conga/ricci/modules/storage/mdadm_wrapper.h 2006/08/10 22:53:09 1.3 @@ -24,7 +24,7 @@ #ifndef mdadm_wrapper_h #define mdadm_wrapper_h -#include +#include "String.h" #include #include @@ -37,10 +37,10 @@ class mdraid_source { public: - mdraid_source(const std::string& path, + mdraid_source(const String& path, mdraid_source_type type); - std::string path; + String path; mdraid_source_type type; }; @@ -52,11 +52,11 @@ public: mdraid(); - std::string path; - std::string name; + String path; + String name; - std::string level; - std::string uuid; + String level; + String uuid; long long num_devices; std::list devices; @@ -69,25 +69,25 @@ { public: - static std::list valid_raid_levels(); + static std::list valid_raid_levels(); static std::list raids(); - static mdraid probe_path(const std::string& path); + static mdraid probe_path(const String& path); - static void add_source(const std::string& raid_path, - const std::string& path); - static void fail_source(const std::string& raid_path, - const std::string& path); - static void remove_source(const std::string& raid_path, - const std::string& path); - static void zero_superblock(const std::string& path); + static void add_source(const String& raid_path, + const String& path); + static void fail_source(const String& raid_path, + const String& path); + static void remove_source(const String& raid_path, + const String& path); + static void zero_superblock(const String& path); static void start_raid(const mdraid& raid); static void stop_raid(const mdraid& raid); - static std::string create_raid(const std::string& level, - const std::list& dev_paths); + static String create_raid(const String& level, + const std::list& dev_paths); }; // class mdadm --- conga/ricci/modules/storage/parted_wrapper.cpp 2006/05/26 19:28:51 1.5 +++ conga/ricci/modules/storage/parted_wrapper.cpp 2006/08/10 22:53:09 1.6 @@ -29,24 +29,24 @@ using namespace std; -#define PARTED_BIN_PATH string("/sbin/parted") +#define PARTED_BIN_PATH String("/sbin/parted") static void fill_gaps(int types, - const std::string& label, + const String& label, long long min_part_size, list& parts, long long begin, long long end); static list -plain_partitions(const std::string& path, - string& label, +plain_partitions(const String& path, + String& label, long long& disk_size); static void -__create_label(const std::string& path, const string& label); +__create_label(const String& path, const String& label); static long long -parted_size_to_bytes(const string& size_str); +parted_size_to_bytes(const String& size_str); @@ -56,7 +56,7 @@ long long end, bool bootable, PPType type, - const std::string& label) : + const String& label) : _partnum(partnum), _beg(beg), _end(end), @@ -68,7 +68,7 @@ PartedPartition::PartedPartition(long long beg, long long end, PPType available_types, - const std::string& label) : + const String& label) : _beg(beg), _end(end), _bootable(false), @@ -96,7 +96,7 @@ PartedPartition::partnum() const { if (unused_space()) - throw string("partnum(): unused space???"); + throw String("partnum(): unused space???"); return _partnum; } @@ -106,7 +106,7 @@ return _bootable; } -std::string +String PartedPartition::type() const { switch (_type) { @@ -119,10 +119,10 @@ case PPTunused: return "unused"; } - throw string("invalid partition type"); + throw String("invalid partition type"); } -std::string +String PartedPartition::label() const { return _label; @@ -159,7 +159,7 @@ _kids.push_back(part); _kids.sort(); } else - throw string("PartedPartition.add_kid() error"); + throw String("PartedPartition.add_kid() error"); } const list& @@ -181,14 +181,14 @@ } void -PartedPartition::print(const string& indent) const +PartedPartition::print(const String& indent) const { cout << indent << "num" << (unused_space()) ? 100000LL : partnum(); cout << " beg" << begin(); cout << " size" << size(); cout << " boot" << bootable(); - string t = "selection"; + String t = "selection"; try { t = type(); } catch ( ... ) {} @@ -208,8 +208,8 @@ // ##### Parted ##### -std::string -Parted::extract_pt_path(const std::string& path) +String +Parted::extract_pt_path(const String& path) { if (path.find("/dev/cciss/") != path.npos) { unsigned int p_pos = path.find("p"); @@ -222,11 +222,11 @@ return path.substr(0, i+1); } -std::string -Parted::generate_part_path(const std::string& pt_path, const PartedPartition& part) +String +Parted::generate_part_path(const String& pt_path, const PartedPartition& part) { if (part.unused_space()) - throw string("generate_part_path(): unused space???"); + throw String("generate_part_path(): unused space???"); if (pt_path.find("/dev/cciss/") != pt_path.npos) return pt_path + "p" + utils::to_string(part.partnum()); else @@ -237,30 +237,30 @@ list -plain_partitions(const std::string& path, - string& label, +plain_partitions(const String& path, + String& label, long long& disk_size) { list parts; label = ""; disk_size = 0; - vector args; + vector args; args.push_back(path); args.push_back("print"); args.push_back("-s"); - string out, err; + String out, err; int status; if (utils::execute(PARTED_BIN_PATH, args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("parted failed") + " " + path; + throw String("parted failed") + " " + path; - vector lines = utils::split(utils::strip(out), "\n"); - for (vector::iterator iter = lines.begin(); + vector lines = utils::split(utils::strip(out), "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - vector words = utils::split(utils::strip(*iter)); + vector words = utils::split(utils::strip(*iter)); if (words.size() < 3) continue; if (words[0] == "Disk" && words[1] == "label" && words[2] == "type:") { @@ -268,8 +268,8 @@ continue; } if (words[0] == "Disk" && words[1] == "geometry" && words[5] == "megabytes") { - string size = words[4]; - string::size_type idx = size.find("-"); + String size = words[4]; + String::size_type idx = size.find("-"); if (idx != size.npos) { size = size.substr(idx + 1); disk_size = utils::to_long(size) * 1024 * 1024; @@ -283,7 +283,7 @@ long long end = parted_size_to_bytes(words[2]); bool bootable = false; PPType type = PPTprimary; - for (vector::iterator word_iter = words.begin(); + for (vector::iterator word_iter = words.begin(); word_iter != words.end(); word_iter++) { if (*word_iter == "boot") @@ -304,7 +304,7 @@ } if (label.empty() || label == "loop") - throw string("not a partition table"); + throw String("not a partition table"); return parts; } @@ -314,10 +314,10 @@ // return label & partitions -pair > -Parted::partitions(const std::string& path) +pair > +Parted::partitions(const String& path) { - string label; + String label; long long disk_size; list parts = plain_partitions(path, label, disk_size); @@ -383,12 +383,12 @@ iter->print("\t"); */ - return pair >(label, sorted); + return pair >(label, sorted); } void fill_gaps(int types, - const std::string& label, + const String& label, long long min_part_size, list& parts, long long begin, @@ -442,28 +442,28 @@ -std::list +std::list Parted::possible_paths() { - list hds; + list hds; // parse blockdev - vector args; + vector args; args.push_back("--report"); - string out, err; + String out, err; int status; if (utils::execute("/sbin/blockdev", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("blockdev failed"); - vector lines = utils::split(out, "\n"); - for (vector::iterator iter = lines.begin(); + throw String("blockdev failed"); + vector lines = utils::split(out, "\n"); + for (vector::iterator iter = lines.begin(); iter != lines.end(); iter++) { - vector words = utils::split(utils::strip(*iter)); + vector words = utils::split(utils::strip(*iter)); if (words.size() != 7 || words[0] == "RO") continue; - string path = words[6]; + String path = words[6]; if (path == Parted::extract_pt_path(path)) hds.push_back(path); @@ -473,10 +473,10 @@ } -std::list +std::list Parted::supported_labels() { - list labels; + list labels; labels.push_back("bsd"); labels.push_back("gpt"); // labels.push_back("mac"); @@ -490,31 +490,31 @@ void -__create_label(const std::string& path, const string& label) +__create_label(const String& path, const String& label) { if (Parted::extract_pt_path(path) != path) - throw string("partition table on partition??? Not for now :("); + throw String("partition table on partition??? Not for now :("); - list labels = Parted::supported_labels(); + list labels = Parted::supported_labels(); if (find(labels.begin(), labels.end(), label) == labels.end()) - throw string("unsuported label type"); + throw String("unsuported label type"); // create label - vector args; + vector args; args.push_back("-s"); args.push_back(path); args.push_back("mklabel"); args.push_back(label); - string out, err; + String out, err; int status; if (utils::execute(PARTED_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("parted failed"); + throw String("parted failed"); } void -Parted::create_label(const std::string& path, const string& label) +Parted::create_label(const String& path, const String& label) { // don't overwrite existing label bool in_use = false; @@ -523,67 +523,67 @@ in_use = true; } catch ( ... ) {} if (in_use) - throw string(path + " already has a partition table"); + throw String(path + " already has a partition table"); // create label __create_label(path, label); } void -Parted::remove_label(const std::string& path) +Parted::remove_label(const String& path) { __create_label(path, "msdos"); - vector args; - string out, err; + vector args; + String out, err; int status; args.push_back("if=/dev/zero"); - args.push_back(string("of=") + path); + args.push_back(String("of=") + path); args.push_back("bs=1"); args.push_back("seek=447"); args.push_back("count=64"); if (utils::execute("/bin/dd", args, out, err, status)) - throw string("execute failed"); + throw String("execute failed"); if (status != 0) - throw string("dd failed"); + throw String("dd failed"); utils::clear_cache(); } long long -Parted::min_part_size(const std::string& label) +Parted::min_part_size(const String& label) { return 2 * 1024 * 1024; // 2 MB // FIXME } -string -Parted::create_partition(const std::string& pt_path, - const std::string& part_type, +String +Parted::create_partition(const String& pt_path, + const String& part_type, long long seg_begin, long long size) { - string aaa; + String aaa; long long bbb; list parts = plain_partitions(pt_path, aaa, bbb); seg_begin = seg_begin / 1024 / 1024; long long seg_end = seg_begin + size / 1024 / 1024; - vector args; + vector args; args.push_back("-s"); args.push_back(pt_path); args.push_back("mkpart"); args.push_back(part_type); args.push_back(utils::to_string(seg_begin)); args.push_back(utils::to_string(seg_end)); - string out, err; + String out, err; int status; if (utils::execute(PARTED_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("parted failed"); + throw String("parted failed"); utils::clear_cache(); @@ -609,39 +609,39 @@ return generate_part_path(pt_path, *iter_n); } - throw string("partition creation failed"); + throw String("partition creation failed"); } void -Parted::remove_partition(const std::string& pt_path, +Parted::remove_partition(const String& pt_path, const PartedPartition& partition) { - vector args; + vector args; args.push_back("-s"); args.push_back(pt_path); args.push_back("rm"); args.push_back(utils::to_string(partition.partnum())); - string out, err; + String out, err; int status; if (utils::execute(PARTED_BIN_PATH, args, out, err, status, false)) - throw string("execute failed"); + throw String("execute failed"); if (status) - throw string("parted failed"); + throw String("parted failed"); utils::clear_cache(); } long long -parted_size_to_bytes(const string& size_str) +parted_size_to_bytes(const String& size_str) { - string s = utils::to_lower(utils::strip(size_str)); + String s = utils::to_lower(utils::strip(size_str)); long long multiplier; if (s.find("b") == s.npos) multiplier = 1024 * 1024; // by old parted behavior. size is in MB else { if (s.size() < 3) - throw string("parted size has an invalid value: ") + s; + throw String("parted size has an invalid value: ") + s; multiplier = 1; if (s[s.size()-2] == 'k') multiplier = 1024; --- conga/ricci/modules/storage/parted_wrapper.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/modules/storage/parted_wrapper.h 2006/08/10 22:53:09 1.3 @@ -24,7 +24,7 @@ #ifndef parted_wrapper_h #define parted_wrapper_h -#include +#include "String.h" #include @@ -42,12 +42,12 @@ long long end, bool bootable, PPType type, - const std::string& label); + const String& label); // unused PartedPartition(long long beg, long long end, PPType available_types, - const std::string& label); + const String& label); virtual ~PartedPartition(); long long begin() const; @@ -55,8 +55,8 @@ int partnum() const; bool bootable() const; - std::string type() const; - std::string label() const; + String type() const; + String label() const; bool unused_space() const; @@ -73,7 +73,7 @@ bool operator<(const PartedPartition&) const; - void print(const std::string& indent) const; + void print(const String& indent) const; private: @@ -82,7 +82,7 @@ long long _end; bool _bootable; PPType _type; - std::string _label; + String _label; std::list _kids; @@ -94,30 +94,30 @@ { public: - static std::string extract_pt_path(const std::string& path); - static std::string generate_part_path(const std::string& pt_path, + static String extract_pt_path(const String& path); + static String generate_part_path(const String& pt_path, const PartedPartition& part); - static std::list possible_paths(); + static std::list possible_paths(); - static std::list supported_labels(); + static std::list supported_labels(); - static long long min_part_size(const std::string& label); + static long long min_part_size(const String& label); - static std::pair > - partitions(const std::string& pt_path); + static std::pair > + partitions(const String& pt_path); - static void create_label(const std::string& path, const std::string& label); - static void remove_label(const std::string& path); + static void create_label(const String& path, const String& label); + static void remove_label(const String& path); // return path of new partition - static std::string create_partition(const std::string& pt_path, - const std::string& part_type, + static String create_partition(const String& pt_path, + const String& part_type, long long seg_begin, long long size); - static void remove_partition(const std::string& pt_path, + static void remove_partition(const String& pt_path, const PartedPartition& partition); --- conga/ricci/ricci/Auth.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/ricci/Auth.cpp 2006/08/10 22:53:09 1.3 @@ -55,21 +55,21 @@ bool -Auth::authenticate(const std::string& passwd) const +Auth::authenticate(const String& passwd) const { if (access(_path.c_str(), X_OK)) - throw string("missing auth helper"); + throw String("missing auth helper"); int _stdin_pipe[2]; if (pipe(_stdin_pipe) == -1) - throw string("failure creating pipe"); + throw String("failure creating pipe"); int pid = fork(); if (pid == -1) { close_fd(_stdin_pipe[0]); close_fd(_stdin_pipe[1]); - throw string("fork failed"); + throw String("fork failed"); } if (pid == 0) { @@ -100,7 +100,7 @@ close_fd(_stdin_pipe[0]); try { - string pass = passwd + "\n"; + String pass = passwd + "\n"; do { int size = write(_stdin_pipe[1], pass.c_str(), pass.size()); if (size == -1) { @@ -108,7 +108,7 @@ continue; else { cout << errno << endl; - throw string("write() error"); + throw String("write() error"); } } pass = pass.substr(size, pass.npos); --- conga/ricci/ricci/Auth.h 2006/03/06 21:48:05 1.1 +++ conga/ricci/ricci/Auth.h 2006/08/10 22:53:09 1.2 @@ -24,7 +24,7 @@ #ifndef Auth_h #define Auth_h -#include +#include "String.h" class Auth @@ -33,10 +33,10 @@ Auth(); virtual ~Auth(); - bool authenticate(const std::string& passwd) const; + bool authenticate(const String& passwd) const; private: - std::string _path; + String _path; }; --- conga/ricci/ricci/ClientInstance.cpp 2006/06/09 16:32:19 1.6 +++ conga/ricci/ricci/ClientInstance.cpp 2006/08/10 22:53:09 1.7 @@ -66,7 +66,7 @@ if (max_reached) { // socket is non-blocking, couple bytes should be able to go out, if not, who cares sock.send("overload - come back later"); - throw string("maximum number of clients reached"); + throw String("maximum number of clients reached"); } } @@ -103,7 +103,7 @@ try { send(XMLObject("Clients_SSL_certificate_required")); } catch ( ... ) {} - throw string("client hasn't presented certificate"); + throw String("client hasn't presented certificate"); } bool authed = _ssl.client_cert_authed(); @@ -121,7 +121,7 @@ request = receive(); } catch ( ... ) { try { - string out = "Timeout_reached_without_valid_XML_request"; + String out = "Timeout_reached_without_valid_XML_request"; send(XMLObject(out)); } catch ( ... ) {} throw; @@ -142,7 +142,7 @@ send(response); } send(XMLObject("bye")); - } catch ( string e ) { + } catch ( String e ) { cout << "exception: " << e << endl; } catch ( ... ) { cout << "unknown exception" << endl; @@ -161,12 +161,12 @@ ClientInstance::receive() { int beg = int(time_sec()); - string xml_in; + String xml_in; while (true) { if (shouldStop()) - throw string("thread exiting"); + throw String("thread exiting"); else if (int(time_sec()) > beg + RECEIVE_TIMEOUT) - throw string("Receive timeout"); + throw String("Receive timeout"); else xml_in += _ssl.recv(500); try { @@ -179,12 +179,12 @@ ClientInstance::send(const XMLObject& msg) { int beg = int(time_sec()); - string out(generateXML(msg)); + String out(generateXML(msg)); while (true) { if (shouldStop()) - throw string("thread exiting"); + throw String("thread exiting"); else if (int(time_sec()) > beg + SEND_TIMEOUT) - throw string("Send timeout"); + throw String("Send timeout"); else if ((out = _ssl.send(out, 500)).empty()) break; @@ -198,21 +198,21 @@ int beg = int(time_sec()); while (true) { if (shouldStop()) - throw string("thread exiting"); + throw String("thread exiting"); else if (int(time_sec()) > beg + ACCEPT_TIMEOUT) - throw string("Accept timeout"); + throw String("Accept timeout"); else if (_ssl.accept(500)) break; } } catch ( ... ) { int beg = int(time_sec()); - string out(generateXML(XMLObject("SSL_required"))); + String out(generateXML(XMLObject("SSL_required"))); while (true) { if (shouldStop()) - throw string("thread exiting"); + throw String("thread exiting"); else if (int(time_sec()) > beg + SEND_TIMEOUT) - throw string("Send timeout"); + throw String("Send timeout"); else { bool read = false, write = true; _ssl.socket().ready(read, write, 500); --- conga/ricci/ricci/DBusController.cpp 2006/07/28 17:33:37 1.14 +++ conga/ricci/ricci/DBusController.cpp 2006/08/10 22:53:09 1.15 @@ -25,7 +25,7 @@ #include "Mutex.h" #include "utils.h" -#include +#include "String.h" #include @@ -68,7 +68,7 @@ if (dbus_error_is_set(&error) || !_dbus_conn) { dbus_error_free(&error); _dbus_conn = 0; - throw string("failed to get system bus connection"); + throw String("failed to get system bus connection"); } else dbus_error_free(&error); } @@ -95,24 +95,24 @@ } -static string -remove_chars(const string& str, char c) +static String +remove_chars(const String& str, char c) { - string s(str); - string::size_type pos; + String s(str); + String::size_type pos; while ((pos = s.find(c)) != s.npos) s.erase(pos, 1); return s; } -string -DBusController::process(const std::string& message, - const std::string& module_name) +String +DBusController::process(const String& message, + const String& module_name) { MutexLocker l(_dbus_mutex); if (_mod_map.find(module_name) == _mod_map.end()) - throw string("module not supported"); + throw String("module not supported"); // prepare msg DBusMessage* msg = dbus_message_new_method_call("com.redhat.ricci", @@ -120,9 +120,9 @@ "com.redhat.ricci", _mod_map[module_name].c_str()); if (!msg) - throw string("not enough memory to create message"); + throw String("not enough memory to create message"); if (message.size()) { - string msg_clean(remove_chars(message, '\n')); + String msg_clean(remove_chars(message, '\n')); const char* msg_clean_c_str = msg_clean.c_str(); const void* message_dbus_ready = 0; @@ -137,7 +137,7 @@ if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, message_dbus_ready, DBUS_TYPE_INVALID)) - throw string("error appending argument to message"); + throw String("error appending argument to message"); } @@ -165,11 +165,11 @@ DBUS_TYPE_INVALID); if (status) { - string e("module returned error code: "); + String e("module returned error code: "); e += err; throw e; } - string ret(out); + String ret(out); dbus_message_unref(resp); return ret; } catch ( ... ) { @@ -177,17 +177,17 @@ throw; } } else { - string error_msg(error.message); + String error_msg(error.message); dbus_error_free(&error); - throw string("response msg error: ") + error_msg; + throw String("response msg error: ") + error_msg; } } -list +list DBusController::modules() { - list mods; - for (map::const_iterator iter = _mod_map.begin(); + list mods; + for (map::const_iterator iter = _mod_map.begin(); iter != _mod_map.end(); iter++) mods.push_back(iter->first); --- conga/ricci/ricci/DBusController.h 2006/07/25 19:30:15 1.5 +++ conga/ricci/ricci/DBusController.h 2006/08/10 22:53:09 1.6 @@ -25,7 +25,7 @@ #define DBusController_h #include "XML.h" -#include +#include "String.h" // thread safe @@ -40,13 +40,13 @@ DBusController(); virtual ~DBusController(); - std::string process(const std::string& message, - const std::string& module_name); + String process(const String& message, + const String& module_name); - std::list modules(); // available modules + std::list modules(); // available modules private: - std::map _mod_map; + std::map _mod_map; }; --- conga/ricci/ricci/QueueLocker.cpp 2006/06/19 21:21:54 1.2 +++ conga/ricci/ricci/QueueLocker.cpp 2006/08/10 22:53:09 1.3 @@ -29,7 +29,7 @@ #include -#include +#include "String.h" using namespace std; @@ -50,7 +50,7 @@ S_IRUSR|S_IWUSR|S_IRGRP); if (fd == -1) - throw string("unable to open queue lock file"); + throw String("unable to open queue lock file"); // acquire flock int res; @@ -58,8 +58,8 @@ if (errno != EINTR) { while ((res = close(fd))) if (errno != EINTR) - throw string("unable to close the queue lock file"); - throw string("unable to lock the queue"); + throw String("unable to close the queue lock file"); + throw String("unable to lock the queue"); } } catch ( ... ) { q_counter--; @@ -76,8 +76,8 @@ if (errno != EINTR) { while ((res = flock(fd, LOCK_UN))) if (errno != EINTR) - break; // throw string("unable to unlock the queue"); - break; // throw string("unable to close the queue lock file"); + break; // throw String("unable to unlock the queue"); + break; // throw String("unable to close the queue lock file"); } } } --- conga/ricci/ricci/Ricci.cpp 2006/07/20 08:29:49 1.14 +++ conga/ricci/ricci/Ricci.cpp 2006/08/10 22:53:09 1.15 @@ -43,9 +43,9 @@ using namespace std; -static string hostname(); -static pair clusterinfo(); -static string os_release(); +static String hostname(); +static pair clusterinfo(); +static String os_release(); @@ -69,18 +69,18 @@ header.set_attr("authenticated", "false"); if (full) { - string name = hostname(); + String name = hostname(); if (name.size()) header.set_attr("hostname", name); - pair c_info = clusterinfo(); + pair c_info = clusterinfo(); if (c_info.first.size()) header.set_attr("clustername", c_info.first); if (c_info.second.size()) header.set_attr("clusteralias", c_info.second); if (authed) { - string os = os_release(); + String os = os_release(); if (os.size()) header.set_attr("os", os); } @@ -115,7 +115,7 @@ XMLObject resp = ricci_header(authenticated); // version check - string version = req.get_attr("version"); + String version = req.get_attr("version"); if (version.empty()) { resp.set_attr("success", utils::to_string(RRC_MISSING_VERSION)); return resp; @@ -126,12 +126,12 @@ RicciRetCode success = RRC_INTERNAL_ERROR; - string function = req.get_attr("function"); + String function = req.get_attr("function"); if (function == "") { success = RRC_MISSING_FUNCTION; } else if (function == "authenticate") { - string passwd = req.get_attr("password"); + String passwd = req.get_attr("password"); bool passwd_ok = false; if (passwd.size()) { try { @@ -169,8 +169,8 @@ success = RRC_NEED_AUTH; } else { // authenticated - list modules = _dbus.modules(); - for (list::const_iterator iter = modules.begin(); + list modules = _dbus.modules(); + for (list::const_iterator iter = modules.begin(); iter != modules.end(); iter++) { XMLObject x("module"); @@ -270,17 +270,17 @@ QueueLocker lock; // id - string path_tmp; + String path_tmp; do { _id = random_generator(1, 2147483647); - _path = string(QUEUE_DIR_PATH) + utils::to_string(_id); + _path = String(QUEUE_DIR_PATH) + utils::to_string(_id); path_tmp = _path + ".tmp"; if (access(_path.c_str(), F_OK)) break; } while (true); // generate request - for (map::const_iterator iter = xml.attrs().begin(); + for (map::const_iterator iter = xml.attrs().begin(); iter != xml.attrs().end(); iter++) _report.set_attr(iter->first, iter->second); @@ -300,26 +300,26 @@ O_RDONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP); if (fd == -1) - throw string("unable to create batch file"); + throw String("unable to create batch file"); while ((res = close(fd))) if (errno != EINTR) - throw string("unable to close batch fd"); + throw String("unable to close batch fd"); // write file FILE* file = fopen(path_tmp.c_str(), "w+"); if (!file) - throw string("unable to open batch file"); + throw String("unable to open batch file"); try { // save request - string xml_str(generateXML(_report)); + String xml_str(generateXML(_report)); if (fwrite(xml_str.c_str(), xml_str.size(), 1, file) != 1) - throw string("unable to write batch request"); + throw String("unable to write batch request"); fclose(file); if (rename(path_tmp.c_str(), _path.c_str())) - throw string("failed to rename batch file"); + throw String("failed to rename batch file"); } catch ( ... ) { fclose(file); unlink(path_tmp.c_str()); @@ -339,21 +339,22 @@ { QueueLocker lock; - string batch; + String batch; // read file - _path = string(QUEUE_DIR_PATH) + utils::to_string(_id); + _path = String(QUEUE_DIR_PATH) + utils::to_string(_id); FILE* file = fopen(_path.c_str(), "r"); if (!file) - throw string("unable to open batch file, either invalid ID or access denied"); + throw String("unable to open batch file, either invalid ID or access denied"); try { do { char buff[1024]; unsigned int res = fread(buff, 1, sizeof(buff), file); batch.append(buff, res); + shred(buff, sizeof(buff)); if (res < sizeof(buff)) { if (ferror(file)) - throw string("unable to read batch file"); + throw String("unable to read batch file"); else break; } @@ -366,7 +367,7 @@ _report = parseXML(batch); if (utils::to_long(_report.get_attr("batch_id")) != _id) - throw string("ID doesn't match"); + throw String("ID doesn't match"); _state = utils::to_long(_report.get_attr("status")); } @@ -374,8 +375,24 @@ { QueueLocker lock; if (_state != ProcessWorker::st_sched && - _state != ProcessWorker::st_prog) + _state != ProcessWorker::st_prog) { + // shred file: + // should use random source (paranoid) + // doesn't work on journaled fss anyways + ifstream is(_path.c_str()); + is.seekg(0, ios::end); + unsigned int length = is.tellg(); + is.close(); + + String t(length + 10, 'o'); + ofstream os(_path.c_str()); + os.seekp(0); + os << t; + os.close(); + + // remove file unlink(_path.c_str()); + } } long long @@ -407,11 +424,11 @@ void -Batch::start_worker(const std::string& path) +Batch::start_worker(const String& path) { - string out, err; + String out, err; int status; - vector args; + vector args; args.push_back("-f"); args.push_back(path); if (utils::execute(RICCI_WORKER_PATH, @@ -420,9 +437,9 @@ err, status, false)) - throw string("execution of ricci-worker failed"); + throw String("execution of ricci-worker failed"); if (status) - throw string("execution of ricci-worker failed"); + throw String("execution of ricci-worker failed"); } void @@ -431,15 +448,15 @@ QueueLocker lock; DIR* dir = opendir(QUEUE_DIR_PATH); if (!dir) - throw string("unable to open queue directory"); + throw String("unable to open queue directory"); struct dirent* file_entry; while ((file_entry = readdir(dir))) try { - string name(file_entry->d_name); + String name(file_entry->d_name); // check name if (name.find_first_not_of("0123456789") == name.npos) // start worker - start_worker(string(QUEUE_DIR_PATH) + name); + start_worker(String(QUEUE_DIR_PATH) + name); } catch ( ... ) {} closedir(dir); } @@ -450,7 +467,7 @@ -string +String hostname() { char name[1024]; @@ -458,12 +475,12 @@ return ""; struct hostent *ent = gethostbyname(name); if (ent) - return string(ent->h_name); + return String(ent->h_name); else return name; } -pair +pair clusterinfo() { char* buff = 0; @@ -474,20 +491,20 @@ is.seekg(0, ios::beg); buff = new char[length]; is.read(buff, length); - string cluster_conf(buff, length); + String cluster_conf(buff, length); XMLObject xml(parseXML(cluster_conf)); delete [] buff; buff = 0; - return pair(xml.get_attr("name"), xml.get_attr("alias")); + return pair(xml.get_attr("name"), xml.get_attr("alias")); } catch ( ... ) { delete [] buff; - return pair("", ""); + return pair("", ""); } } -string +String os_release() { char* buff = 0; @@ -499,7 +516,7 @@ buff = new char[length]; is.read(buff, length); - string rel(buff, length); + String rel(buff, length); delete [] buff; buff = 0; --- conga/ricci/ricci/Ricci.h 2006/06/09 16:32:19 1.7 +++ conga/ricci/ricci/Ricci.h 2006/08/10 22:53:09 1.8 @@ -92,12 +92,12 @@ XMLObject _report; - std::string _path; + String _path; long long _id; long long _state; - static void start_worker(const std::string& path); + static void start_worker(const String& path); Batch(const Batch&); Batch& operator=(const Batch&); --- conga/ricci/ricci/RicciWorker.cpp 2006/07/20 08:29:49 1.9 +++ conga/ricci/ricci/RicciWorker.cpp 2006/08/10 22:53:09 1.10 @@ -54,11 +54,11 @@ usage(); return 1; } - if (string(argv[1]) != "-f") { + if (String(argv[1]) != "-f") { usage(); return 1; } - string path(argv[2]); + String path(argv[2]); if (daemon(0, 0)) { cout << "daemon() failed" << endl; @@ -70,7 +70,7 @@ BatchWorker batch(dbus, path); batch.process(); return 0; - } catch (string e) { + } catch (String e) { cout << "exception: " << e << endl; } catch ( ... ) { cout << "unknown exception" << endl; @@ -98,7 +98,7 @@ _report(xml), _batch(batch) { - string state_str = _report.get_attr("status"); + String state_str = _report.get_attr("status"); if (state_str.empty()) _state = st_sched; else @@ -171,7 +171,7 @@ return; } - string module_name(_report.get_attr("name")); + String module_name(_report.get_attr("name")); XMLObject module_header("module"); module_header.set_attr("name", module_name); @@ -195,8 +195,8 @@ return; } } else { - string message = generateXML(request); - string ret = _dbus.process(message, module_name); + String message = generateXML(request); + String ret = _dbus.process(message, module_name); mod_resp = parseXML(ret); } if (mod_resp.tag() == "internal_error") @@ -258,7 +258,7 @@ BatchWorker::BatchWorker(DBusController& dbus, - const string& path) : + const String& path) : _rm(dbus), _path(path) { @@ -266,20 +266,20 @@ _fd = open(_path.c_str(), O_RDONLY); if (_fd == -1) - throw string("unable to open batch file"); + throw String("unable to open batch file"); try { // lock file while (flock(_fd, LOCK_EX|LOCK_NB)) { if (errno == EINTR) continue; else if (errno == EWOULDBLOCK) - throw string("file is in use by other worker"); + throw String("file is in use by other worker"); else - throw string("something bad happened"); + throw String("something bad happened"); } // read file - string xml_str; + String xml_str; char buff[1024]; int res; while ((res = read(_fd, buff, sizeof(buff))) != 0) { @@ -287,16 +287,17 @@ xml_str.append(buff, res); else if (errno != EINTR) - throw string("failure reading batch file"); + throw String("failure reading batch file"); } + shred(buff, sizeof(buff)); // _xml _xml = parseXML(xml_str); if (_xml.tag() != "batch") - throw string("not a batch file"); - string state_str = _xml.get_attr("status"); + throw String("not a batch file"); + String state_str = _xml.get_attr("status"); if (state_str.empty()) - throw string("missing status attr"); + throw String("missing status attr"); _state = (ProcessWorker::state) utils::to_long(state_str); // parse xml and generate subprocesses @@ -361,7 +362,7 @@ BatchWorker::report() const { XMLObject result(_xml.tag()); - for (map::const_iterator iter = _xml.attrs().begin(); + for (map::const_iterator iter = _xml.attrs().begin(); iter != _xml.attrs().end(); iter++) result.set_attr(iter->first, iter->second); @@ -378,33 +379,33 @@ { QueueLocker lock; - string path_tmp(_path + ".tmp"); + String path_tmp(_path + ".tmp"); int fd_tmp = open(path_tmp.c_str(), O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP); if (fd_tmp == -1) - throw string("unable to create tmp batch file"); + throw String("unable to create tmp batch file"); try { // lock path_tmp while (flock(fd_tmp, LOCK_EX)) if (errno != EINTR) - throw string("unable to lock the tmp batch file"); + throw String("unable to lock the tmp batch file"); // write to tmp file - string out(generateXML(report())); + String out(generateXML(report())); do { int res = write(fd_tmp, out.c_str(), out.size()); if (res == -1) { if (errno != EINTR) - throw string("unable to write batch file"); + throw String("unable to write batch file"); } else out = out.substr(res); } while (out.size()); // rename path_tmp to _path if (rename(path_tmp.c_str(), _path.c_str())) - throw string("unable to rename batch file"); + throw String("unable to rename batch file"); // close _fd, and replace it with fd_tmp close_fd(_fd); --- conga/ricci/ricci/RicciWorker.h 2006/04/12 15:47:09 1.5 +++ conga/ricci/ricci/RicciWorker.h 2006/08/10 22:53:09 1.6 @@ -88,7 +88,7 @@ { public: BatchWorker(DBusController& dbus, - const std::string& path); + const String& path); virtual ~BatchWorker(); virtual XMLObject report() const; @@ -103,7 +103,7 @@ XMLObject _xml; ProcessWorker::state _state; - std::string _path; + String _path; int _fd; void close_fd(int fd); --- conga/ricci/ricci/SSLInstance.cpp 2006/06/09 16:32:19 1.4 +++ conga/ricci/ricci/SSLInstance.cpp 2006/08/10 22:53:09 1.5 @@ -52,12 +52,12 @@ class file_cert { public: - file_cert(const string& file, const string& cert) : + file_cert(const String& file, const String& cert) : file(file), cert(cert) {} - string file; - string cert; + String file; + String cert; }; static list authorized_certs; @@ -87,11 +87,11 @@ // load saved certs - set files; - string dir_path(CLIENT_CERTS_DIR_PATH); + set files; + String dir_path(CLIENT_CERTS_DIR_PATH); DIR* d = opendir(dir_path.c_str()); if (d == NULL) - throw string("unable to open directory ") + dir_path; + throw String("unable to open directory ") + dir_path; try { while (true) { struct dirent* ent = readdir(d); @@ -99,7 +99,7 @@ closedir(d); break; } - string kid_path = ent->d_name; + String kid_path = ent->d_name; if (kid_path == "." || kid_path == "..") continue; kid_path = dir_path + "/" + kid_path; @@ -116,7 +116,7 @@ authorized_certs.clear(); - for (set::const_iterator iter = files.begin(); + for (set::const_iterator iter = files.begin(); iter != files.end(); iter++) { char* buff = 0; @@ -126,10 +126,10 @@ streamoff length = is.tellg(); is.seekg(0, ios::beg); if (length > 10 * 1024) - throw string("file too large to be a certificate"); + throw String("file too large to be a certificate"); buff = new char[length]; is.read(buff, length); - string cert(buff, length); + String cert(buff, length); if (cert.size()) authorized_certs.push_back(file_cert(*iter, cert)); delete [] buff; @@ -180,7 +180,7 @@ if (!ctx) ctx = SSL_CTX_new(SSLv23_server_method()); if (!ctx) - throw string("SSL context creation failed"); + throw String("SSL context creation failed"); // set verify_callback() function SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, @@ -193,12 +193,12 @@ if (!SSL_CTX_use_PrivateKey_file(ctx, SERVER_KEY_PATH, SSL_FILETYPE_PEM)) - throw string("error importing server's cert key file"); + throw String("error importing server's cert key file"); // load server cert if (!SSL_CTX_use_certificate_file(ctx, SERVER_CERT_PATH, SSL_FILETYPE_PEM)) - throw string("error importing server's cert file"); + throw String("error importing server's cert file"); // load client certs load_client_certs(); @@ -208,7 +208,7 @@ // create SSL object, giving it context _ssl = SSL_new(ctx); if (!_ssl) - throw string("creation of ssl object failed"); + throw String("creation of ssl object failed"); } // make socket non-blocking @@ -222,7 +222,7 @@ // assign fd to _ssl if (!SSL_set_fd(_ssl, _sock.get_sock())) { SSL_free(_ssl); - throw string("fd assignment to ssl_obj failed"); + throw String("fd assignment to ssl_obj failed"); } } @@ -255,12 +255,12 @@ return _accepted; } -std::string -SSLInstance::send(const std::string& msg, +String +SSLInstance::send(const String& msg, unsigned int timeout) { if (!_accepted) - throw string("cannot send, yet: SSL connection not accepted"); + throw String("cannot send, yet: SSL connection not accepted"); if (msg.empty()) return msg; @@ -280,11 +280,11 @@ return msg; } -std::string +String SSLInstance::recv(unsigned int timeout) { if (!_accepted) - throw string("cannot receive, yet: SSL connection not accepted"); + throw String("cannot receive, yet: SSL connection not accepted"); char buff[1024]; @@ -292,7 +292,9 @@ while (time_mil() < beg + timeout) { int ret = SSL_read(_ssl, buff, sizeof(buff)); if (ret > 0) { - return string(buff, ret); + String data(buff, ret); + shred(buff, sizeof(buff)); + return data; } else { bool want_read, want_write; check_error(ret, want_read, want_write); @@ -307,7 +309,7 @@ SSLInstance::client_has_cert() { if (!_accepted) - throw string("cannot determine if client has certificate: SSL connection not accepted"); + throw String("cannot determine if client has certificate: SSL connection not accepted"); if (_cert_pem.size()) return true; @@ -320,9 +322,9 @@ FILE* f = NULL; try { if (!(f = tmpfile())) - throw string("unable to open temp file"); + throw String("unable to open temp file"); if (!PEM_write_X509(f, cert)) - throw string("unable to write cert to tmp file"); + throw String("unable to write cert to tmp file"); X509_free(cert); cert = NULL; // read cert @@ -335,7 +337,7 @@ if (feof(f)) break; else - throw string("error while reading certificate from temp file"); + throw String("error while reading certificate from temp file"); } } fclose(f); f = NULL; @@ -378,9 +380,9 @@ MutexLocker l(global_lock); if (!client_has_cert()) - throw string("client did not present cert"); + throw String("client did not present cert"); - string f_name(CLIENT_CERTS_DIR_PATH); + String f_name(CLIENT_CERTS_DIR_PATH); f_name += "/client_cert_XXXXXX"; int fd = -1; char* buff = new char[f_name.size() + 1]; @@ -388,16 +390,16 @@ // pick a filename strcpy(buff, f_name.c_str()); if ((fd = mkstemp(buff)) == -1) - throw string("unable to generate random file"); + throw String("unable to generate random file"); f_name = buff; delete[] buff; buff = 0; - string data(_cert_pem); + String data(_cert_pem); while (data.size()) { ssize_t i = write(fd, data.c_str(), data.size()); if (i == -1) { if (errno != EINTR) - throw string("error writing certificate"); + throw String("error writing certificate"); } else data = data.substr(i); } @@ -423,7 +425,7 @@ MutexLocker l(global_lock); if (!client_has_cert()) - throw string("client did not present cert"); + throw String("client did not present cert"); for (list::const_iterator iter = authorized_certs.begin(); iter != authorized_certs.end(); @@ -446,7 +448,7 @@ { want_read = want_write = false; - string e; + String e; switch (SSL_get_error(_ssl, value)) { case SSL_ERROR_NONE: e = "SSL_ERROR_NONE"; @@ -476,5 +478,5 @@ e = "SSL_ERROR_SSL"; break; } - throw string("SSL_read() error: ") + e; + throw String("SSL_read() error: ") + e; } --- conga/ricci/ricci/SSLInstance.h 2006/06/09 16:32:19 1.4 +++ conga/ricci/ricci/SSLInstance.h 2006/08/10 22:53:09 1.5 @@ -26,7 +26,7 @@ #include "Socket.h" -#include +#include "String.h" #include @@ -41,8 +41,8 @@ bool accept(unsigned int timeout); - std::string send(const std::string& msg, unsigned int timeout); - std::string recv(unsigned int timeout); + String send(const String& msg, unsigned int timeout); + String recv(unsigned int timeout); bool client_has_cert(); @@ -59,7 +59,7 @@ ClientSocket _sock; SSL* _ssl; - std::string _cert_pem; + String _cert_pem; bool _accepted; --- conga/ricci/ricci/Server.cpp 2006/04/03 14:45:41 1.3 +++ conga/ricci/ricci/Server.cpp 2006/08/10 22:53:09 1.4 @@ -107,7 +107,7 @@ if (errno == EINTR) continue; else - throw string("poll() error"); + throw String("poll() error"); } // process events @@ -120,12 +120,12 @@ client->start(); clients.push_back(client); cout << "client added" << endl; - } catch ( string e ) { + } catch ( String e ) { cout << "exception: " << e << endl; } catch ( ... ) {} } if (poll_data.revents & (POLLERR | POLLHUP | POLLNVAL)) - throw string("server socket error????"); + throw String("server socket error????"); } // while } --- conga/ricci/ricci/auth_helper.cpp 2006/03/06 21:48:05 1.1 +++ conga/ricci/ricci/auth_helper.cpp 2006/08/10 22:53:09 1.2 @@ -23,6 +23,7 @@ #include #include +#include "String.h" using namespace std; @@ -38,7 +39,7 @@ if ( ! ((*msg)->msg_style == PAM_PROMPT_ECHO_OFF || (*msg)->msg_style == PAM_PROMPT_ECHO_ON) ) return PAM_CONV_ERR; - string *passwd = (string*) appdata_ptr; + String *passwd = (String*) appdata_ptr; if (passwd->size() >= PAM_MAX_MSG_SIZE-1) return PAM_CONV_ERR; @@ -63,7 +64,7 @@ { cout << "Enter root password: "; - string passwd; + String passwd; cin >> passwd; // pam handle --- conga/ricci/ricci/dbus_test.cpp 2006/06/15 03:08:37 1.3 +++ conga/ricci/ricci/dbus_test.cpp 2006/08/10 22:53:09 1.4 @@ -21,7 +21,7 @@ cout << "max msg size: " << dbus_connection_get_max_message_size(conn) << endl; // construct xml request - string xml = ""; + String xml = ""; xml += ""; xml += ""; xml += ""; @@ -51,7 +51,7 @@ cout << "status: " << status << endl; cout << "out: " << out << endl; - cout << "out size: " << string(out).size() << endl; + cout << "out size: " << String(out).size() << endl; cout << "err: " << err << endl; dbus_message_unref(resp); --- conga/ricci/ricci/main.cpp 2006/04/03 14:45:41 1.3 +++ conga/ricci/ricci/main.cpp 2006/08/10 22:53:09 1.4 @@ -79,7 +79,7 @@ Server server(serv_sock); server.run(); - } catch ( string e ) { + } catch ( String e ) { cout << "exception: " << e << endl; return 1; }