Exemplo n.º 1
0
def test_quote_values_with_spaces():
  expected = dedent("""
  # Added to support booting on Google Compute Engine.
  ARGS='a=b, c=d'
  """).strip()

  assert configs.update_grub_conf('', ARGS='a=b, c=d') == expected
Exemplo n.º 2
0
def _update_grub(g: guestfs.GuestFS):
  """Update and rebuild grub to ensure the image is bootable on GCP.
  See https://cloud.google.com/compute/docs/import/import-existing-image
  """
  g.write('/etc/default/grub', configs.update_grub_conf(
      g.cat('/etc/default/grub'),
      GRUB_CMDLINE_LINUX_DEFAULT='console=ttyS0,38400n8',
      GRUB_CMDLINE_LINUX='',
  ))
  g.command(['grub2-mkconfig', '-o', '/boot/grub2/grub.cfg'])
Exemplo n.º 3
0
def test_comment_all_occurrences():
  original = dedent("""
  ARGS=1,2
  ARGS=3,4
  """).strip()

  expected = dedent("""
  # Removed to support booting on Google Compute Engine.
  # ARGS=1,2
  # Removed to support booting on Google Compute Engine.
  # ARGS=3,4
  # Added to support booting on Google Compute Engine.
  ARGS=10
  """).strip()

  actual = configs.update_grub_conf(original, ARGS='10')

  assert actual == expected