def assert_success(self, section, key, value, expected_key=None, expected_value=None): ''' Try and read an l3overlay daemon using the given arguments. Assumes it will succeed, and will run an assertion test to make sure a Daemon is returned. ''' oc = self._overlay_conf_copy(section, key, value) overlay = l3overlay.overlay.read( self.global_conf["log"], self.global_conf["log_level"], config = oc, ) self.assertIsInstance(overlay, l3overlay.overlay.Overlay) if expected_value is not None: k = expected_key if expected_key else key if l3overlay.overlay.interface.section_type_is_static_interface(section): for interface in overlay.interfaces: if interface.name == util.section_name_get(section): self.assertEqual(expected_value, vars(interface)[k.replace("-", "_")]) break else: self.assertEqual(expected_value, vars(overlay)[k.replace("-", "_")]) return overlay
def value_get(self, overlay, section, k): ''' Get the value from the given section and key on the overlay. ''' key = k.replace("-", "_") if section == "overlay": return vars(overlay)[key] elif section.startswith("static"): name = util.section_name_get(section) for i in overlay.interfaces: if name == i.name: return vars(i)[key] else: raise RuntimeError("unknown section type '%s'" % section)