Revision 9dcc20b4 lib/hypervisor/hv_kvm.py

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

  
947 947
  @classmethod
948
  def _InstanceNICFile(cls, instance_name, seq):
948
  def _InstanceNICFile(cls, instance_name, seq_or_uuid):
949 949
    """Returns the name of the file containing the tap device for a given NIC
950 950

  
951 951
    """
952
    return utils.PathJoin(cls._InstanceNICDir(instance_name), str(seq))
952
    return utils.PathJoin(cls._InstanceNICDir(instance_name), str(seq_or_uuid))
953

  
954
  @classmethod
955
  def _GetInstanceNICTap(cls, instance_name, nic):
956
    """Returns the tap for the corresponding nic
957

  
958
    Search for tap file named after NIC's uuid.
959
    For old instances without uuid indexed tap files returns nothing.
960

  
961
    """
962
    try:
963
      return utils.ReadFile(cls._InstanceNICFile(instance_name, nic.uuid))
964
    except EnvironmentError:
965
      pass
966

  
967
  @classmethod
968
  def _WriteInstanceNICFiles(cls, instance_name, seq, nic, tap):
969
    """Write tap name to both instance NIC files
970

  
971
    """
972
    for ident in [seq, nic.uuid]:
973
      utils.WriteFile(cls._InstanceNICFile(instance_name, ident), data=tap)
974

  
975
  @classmethod
976
  def _RemoveInstanceNICFiles(cls, instance_name, seq, nic):
977
    """Write tap name to both instance NIC files
978

  
979
    """
980
    for ident in [seq, nic.uuid]:
981
      utils.RemoveFile(cls._InstanceNICFile(instance_name, ident))
953 982

  
954 983
  @classmethod
955 984
  def _InstanceKeymapFile(cls, instance_name):

Also available in: Unified diff