def __comparePackagesToString(self, comparePackages): stringUtil = StringUtil() rString = "" missingPackagesMap = comparePackages.getMissingPackagesMap() if (len(missingPackagesMap.keys()) > 0): description = "The following hosts did not have certain cluster packages installed(whereas other hosts did have the packages installed):" keys = missingPackagesMap.keys() keys.sort() missingPackagesTable = [] for key in keys: reportNames = missingPackagesMap.get(key) reportNames.sort() if (len(reportNames) > 0): currentHostnames = "" for reportName in reportNames: currentHostnames += "%s " % (reportName) missingPackagesTable.append([key, currentHostnames]) tableHeader = ["Package Name", "Hostname(s)"] tableOfStrings = stringUtil.toTableStringsList( missingPackagesTable, tableHeader) rString += StringUtil.formatBulletString(description, [], tableOfStrings) differentPackagesVersionMap = comparePackages.getDiffernetPackagesVersionMap( ) if (len(differentPackagesVersionMap.keys()) > 0): description = "The following hosts had a different package version installed:" keys = differentPackagesVersionMap.keys() keys.sort() differentPackageVersionsTable = [] for key in keys: reportNames = differentPackagesVersionMap.get(key) reportNames.sort() if (len(reportNames) > 0): currentHostnames = "" for reportName in reportNames: currentHostnames += "%s " % (reportName) differentPackageVersionsTable.append( [key, currentHostnames]) tableHeader = ["Package Name", "Hostname(s)"] tableOfStrings = stringUtil.toTableStringsList( differentPackageVersionsTable, tableHeader) rString += StringUtil.formatBulletString(description, [], tableOfStrings) if (len(rString) > 0): rString = "%s\n%s" % (comparePackages, rString) return rString
def evaluate(self): rstring = "" storageData = self.getStorageData() bdt = storageData.getBlockDeviceTree() # ################################################################### # Find out if multipath bindging file is located on a fs /var. # ################################################################### fsVarExist = False # Find out if /var is its own filesystem for filesysMount in bdt.getFilesysMountList(): if (filesysMount.getMountPoint() == "/var"): fsVarExist = True break if (fsVarExist): for line in storageData.getMultipathConfData(): lineSplit = line.strip().split() if (len(lineSplit) == 2): if ((lineSplit[0].strip() == "bindings_file") and (lineSplit[1].strip().startswith("/var"))): description = "The binding file for multipath is located on /var." urls = ["https://access.redhat.com/solutions/17643"] rstring += StringUtil.formatBulletString( description, urls) break # ################################################################### # Check if emc and dmm module are loaded at same time. # ################################################################### foundEMC = False foundDMMultipath = False for lsmod in storageData.getLSMod(): if (lsmod.getModuleName() == "emcp"): foundEMC = True elif (lsmod.getModuleName() == "dm_multipath"): foundDMMultipath = True if (foundEMC and foundDMMultipath): description = "The modules dm-emc and scsi_dh_emc should never be loaded at the same time. One of these packages should be remove: emc or device-mapper-multipath." urls = ["https://access.redhat.com/solutions/45197"] rstring += StringUtil.formatBulletString(description, urls) # ################################################################### # Add newline to separate the node stanzas # ################################################################### if (len(rstring) > 0): rstring += "\n" # ################################################################### return rstring
def __compareDataToString(self, compareData): stringUtil = StringUtil() rString = "" nonBaseCompareMap = compareData.getNonBaseCompareMap() if (not len(nonBaseCompareMap.keys()) > 0): return rString description = "The following hosts had similar compared values:" baseCompareMap = compareData.getBaseCompareMap() keys = baseCompareMap.keys() keys.sort() compareTable = [] for key in keys: reportNames = baseCompareMap.get(key) reportNames.sort() currentHostnames = "" for reportName in reportNames: currentHostnames += "%s " % (reportName) compareTable.append([key, currentHostnames]) tableHeader = ["Compared String", "Hostname(s)"] tableOfStrings = stringUtil.toTableStringsList(compareTable, tableHeader) rString += StringUtil.formatBulletString(description, [], tableOfStrings) description = "The following hosts had different compared values than the above compared values:" keys = nonBaseCompareMap.keys() keys.sort() compareTable = [] for key in keys: reportNames = nonBaseCompareMap.get(key) reportNames.sort() currentHostnames = "" for reportName in reportNames: currentHostnames += "%s " % (reportName) compareTable.append([key, currentHostnames]) tableHeader = ["Compared String", "Hostname(s)"] tableOfStrings = stringUtil.toTableStringsList(compareTable, tableHeader) rString += StringUtil.formatBulletString(description, [], tableOfStrings) if (len(rString) > 0): rString = "%s\n%s" % (compareData, rString) return rString
def evaluateClusteredFilesystems(self): # Is active/active nfs supported? Sorta # urls = ["https://access.redhat.com/solutions/59498"] rString = "" baseClusterNode = self.__cnc.getBaseClusterNode() if (baseClusterNode == None): return rString cca = ClusterHAConfAnalyzer(baseClusterNode.getPathToClusterConf()) if ((cca.getTransportMode() == "broadcast") or (cca.getTransportMode() == "udpu")): for clusternode in self.__cnc.getClusterNodes(): if (len(clusternode.getClusterStorageFilesystemList()) > 0): description = "There is known limitations for GFS2 filesystem when using the " description += "following transports: \"%s\"." %(cca.getTransportMode()) urls = ["https://access.redhat.com/solutions/162193", "https://access.redhat.com/articles/146163", "https://access.redhat.com/solutions/459243"] rString += "%s\n" %(StringUtil.formatBulletString(description, urls)) break; for clusternode in self.__cnc.getClusterNodes(): stringUtil = StringUtil() clusterNodeEvalString = "" # ################################################################### # Distro Specific evaluations # ################################################################### # The distro release of this node distroRelease = clusternode.getDistroRelease() if ((distroRelease.getDistroName() == "RHEL") and (distroRelease.getMajorVersion() == 5)): # Check if GFS2 module should be removed on RH5 nodes if (self.__doesGFS2ModuleNeedRemoval(clusternode.getUnameA(), clusternode.getClusterModulePackagesVersion())) : description = "The kmod-gfs2 is installed on a running kernel >= 2.6.18-128. This module should be removed since the module is included in the kernel." urls = ["https://access.redhat.com/solutions/17832"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls) # ################################################################### # Analyze the Clustered Storage # ################################################################### listOfClusterStorageFilesystems = clusternode.getClusterStorageFilesystemList() # ################################################################### # Verify that GFS/GFS2 filesystem is using lvm with cluster bit set # ################################################################### fsTable = [] # Verify the locking_type is set to 3 cause built-in cluster locking is required. if (len(listOfClusterStorageFilesystems) > 0): devicemapperCommandsMap = self.__cnc.getStorageData(clusternode.getClusterNodeName()).getDMCommandsMap() lvm = LVM(DeviceMapperParser.parseVGSVData(devicemapperCommandsMap.get("vgs_-v")), DeviceMapperParser.parseLVSAODevicesData(devicemapperCommandsMap.get("lvs_-a_-o_devices")), self.__cnc.getStorageData(clusternode.getClusterNodeName()).getLVMConfData()) if (not lvm.isLockingTypeClustering()): description = "The locking_type is not set to type 3 for built-in cluster locking. A GFS/GFS2 filesystem requires the filesystem be on a " description += "clustered LVM volume with locking_type 3 enabled in the /etc/lvm/lvm.conf." urls = ["https://access.redhat.com/solutions/46637"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls) # Disabling this check for now cause still working on how to do it. """ # Verify that the clustered filesystem has clusterbit set on the vg. # Verify the locking_type is set to 3 cause built-in cluster locking is required. fsTable = [] if (len(listOfClusterStorageFilesystems) > 0): devicemapperCommandsMap = self.__cnc.getStorageData(clusternode.getClusterNodeName()).getDMCommandsMap() lvm = LVM(DeviceMapperParser.parseVGSVData(devicemapperCommandsMap.get("vgs_-v")), DeviceMapperParser.parseLVSAODevicesData(devicemapperCommandsMap.get("lvs_-a_-o_devices")), self.__cnc.getStorageData(clusternode.getClusterNodeName()).getLVMConfData()) for csFilesystem in listOfClusterStorageFilesystems: pathToDevice = str(csFilesystem.getDeviceName().strip().rstrip()) if (not lvm.isClusteredLVMDevice(pathToDevice)): currentFS = [pathToDevice, csFilesystem.getMountPoint(), csFilesystem.getFSType()] if (not currentFS in fsTable): fsTable.append(currentFS) if (len(fsTable) > 0): stringUtil = StringUtil() description = "The following filesystems appears not to be on a clustered LVM volume. A clustered LVM volume is required for GFS/GFS2 fileystems." tableHeader = ["device_name", "mount_point", "fs_type"] tableOfStrings = stringUtil.toTableStringsList(fsTable, tableHeader) urls = ["https://access.redhat.com/solutions/46637"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls, tableOfStrings) """ # ################################################################### # Verify they are exporting a gfs/gfs2 fs via samba and nfs correctly # ################################################################### tableHeader = ["device_name", "mount_point", "nfs_mp", "smb_mp"] fsTable = [] for csFilesystem in listOfClusterStorageFilesystems: # There are 4 ways of mounting gfs via nfs/smb at same time that # needs to be checked: # 1) nfs mount via /etc/exports and smb mount via /etc/samba/smb.conf # 2) nfs mount via /etc/cluster/cluster.conf and smb mount via /etc/cluster/cluster.conf # 3) nfs mount via /etc/cluster/cluster.conf and smb mount via /etc/samba/smb.conf. # 4) nfs mount via /etc/exports and smb mount via /etc/cluster/cluster.conf if (csFilesystem.isEtcExportMount() and csFilesystem.isSMBSectionMount()): # 1) nfs mount via /etc/exports and smb mount via /etc/samba/smb.conf #print "1: %s" %(csFilesystem.getMountPoint()) nfsMP = csFilesystem.getEtcExportMount().getMountPoint() smbSectionList = csFilesystem.getSMBSectionMountList() if (len(smbSectionList) > 0): smbMP = smbSectionList.pop().getOptionValue("path").strip() fsTable.append([csFilesystem.getDeviceName(), csFilesystem.getMountPoint(), "%s(EN)" %(nfsMP), "%s(ES)" %(smbMP)]) for smbSection in smbSectionList: smbMP = smbSection.getOptionValue("path").strip() fsTable.append(["", "", "", "%s(ES)" %(smbMP)]) elif ((not csFilesystem.isEtcExportMount()) and (not csFilesystem.isSMBSectionMount())): # 2) nfs mount via /etc/cluster/cluster.conf and smb mount via /etc/cluster/cluster.conf #print "2: %s" %(csFilesystem.getMountPoint()) if((self.__isNFSChildOfClusterStorageResource(cca, csFilesystem)) and (len(csFilesystem.getClusteredSMBNames()) > 0)): nfsMP = csFilesystem.getMountPoint() smbPaths = [] for name in csFilesystem.getClusteredSMBNames(): for smbSection in csFilesystem.getClusteredSMBSectionList(name): currentPath = smbSection.getOptionValue("path").strip() if (len(currentPath) > 0): smbPaths.append(currentPath) if ((len(nfsMP) > 0) and (len(smbPaths) > 0)): # Pop the first one off the list. smbMP = smbPaths.pop() fsTable.append([csFilesystem.getDeviceName(), csFilesystem.getMountPoint(), "%s(CN)" %(nfsMP), "%s(CS)" %(smbMP)]) # IF there any left add those with some blanks. for smbMP in smbPaths: fsTable.append(["", "", "", "%s(CS)" %(smbMP)]) elif ((csFilesystem.isSMBSectionMount()) and (self.__isNFSChildOfClusterStorageResource(cca, csFilesystem))): # 3) nfs mount via /etc/cluster/cluster.conf and smb mount via /etc/samba/smb.conf. #print "3: %s" %(csFilesystem.getMountPoint()) nfsMP = csFilesystem.getMountPoint() smbSectionList = csFilesystem.getSMBSectionMountList() if (len(smbSectionList) > 0): smbMP = smbSectionList.pop().getOptionValue("path").strip() fsTable.append([csFilesystem.getDeviceName(), csFilesystem.getMountPoint(), "%s(CN)" %(nfsMP), "%s(ES)" %(smbMP)]) for smbSection in smbSectionList: smbMP = smbSection.getOptionValue("path").strip() fsTable.append(["", "", "", "%s(ES)" %(smbMP)]) elif ((csFilesystem.isEtcExportMount()) and (len(csFilesystem.getClusteredSMBNames()) > 0)): # 4) nfs mount via /etc/exports and smb mount via /etc/cluster/cluster.conf # print "4: %s" %(csFilesystem.getMountPoint()) smbSectionList = [] for name in csFilesystem.getClusteredSMBNames(): smbSectionList += csFilesystem.getClusteredSMBSectionList(name) if (len(smbSectionList) > 0): smbMP = smbSectionList.pop().getOptionValue("path").strip() fsTable.append([csFilesystem.getDeviceName(), csFilesystem.getMountPoint(), "%s(EN)" %(nfsMP), "%s(CS)" %(smbMP)]) for smbSection in smbSectionList: smbMP = smbSection.getOptionValue("path").strip() fsTable.append(["", "", "", "%s(CS)" %(smbMP)]) # Write the table if it is not empty. if (len(fsTable) > 0): description = "The following GFS/GFS2 filesystem(s) are being exported by NFS and SMB(samba) which is unsupported. " description += "The mount point(s) that were found will be noted with these symbols below: " description += "nfs export via /etc/exports (EN) " description += "nfs export via /etc/cluster/cluster.conf (CN) " description += "samba export via /etc/exports for samba (ES) " description += "samba export via /etc/cluster/cluster.conf for samba (CS)" urls = ["https://access.redhat.com/solutions/39855"] tableOfStrings = stringUtil.toTableStringsList(fsTable, tableHeader) clusterNodeEvalString += StringUtil.formatBulletString(description, urls, tableOfStrings) # ################################################################### # Check for localflocks if they are exporting nfs. # ################################################################### fsTable = [] for csFilesystem in listOfClusterStorageFilesystems: # If a GFS or GFS2 fs is in /etc/exports or has a child that is # nfsexport then localflocks required. if ((csFilesystem.isEtcExportMount()) or (self.__isNFSChildOfClusterStorageResource(cca, csFilesystem))): csFilesystemOptions = csFilesystem.getAllMountOptions() if (not csFilesystemOptions.find("localflocks") >= 0): fsTable.append([csFilesystem.getDeviceName(), csFilesystem.getMountPoint()]) # Write the table if it is not empty. if (len(fsTable) > 0): tableHeader = ["device_name", "mount_point"] description = "Any GFS/GFS2 filesystem that is exported with NFS should have the option \"localflocks\" set." description += "The following GFS/GFS2 filesystem do not have the option set." tableOfStrings = stringUtil.toTableStringsList(fsTable, tableHeader) urls = ["https://access.redhat.com/solutions/20327", "http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html-single/Configuration_Example_-_NFS_Over_GFS/index.html#locking_considerations"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls, tableOfStrings) # ################################################################### # Check to see if the GFS/GFS2 fs has certain mount options enabled. # ################################################################### fsTable = [] for csFilesystem in listOfClusterStorageFilesystems: csFilesystemOptions = csFilesystem.getAllMountOptions() if (not csFilesystemOptions.find("noatime") >= 0): fsTable.append([csFilesystem.getDeviceName(), csFilesystem.getMountPoint()]) if (len(fsTable) > 0): # Verified that noatime implies nodiratime, so nodiratime check # does not need to be done. description = "There were GFS/GFS2 file-systems that did not have the mount option \"noatime\"(no \"nodiratime\" is implied. " description += "when noatime is set) enabled. Unless atime support is essential, Red Hat recommends setting the mount option " description += "\"noatime\" on every GFS/GFS2 mount point. This will significantly improve performance since it prevents " description += "reads from turning into writes because the access time attribute will not be updated." urls = ["https://access.redhat.com/articles/628093#slowdown_due_to_system_configuration_issues"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls) # ################################################################### # Make sure GFS/GFS2 filesystems dont have fsck option enable # ################################################################### for csFilesystem in listOfClusterStorageFilesystems: if (csFilesystem.isEtcFstabMount()): if (not csFilesystem.getEtcFstabMount().getFSFsck() == "0"): description = "There were GFS/GFS2 file-systems that had the fsck option enabled in the /etc/fstab file. This option " description += "should be disabled(set value to 0) or corruption will occur eventually." urls = ["https://access.redhat.com/solutions/766393"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls) # ################################################################### # Add to string with the hostname and header if needed. # ################################################################### if (len(clusterNodeEvalString) > 0): rString += "%s(Cluster Node ID: %s):\n%s\n\n" %(clusternode.getClusterNodeName(), clusternode.getClusterNodeID(), clusterNodeEvalString.rstrip()) # Return the string if (len(rString) > 0): sectionHeader = "%s\nCluster Storage Configuration Known Issues\n%s" %(self.__seperator, self.__seperator) rString = "%s\n%s" %(sectionHeader, rString) return rString
def evaluateNonClusteredFilesystems(self): """ This functions verifies that all fs resources are using HALVM. This checks to see if clusterbit on lvm vg is set or if they are using "volume_list" method in /etc/lvm/lvm.conf. Do note that tags in "volume_list" option are not checked. """ rString = "" baseClusterNode = self.__cnc.getBaseClusterNode() if (baseClusterNode == None): return rString cca = ClusterHAConfAnalyzer(baseClusterNode.getPathToClusterConf()) fsTable = [] filesystemResourcesList = cca.getFilesystemResourcesList() if (len(filesystemResourcesList) > 0): for clusterConfMount in filesystemResourcesList: currentFS = [clusterConfMount.getDeviceName(), clusterConfMount.getMountPoint(), clusterConfMount.getFSType()] if (not currentFS in fsTable): fsTable.append(currentFS) if (len(fsTable) > 0): stringUtil = StringUtil() sectionHeader = "%s\nFilesystem and Clustered-Filesystem cluster.conf Summary\n%s" %(self.__seperator, self.__seperator) description = "There was %d filesystems resources(fs.sh) found in the cluster.conf. It is recommended that all filesystem resource\'s(fs.sh) " %(len(fsTable)) description += "underlying storage device is using one(not both) of the 2 methods for HALVM as described in article below for the underlying " description += "storage device. The following article describes these procedures:" urls = ["https://access.redhat.com/solutions/3067"] rString += StringUtil.formatBulletString(description, urls) # Disabled for now and will return an empty string """ baseClusterNode = self.__cnc.getBaseClusterNode() if (baseClusterNode == None): return rString cca = ClusterHAConfAnalyzer(baseClusterNode.getPathToClusterConf()) fsTable = [] filesystemResourcesList = cca.getFilesystemResourcesList() for clusternode in self.__cnc.getClusterNodes(): clusterNodeEvalString = "" # Check to see if volume_list and locking_type 3 is set for cluster # locking. if (len(filesystemResourcesList) > 0): devicemapperCommandsMap = self.__cnc.getStorageData(clusternode.getClusterNodeName()).getDMCommandsMap() lvm = LVM(DeviceMapperParser.parseVGSVData(devicemapperCommandsMap.get("vgs_-v")), DeviceMapperParser.parseLVSAODevicesData(devicemapperCommandsMap.get("lvs_-a_-o_devices")), self.__cnc.getStorageData(clusternode.getClusterNodeName()).getLVMConfData()) if (lvm.isVolumeListEnabled() and lvm.isLockingTypeClustering()): description = "The option \"volume_list\" and \"locking_type = 3\" in /etc/lvm/lvm.conf are both in use. Using " description += "both options at the same time is supported, but not recommended except for certain configurations. " description += "This configuration should be reviewed to verify that configuration is correct." urls = ["https://access.redhat.com/solutions/3067"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls) # Check to see if device is either has volume_list set or has # cluster bit set on each fs resource. for clusterConfMount in filesystemResourcesList: pathToDevice = str(clusterConfMount.getDeviceName().strip().rstrip()) if (not lvm.isLVMVolumeHALVM(pathToDevice)): currentFS = [clusterConfMount.getDeviceName(), clusterConfMount.getMountPoint(), clusterConfMount.getFSType()] if (not currentFS in fsTable): fsTable.append(currentFS) if (len(fsTable) > 0): # Should flag for vgs with no c bit set and no lvm on device path. stringUtil = StringUtil() description = "The following filesystems appears to not be on a HALVM volume using one of the methods outlined in the article below. " description += "A HALVM volume is recommoned for all fs resources. Do note that LVM tags were not searched and compared if they were " description += "used in the \"volume_list\" option of the /etc/lvm/lvm.conf file:" tableHeader = ["device_name", "mount_point", "fs_type"] tableOfStrings = stringUtil.toTableStringsList(fsTable, tableHeader) urls = ["https://access.redhat.com/solutions/3067"] rString += StringUtil.formatBulletString(description, urls, tableOfStrings) """ return rString
def evaluate(self): """ * If two node cluster, check if hb and fence on same network. warn qdisk required if not or fence delay. """ # Return string for evaluation. rstring = "" # Nodes that are in cluster.conf, so should have report of all these baseClusterNode = self.__cnc.getBaseClusterNode() if (baseClusterNode == None): # Should never occur since node count should be checked first. return "" cca = ClusterHAConfAnalyzer(baseClusterNode.getPathToClusterConf()) for clusternode in self.__cnc.getClusterNodes(): clusterNodeEvalString = "" if (not clusternode.isClusterNode()): continue # The distro release of this node distroRelease = clusternode.getDistroRelease() # The clusternode name in /etc/cluster/cluster.conf clusterNodeName = clusternode.getClusterNodeName() if (not (distroRelease.getDistroName() == "RHEL") and ((distroRelease.getMajorVersion() == 5) or (distroRelease.getMajorVersion() == 6))): message = "Stretch Clusters are only supported on RHEL 5 and RHEL6." logging.getLogger(sx.MAIN_LOGGER_NAME).error(message) else: # ################################################################### # CLVMD and cmirror cannot be enabled on stretch clusters. # ################################################################### serviceName = "clvmd" serviceRunlevelEnabledString = "" for chkConfigItem in clusternode.getChkConfigList(): if (chkConfigItem.getName() == serviceName): if(chkConfigItem.isEnabledRunlevel3()): serviceRunlevelEnabledString += "3 " if(chkConfigItem.isEnabledRunlevel4()): serviceRunlevelEnabledString += "4 " if(chkConfigItem.isEnabledRunlevel5()): serviceRunlevelEnabledString += "5 " if (len(serviceRunlevelEnabledString) > 0): description = "The service %s should be disabled if this is cluster node is part of a stretch cluster. The service %s is not supported in stretch clusters." %(serviceName, serviceName) description += "The following runlevels have %s enabled: %s." %(serviceName, serviceRunlevelEnabledString.strip()) urls = ["https://access.redhat.com/solutions/163833"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls) serviceName = "cmirror" serviceRunlevelEnabledString = "" for chkConfigItem in clusternode.getChkConfigList(): if (chkConfigItem.getName() == serviceName): if(chkConfigItem.isEnabledRunlevel3()): serviceRunlevelEnabledString += "3 " if(chkConfigItem.isEnabledRunlevel4()): serviceRunlevelEnabledString += "4 " if(chkConfigItem.isEnabledRunlevel5()): serviceRunlevelEnabledString += "5 " if (len(serviceRunlevelEnabledString) > 0): description = "The service %s should be disabled if this is cluster node is part of a stretch cluster. The service %s is not supported in stretch clusters." %(serviceName, serviceName) description += "The following runlevels have %s enabled: %s." %(serviceName, serviceRunlevelEnabledString.strip()) urls = ["https://access.redhat.com/solutions/163833"] clusterNodeEvalString += StringUtil.formatBulletString(description, urls) # ################################################################### # Add newline to separate the node stanzas # ################################################################### if (len(clusterNodeEvalString) > 0): rstring += "%s(Cluster Node ID: %s):\n%s\n" %(clusterNodeName, clusternode.getClusterNodeID(), clusterNodeEvalString) # ################################################################### return rstring