Revision 1a63f285 lib/hypervisor/hv_xen.py

b/lib/hypervisor/hv_xen.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
86 86
    This version of the function just writes the config file from static data.
87 87

  
88 88
    """
89
    utils.WriteFile(XenHypervisor._ConfigFileName(instance_name), data=data)
89
    # just in case it exists
90
    utils.RemoveFile("/etc/xen/auto/%s" % instance_name)
91
    cfg_file = XenHypervisor._ConfigFileName(instance_name)
92
    try:
93
      utils.WriteFile(cfg_file, data=data)
94
    except EnvironmentError, err:
95
      raise errors.HypervisorError("Cannot write Xen instance configuration"
96
                                   " file %s: %s" % (cfg_file, err))
90 97

  
91 98
  @staticmethod
92 99
  def _ReadConfigFile(instance_name):
......
685 692
      config.write("on_reboot = 'destroy'\n")
686 693
    config.write("on_crash = 'restart'\n")
687 694
    config.write("extra = '%s'\n" % hvp[constants.HV_KERNEL_ARGS])
688
    # just in case it exists
689
    utils.RemoveFile("/etc/xen/auto/%s" % instance.name)
690
    try:
691
      utils.WriteFile(cls._ConfigFileName(instance.name),
692
                      data=config.getvalue())
693
    except EnvironmentError, err:
694
      raise errors.HypervisorError("Cannot write Xen instance confile"
695
                                   " file %s: %s" %
696
                                   (cls._ConfigFileName(instance.name), err))
695
    cls._WriteConfigFileStatic(instance.name, config.getvalue())
697 696

  
698 697
    return True
699 698

  
......
836 835
    else:
837 836
      config.write("on_reboot = 'destroy'\n")
838 837
    config.write("on_crash = 'restart'\n")
839
    # just in case it exists
840
    utils.RemoveFile("/etc/xen/auto/%s" % instance.name)
841
    try:
842
      utils.WriteFile(cls._ConfigFileName(instance.name),
843
                      data=config.getvalue())
844
    except EnvironmentError, err:
845
      raise errors.HypervisorError("Cannot write Xen instance confile"
846
                                   " file %s: %s" %
847
                                   (cls._ConfigFileName(instance.name), err))
838
    cls._WriteConfigFileStatic(instance.name, config.getvalue())
848 839

  
849 840
    return True

Also available in: Unified diff