def assert_ifcfg_has_items(ifname, expected_items): ifcfg = ShellVarFile("/etc/sysconfig/network-scripts/ifcfg-" + ifname) ifcfg_items = sorted(ifcfg.get_dict().items()) logging.info("ifcfg : %s" % ifname) logging.info("expect: %s" % expected_items) logging.info("got : %s" % ifcfg_items) assert ifcfg_items == expected_items
def ifcfg_has_items(ifname, expected_items): """Check if the items in an ifcfg file are equal the expected_items """ ifcfg = ShellVarFile(ifcfgfilename(ifname)) ifcfg_items = sorted(ifcfg.get_dict().items()) logging.info("ifcfg : %s" % ifname) logging.info("expect: %s" % expected_items) logging.info("got : %s" % ifcfg_items) return ifcfg_items == expected_items
def write(self): """Write a ifcfg file from the cfg """ data = {} for k in self.cfg._keys: data[k.upper()] = self.cfg.__dict__.get(k) ShellVarFile.write(self, data, True) pcfg = fs.Config() if pcfg.is_enabled(): pcfg.persist(self.filename) return data