Revision 1f0ab629 lib/hypervisor/hv_kvm/__init__.py

b/lib/hypervisor/hv_kvm/__init__.py
1390 1390
    except EnvironmentError, err:
1391 1391
      raise errors.HypervisorError("Failed to save KVM runtime file: %s" % err)
1392 1392

  
1393
  def _ReadKVMRuntime(self, instance_name):
1393
  @classmethod
1394
  def _ReadKVMRuntime(cls, instance_name):
1394 1395
    """Read an instance's KVM runtime
1395 1396

  
1396 1397
    """
1397 1398
    try:
1398
      file_content = utils.ReadFile(self._InstanceKVMRuntime(instance_name))
1399
      file_content = utils.ReadFile(cls._InstanceKVMRuntime(instance_name))
1399 1400
    except EnvironmentError, err:
1400 1401
      raise errors.HypervisorError("Failed to load KVM runtime file: %s" % err)
1401 1402
    return file_content
......
1414 1415

  
1415 1416
    self._WriteKVMRuntime(instance.name, serialized_form)
1416 1417

  
1417
  def _LoadKVMRuntime(self, instance, serialized_runtime=None):
1418
  @classmethod
1419
  def _LoadKVMRuntime(cls, instance_name, serialized_runtime=None):
1418 1420
    """Load an instance's KVM runtime
1419 1421

  
1420 1422
    """
1421 1423
    if not serialized_runtime:
1422
      serialized_runtime = self._ReadKVMRuntime(instance.name)
1424
      serialized_runtime = cls._ReadKVMRuntime(instance_name)
1423 1425

  
1424 1426
    return _AnalyzeSerializedRuntime(serialized_runtime)
1425 1427

  
......
1850 1852
    if device.pci is None:
1851 1853
      device.pci = self.qmp.GetFreePCISlot()
1852 1854
    kvm_devid = _GenerateDeviceKVMId(dev_type, device)
1853
    runtime = self._LoadKVMRuntime(instance)
1855
    runtime = self._LoadKVMRuntime(instance.name)
1854 1856
    if dev_type == constants.HOTPLUG_TARGET_DISK:
1855 1857
      uri = _GetDriveURI(device, extra[0], extra[1])
1856 1858
      self.qmp.HotAddDisk(device, kvm_devid, uri)
......
1880 1882
    invokes the device specific method.
1881 1883

  
1882 1884
    """
1883
    runtime = self._LoadKVMRuntime(instance)
1885
    runtime = self._LoadKVMRuntime(instance.name)
1884 1886
    entry = _GetExistingDeviceInfo(dev_type, device, runtime)
1885 1887
    kvm_device = _RUNTIME_DEVICE[dev_type](entry)
1886 1888
    kvm_devid = _GenerateDeviceKVMId(dev_type, kvm_device)
......
2028 2030
                                   " not running" % instance.name)
2029 2031
    # StopInstance will delete the saved KVM runtime so:
2030 2032
    # ...first load it...
2031
    kvm_runtime = self._LoadKVMRuntime(instance)
2033
    kvm_runtime = self._LoadKVMRuntime(instance.name)
2032 2034
    # ...now we can safely call StopInstance...
2033 2035
    if not self.StopInstance(instance):
2034 2036
      self.StopInstance(instance, force=True)
......
2060 2062
    @param target: target host (usually ip), on this node
2061 2063

  
2062 2064
    """
2063
    kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info)
2065
    kvm_runtime = self._LoadKVMRuntime(instance.name, serialized_runtime=info)
2064 2066
    incoming_address = (target, instance.hvparams[constants.HV_MIGRATION_PORT])
2065 2067
    kvmpath = instance.hvparams[constants.HV_KVM_PATH]
2066 2068
    kvmhelp = self._GetKVMOutput(kvmpath, self._KVMOPT_HELP)
......
2077 2079

  
2078 2080
    """
2079 2081
    if success:
2080
      kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info)
2082
      kvm_runtime = self._LoadKVMRuntime(instance.name, serialized_runtime=info)
2081 2083
      kvm_nics = kvm_runtime[1]
2082 2084

  
2083 2085
      for nic_seq, nic in enumerate(kvm_nics):

Also available in: Unified diff