Revision fcbf3d43 lib/hypervisor/hv_kvm/__init__.py
b/lib/hypervisor/hv_kvm/__init__.py | ||
---|---|---|
596 | 596 |
return utils.PathJoin(cls._NICS_DIR, instance_name) |
597 | 597 |
|
598 | 598 |
@classmethod |
599 |
def _InstanceNICFile(cls, instance_name, seq): |
|
599 |
def _InstanceNICFile(cls, instance_name, seq_or_uuid):
|
|
600 | 600 |
"""Returns the name of the file containing the tap device for a given NIC |
601 | 601 |
|
602 | 602 |
""" |
603 |
return utils.PathJoin(cls._InstanceNICDir(instance_name), str(seq)) |
|
603 |
return utils.PathJoin(cls._InstanceNICDir(instance_name), str(seq_or_uuid)) |
|
604 |
|
|
605 |
@classmethod |
|
606 |
def _GetInstanceNICTap(cls, instance_name, nic): |
|
607 |
"""Returns the tap for the corresponding nic |
|
608 |
|
|
609 |
Search for tap file named after NIC's uuid. |
|
610 |
For old instances without uuid indexed tap files returns nothing. |
|
611 |
|
|
612 |
""" |
|
613 |
try: |
|
614 |
return utils.ReadFile(cls._InstanceNICFile(instance_name, nic.uuid)) |
|
615 |
except EnvironmentError: |
|
616 |
pass |
|
617 |
|
|
618 |
@classmethod |
|
619 |
def _WriteInstanceNICFiles(cls, instance_name, seq, nic, tap): |
|
620 |
"""Write tap name to both instance NIC files |
|
621 |
|
|
622 |
""" |
|
623 |
for ident in [seq, nic.uuid]: |
|
624 |
utils.WriteFile(cls._InstanceNICFile(instance_name, ident), data=tap) |
|
625 |
|
|
626 |
@classmethod |
|
627 |
def _RemoveInstanceNICFiles(cls, instance_name, seq, nic): |
|
628 |
"""Write tap name to both instance NIC files |
|
629 |
|
|
630 |
""" |
|
631 |
for ident in [seq, nic.uuid]: |
|
632 |
utils.RemoveFile(cls._InstanceNICFile(instance_name, ident)) |
|
604 | 633 |
|
605 | 634 |
@classmethod |
606 | 635 |
def _InstanceKeymapFile(cls, instance_name): |
Also available in: Unified diff