Commit 8df21834 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Iustin Pop
Browse files

Move _BuildNetworkEnv() at top-level


Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 861a92b4
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment