def update_grub_rpm(remote, newversion): """ Updates grub file to boot new kernel version on both legacy grub/grub2. """ grub = 'grub2' # Check if grub2 is isntalled try: remote.run(args=['sudo', 'rpm', '-qi', 'grub2']) except Exception: grub = 'legacy' log.info('Updating Grub Version: {grub}'.format(grub=grub)) if grub == 'legacy': data = '' #Write new legacy grub entry. newgrub = generate_legacy_grub_entry(remote, newversion) for line in newgrub: data += line + '\n' temp_file_path = remote.mktemp() teuthology.sudo_write_file(remote, temp_file_path, StringIO(data), '755') teuthology.move_file(remote, temp_file_path, '/boot/grub/grub.conf', True) else: #Update grub menu entry to new version. grub2_kernel_select_generic(remote, newversion, 'rpm')
def cleanup_added_key(ctx, key_backup_files, path): """ Delete the keys and removes ~/.ssh/authorized_keys entries we added """ log.info('cleaning up keys added for testing') for remote in ctx.cluster.remotes: username, hostname = str(remote).split('@') if "" == username or "" == hostname: continue else: log.info(' cleaning up keys for user {user} on {host}'.format(host=hostname, user=username)) misc.delete_file(remote, '/home/{user}/.ssh/id_rsa'.format(user=username)) misc.delete_file(remote, '/home/{user}/.ssh/id_rsa.pub'.format(user=username)) misc.move_file(remote, key_backup_files[remote], path)
def update_grub_rpm(remote, newversion): """ Updates grub file to boot new kernel version on both legacy grub/grub2. """ grub='grub2' # Check if grub2 is isntalled try: remote.run(args=['sudo', 'rpm', '-qi', 'grub2']) except Exception: grub = 'legacy' log.info('Updating Grub Version: {grub}'.format(grub=grub)) if grub == 'legacy': data = '' #Write new legacy grub entry. newgrub = generate_legacy_grub_entry(remote, newversion) for line in newgrub: data += line + '\n' temp_file_path = remote.mktemp() teuthology.sudo_write_file(remote, temp_file_path, StringIO(data), '755') teuthology.move_file(remote, temp_file_path, '/boot/grub/grub.conf', True) else: #Update grub menu entry to new version. grub2_kernel_select_generic(remote, newversion, 'rpm')