diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index da8c18301f8655acf1149354377561bde9c765a2..13e0ec4921a289419621a4071dc3daef744d4e4c 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -136,6 +136,31 @@ def _OpenTap(vnet_hdr=True): return (ifname, tapfd) +def _BuildNetworkEnv(name, network, gateway, network6, gateway6, + network_type, mac_prefix, tags, env): + """Build environment variables concerning a Network. + + """ + if name: + env["NETWORK_NAME"] = name + if network: + env["NETWORK_SUBNET"] = network + if gateway: + env["NETWORK_GATEWAY"] = gateway + if network6: + env["NETWORK_SUBNET6"] = network6 + if gateway6: + env["NETWORK_GATEWAY6"] = gateway6 + if mac_prefix: + env["NETWORK_MAC_PREFIX"] = mac_prefix + if network_type: + env["NETWORK_TYPE"] = network_type + if tags: + env["NETWORK_TAGS"] = " ".join(tags) + + return env + + class QmpMessage: """QEMU Messaging Protocol (QMP) message. @@ -775,27 +800,6 @@ class KVMHypervisor(hv_base.BaseHypervisor): if nic.nicparams[constants.NIC_LINK]: env["LINK"] = nic.nicparams[constants.NIC_LINK] - def _BuildNetworkEnv(name, network, gateway, network6, gateway6, - network_type, mac_prefix, tags, env): - if name: - env["NETWORK_NAME"] = name - if network: - env["NETWORK_SUBNET"] = network - if gateway: - env["NETWORK_GATEWAY"] = gateway - if network6: - env["NETWORK_SUBNET6"] = network6 - if gateway6: - env["NETWORK_GATEWAY6"] = gateway6 - if mac_prefix: - env["NETWORK_MAC_PREFIX"] = mac_prefix - if network_type: - env["NETWORK_TYPE"] = network_type - if tags: - env["NETWORK_TAGS"] = " ".join(tags) - - return env - if nic.network: n = objects.Network.FromDict(nic.netinfo) _BuildNetworkEnv(nic.network, n.network, n.gateway,