g.command([ 'sed', '-i', r's#^\(GRUB_CMDLINE_LINUX=".*\)"$#\1 console=ttyS0,38400n8"#', '/etc/default/grub' ]) # Disable predictive network interface naming in Stretch. if deb_release == 'stretch': g.command([ 'sed', '-i', r's#^\(GRUB_CMDLINE_LINUX=".*\)"$#\1 net.ifnames=0 biosdevname=0"#', '/etc/default/grub' ]) g.command(['update-grub2']) # Reset network for DHCP. logging.info('Resetting network to DHCP for eth0.') g.write('/etc/network/interfaces', interfaces) def main(): g = diskutils.MountDisk('/dev/sdb') DistroSpecific(g) utils.CommonRoutines(g) diskutils.UnmountDisk(g) if __name__ == '__main__': utils.RunTranslate(main)
def main(): utils.RunTranslate(translate, run_with_tracing=False)
# Update grub config to log to console. run(g, [ 'sed', '-i', r's#^\(GRUB_CMDLINE_LINUX=".*\)"$#\1 console=ttyS0,38400n8"#', '/etc/default/grub' ]) run(g, ['update-grub2']) def remove_azure_agents(g): try: run(g, ['apt-get', 'remove', '-y', '-f', 'walinuxagent']) except Exception as e: logging.debug(str(e)) try: run(g, ['apt-get', 'remove', '-y', '-f', 'waagent']) except Exception as e: logging.debug(str(e)) def main(): g = diskutils.MountDisk('/dev/sdb') DistroSpecific(g) utils.CommonRoutines(g) diskutils.UnmountDisk(g) if __name__ == '__main__': utils.RunTranslate(main, run_with_tracing=False)
def _install_virtio_drivers(g): """Rebuilds initramfs to ensure that virtio drivers are present.""" logging.info('Installing virtio drivers.') for kernel in g.ls('/lib/modules'): g.command(['dracut', '-v', '-f', '--kver', kernel]) def translate(): """Mounts the disk, runs translation steps, then unmounts the disk.""" include_gce_packages = utils.GetMetadataAttribute('install_gce_packages', 'true').lower() == 'true' g = diskutils.MountDisk('/dev/sdb') distro = _get_distro(g) _install_product(distro, g) _install_packages(g, include_gce_packages) _install_virtio_drivers(g) if include_gce_packages: logging.info('Enabling google services.') g.sh('systemctl enable /usr/lib/systemd/system/google-*') _reset_network(g) _update_grub(g) utils.CommonRoutines(g) diskutils.UnmountDisk(g) if __name__ == '__main__': utils.RunTranslate(translate)