Revision 36b31aea lib/hypervisor/hv_kvm/__init__.py
b/lib/hypervisor/hv_kvm/__init__.py | ||
---|---|---|
718 | 718 |
def _ConfigureNIC(instance, seq, nic, tap): |
719 | 719 |
"""Run the network configuration script for a specified NIC |
720 | 720 |
|
721 |
See L{hv_base.ConfigureNIC}. |
|
722 |
|
|
721 | 723 |
@param instance: instance we're acting on |
722 | 724 |
@type instance: instance object |
723 | 725 |
@param seq: nic sequence number |
... | ... | |
728 | 730 |
@type tap: str |
729 | 731 |
|
730 | 732 |
""" |
731 |
env = { |
|
732 |
"PATH": "%s:/sbin:/usr/sbin" % os.environ["PATH"], |
|
733 |
"INSTANCE": instance.name, |
|
734 |
"MAC": nic.mac, |
|
735 |
"MODE": nic.nicparams[constants.NIC_MODE], |
|
736 |
"INTERFACE": tap, |
|
737 |
"INTERFACE_INDEX": str(seq), |
|
738 |
"INTERFACE_UUID": nic.uuid, |
|
739 |
"TAGS": " ".join(instance.GetTags()), |
|
740 |
} |
|
741 |
|
|
742 |
if nic.ip: |
|
743 |
env["IP"] = nic.ip |
|
744 |
|
|
745 |
if nic.name: |
|
746 |
env["INTERFACE_NAME"] = nic.name |
|
747 |
|
|
748 |
if nic.nicparams[constants.NIC_LINK]: |
|
749 |
env["LINK"] = nic.nicparams[constants.NIC_LINK] |
|
750 |
|
|
751 |
if constants.NIC_VLAN in nic.nicparams: |
|
752 |
env["VLAN"] = nic.nicparams[constants.NIC_VLAN] |
|
753 |
|
|
754 |
if nic.network: |
|
755 |
n = objects.Network.FromDict(nic.netinfo) |
|
756 |
env.update(n.HooksDict()) |
|
757 |
|
|
758 |
if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED: |
|
759 |
env["BRIDGE"] = nic.nicparams[constants.NIC_LINK] |
|
760 |
|
|
761 |
result = utils.RunCmd([pathutils.KVM_IFUP, tap], env=env) |
|
762 |
if result.failed: |
|
763 |
raise errors.HypervisorError("Failed to configure interface %s: %s;" |
|
764 |
" network configuration script output: %s" % |
|
765 |
(tap, result.fail_reason, result.output)) |
|
733 |
hv_base.ConfigureNIC([pathutils.KVM_IFUP, tap], instance, seq, nic, tap) |
|
766 | 734 |
|
767 | 735 |
@staticmethod |
768 | 736 |
def _VerifyAffinityPackage(): |
Also available in: Unified diff