def make_kernel_parameters(testcase=None, **parms): """Make a randomly populated `KernelParameters` instance. If testcase is passed, we poke the generated arch/subarch into the ArchitectureRegistry and call addCleanup on the testcase to make sure it is removed after the test completes. """ # fs_host needs to be an IP address, set it if it was not passed. if 'fs_host' not in parms: parms.update({'fs_host': factory.make_ip_address()}) parms.update({ field: factory.make_name(field) for field in KernelParameters._fields if field not in parms }) if not isinstance(parms['http_boot'], bool): parms['http_boot'] = True params = KernelParameters(**parms) if testcase is not None: name = "%s/%s" % (params.arch, params.subarch) if name in ArchitectureRegistry: # It's already there, no need to patch and risk overwriting # preset kernel options. return params resource = Architecture(name, name) ArchitectureRegistry.register_item(name, resource) testcase.addCleanup(ArchitectureRegistry.unregister_item, name) return params
def make_kernel_parameters(**parms): """Make a randomly populated `KernelParameters` instance.""" parms.update({ field: factory.make_name(field) for field in KernelParameters._fields if field not in parms }) return KernelParameters(**parms)
def fetch(client, params): params["system_id"] = client.localIdent d = self.fetcher(client, GetBootConfig, **params) d.addCallback(self.get_boot_image, client, params["remote_ip"]) d.addCallback(lambda data: KernelParameters(**data)) return d
def test_pxeconfig_returns_fs_host_as_cluster_controller(self): # The kernel parameter `fs_host` points to the cluster controller # address, which is passed over within the `local` parameter. params = self.get_default_params() kernel_params = KernelParameters(**self.get_pxeconfig(params)) self.assertEqual(params["local"], kernel_params.fs_host)
def reassemble(data): return KernelParameters(**data)