def test_sysconfig_set_bsc1145823(): s = '''# this is test #age=1000 ''' fd, fname = tmpfiles.create() with open(fname, 'w') as f: f.write(s) utils.sysconfig_set(fname, age="100") sc = utils.parse_sysconfig(fname) assert (sc.get("age") == "100")
def verify(self): """ Verify the modification is working """ sbd_options = crmshutils.parse_sysconfig(self.conf) if sbd_options["SBD_DEVICE"] == self.new: self.info("SBD DEVICE change succeed") else: raise TaskError("Fail to replace SBD device {} in {}!".format( self.new, config.SBD_CONF))
def test_sysconfig_set(): s = ''' FW_SERVICES_ACCEPT_EXT="0/0,tcp,22,,hitcount=3,blockseconds=60,recentname=ssh" ''' fd, fname = tmpfiles.create() with open(fname, 'w') as f: f.write(s) utils.sysconfig_set(fname, FW_SERVICES_ACCEPT_EXT="foo=bar", FOO="bar") sc = utils.parse_sysconfig(fname) assert (sc.get("FW_SERVICES_ACCEPT_EXT") == "foo=bar") assert (sc.get("FOO") == "bar")
def __init__(self, candidate, yes=False): self.new = candidate self.description = "Replace SBD_DEVICE with candidate {}".format(self.new) self.conf = config.SBD_CONF super(self.__class__, self).__init__(self.description, flush=True) self.bak = tempfile.mkstemp()[1] self.edit = tempfile.mkstemp()[1] self.yes = yes sbd_options = crmshutils.parse_sysconfig(self.conf) self.old = sbd_options["SBD_DEVICE"]
def test_parse_sysconfig(): """ bsc#1129317: Fails on this line FW_SERVICES_ACCEPT_EXT="0/0,tcp,22,,hitcount=3,blockseconds=60,recentname=ssh" """ s = ''' FW_SERVICES_ACCEPT_EXT="0/0,tcp,22,,hitcount=3,blockseconds=60,recentname=ssh" ''' fd, fname = tmpfiles.create() with open(fname, 'w') as f: f.write(s) sc = utils.parse_sysconfig(fname) assert ("FW_SERVICES_ACCEPT_EXT" in sc)
def check_sbd(): """ Check the sbd device and find a possible fix for incorrect disk Only support one path SBD_DEVICE in the current version """ print("\n============ Checking the SBD device ============") task_inst = task.TaskCheck("Checking SBD device") with task_inst.run(): if not os.path.exists(config.SBD_CONF): utils.msg_info("SBD configuration file {} not found.".format( config.SBD_CONF)) return "" sbd_options = crmshutils.parse_sysconfig(config.SBD_CONF) if not "SBD_DEVICE" in sbd_options: utils.msg_info("SBD DEVICE not used.") return "" dev = sbd_options["SBD_DEVICE"] if not os.path.exists(dev): task_inst.warn("SBD device '{}' is not exist.".format(dev)) else: if utils.is_valid_sbd(dev): task_inst.info("'{}' is a valid SBD device.".format(dev)) return "" else: task_inst.warn( "Device '{}' is not valid for SBD, may need initialize.". format(dev)) candidate = utils.find_candidate_sbd(dev) if candidate == "": task_inst.warn("Fail to find a valid candidate SBD device.") return "" task_inst.info("Found '{}' with SBD header exist.".format(candidate)) return candidate