def copy_boot_files(userspace_dir): kernel = 'vmlinuz-upgrade.x86_64' initram = 'initramfs-upgrade.x86_64.img' content = BootContent( kernel_path=os.path.join('/boot', kernel), initram_path=os.path.join('/boot', initram) ) run(['cp', '-a', os.path.join(userspace_dir, 'artifacts', kernel), content.kernel_path]) run(['cp', '-a', os.path.join(userspace_dir, 'artifacts', initram), content.initram_path]) api.produce(content)
def copy_boot_files(context): """ Function to copy the generated initram and corresponding kernel to /boot - Additionally produces a BootContent message with their location. """ kernel = 'vmlinuz-upgrade.x86_64' initram = 'initramfs-upgrade.x86_64.img' content = BootContent(kernel_path=os.path.join('/boot', kernel), initram_path=os.path.join('/boot', initram)) context.copy_from(os.path.join('/artifacts', kernel), content.kernel_path) context.copy_from(os.path.join('/artifacts', initram), content.initram_path) api.produce(content)
def copy_boot_files(context): """ Function to copy the generated initram and corresponding kernel to /boot - Additionally produces a BootContent message with their location. """ curr_arch = api.current_actor().configuration.architecture kernel = 'vmlinuz-upgrade.{}'.format(curr_arch) initram = 'initramfs-upgrade.{}.img'.format(curr_arch) content = BootContent(kernel_path=os.path.join('/boot', kernel), initram_path=os.path.join('/boot', initram)) context.copy_from(os.path.join('/artifacts', kernel), content.kernel_path) context.copy_from(os.path.join('/artifacts', initram), content.initram_path) api.produce(content)
def test_copy_boot_files(monkeypatch, arch): kernel = 'vmlinuz-upgrade.{}'.format(arch) initram = 'initramfs-upgrade.{}.img'.format(arch) bootc = BootContent(kernel_path=os.path.join('/boot', kernel), initram_path=os.path.join('/boot', initram)) monkeypatch.setattr(upgradeinitramfsgenerator.api, 'current_actor', CurrentActorMocked(arch=arch)) monkeypatch.setattr(upgradeinitramfsgenerator.api, 'produce', produce_mocked()) context = MockedContext() upgradeinitramfsgenerator.copy_boot_files(context) assert len(context.called_copy_from) == 2 assert (os.path.join('/artifacts', kernel), bootc.kernel_path) in context.called_copy_from assert (os.path.join('/artifacts', initram), bootc.initram_path) in context.called_copy_from assert upgradeinitramfsgenerator.api.produce.called == 1 assert upgradeinitramfsgenerator.api.produce.model_instances[0] == bootc
def consume_message_mocked(*models): yield BootContent(kernel_path='/abc', initram_path='/def')
def message_copied_files(): """Let the other actors know what files we've stored on /boot.""" api.produce( BootContent(kernel_path=get_dst_filepath(KERNEL_FILENAME), initram_path=get_dst_filepath(INITRAM_FILENAME)))
def consume_message_mocked(*models): yield BootContent(kernel_path='/ghi', initram_path='/jkl')