Revision aec254f5

b/lib/hypervisor/hv_kvm.py
961 961
    return utils.PathJoin(cls._NICS_DIR, instance_name)
962 962

  
963 963
  @classmethod
964
  def _InstanceNICFile(cls, instance_name, seq):
964
  def _InstanceNICFile(cls, instance_name, seq_or_uuid):
965 965
    """Returns the name of the file containing the tap device for a given NIC
966 966

  
967 967
    """
968
    return utils.PathJoin(cls._InstanceNICDir(instance_name), str(seq))
968
    return utils.PathJoin(cls._InstanceNICDir(instance_name), str(seq_or_uuid))
969

  
970
  @classmethod
971
  def _GetInstanceNICTap(cls, instance_name, nic):
972
    """Returns the tap for the corresponding nic
973

  
974
    Search for tap file named after NIC's uuid.
975
    For old instances without uuid indexed tap files returns nothing.
976

  
977
    """
978
    try:
979
      return utils.ReadFile(cls._InstanceNICFile(instance_name, nic.uuid))
980
    except EnvironmentError:
981
      pass
982

  
983
  @classmethod
984
  def _WriteInstanceNICFiles(cls, instance_name, seq, nic, tap):
985
    """Write tap name to both instance NIC files
986

  
987
    """
988
    for ident in [seq, nic.uuid]:
989
      utils.WriteFile(cls._InstanceNICFile(instance_name, ident), data=tap)
990

  
991
  @classmethod
992
  def _RemoveInstanceNICFiles(cls, instance_name, seq, nic):
993
    """Write tap name to both instance NIC files
994

  
995
    """
996
    for ident in [seq, nic.uuid]:
997
      utils.RemoveFile(cls._InstanceNICFile(instance_name, ident))
969 998

  
970 999
  @classmethod
971 1000
  def _InstanceKeymapFile(cls, instance_name):

Also available in: Unified diff