Revision 4390ccff

b/lib/hypervisor/hv_xen.py
51 51
    raise NotImplementedError
52 52

  
53 53
  @staticmethod
54
  def _WriteConfigFileStatic(instance_name, data):
55
    """Write the Xen config file for the instance.
56

  
57
    This version of the function just writes the config file from static data.
58

  
59
    """
60
    utils.WriteFile("/etc/xen/%s" % instance_name, data=data)
61

  
62
  @staticmethod
63
  def _ReadConfigFile(instance_name):
64
    """Returns the contents of the instance config file.
65

  
66
    """
67
    try:
68
      file_content = utils.ReadFile("/etc/xen/%s" % instance_name)
69
    except EnvironmentError, err:
70
      raise errors.HypervisorError("Failed to load Xen config file: %s" % err)
71
    return file_content
72

  
73
  @staticmethod
54 74
  def _RemoveConfigFile(instance_name):
55 75
    """Remove the xen configuration file.
56 76

  
......
266 286

  
267 287
    return disk_data
268 288

  
289
  def MigrationInfo(self, instance):
290
    """Get instance information to perform a migration.
291

  
292
    @type instance: L{objects.Instance}
293
    @param instance: instance to be migrated
294
    @rtype: string
295
    @return: content of the xen config file
296

  
297
    """
298
    return self._ReadConfigFile(instance.name)
299

  
300
  def AcceptInstance(self, instance, info, target):
301
    """Prepare to accept an instance.
302

  
303
    @type instance: L{objects.Instance}
304
    @param instance: instance to be accepted
305
    @type info: string
306
    @param info: content of the xen config file on the source node
307
    @type target: string
308
    @param target: target host (usually ip), on this node
309

  
310
    """
311
    pass
312

  
313
  def FinalizeMigration(self, instance, info, success):
314
    """Finalize an instance migration.
315

  
316
    After a successful migration we write the xen config file.
317
    We do nothing on a failure, as we did not change anything at accept time.
318

  
319
    @type instance: L{objects.Instance}
320
    @param instance: instance whose migration is being aborted
321
    @type info: string
322
    @param info: content of the xen config file on the source node
323
    @type success: boolean
324
    @param success: whether the migration was a success or a failure
325

  
326
    """
327
    if success:
328
      self._WriteConfigFileStatic(instance.name, info)
329

  
269 330
  def MigrateInstance(self, instance, target, live):
270 331
    """Migrate an instance to a target node.
271 332

  

Also available in: Unified diff