Revision 7e8f03e3

b/lib/cmdlib.py
1512 1512
        # FIXME: broken network reference: the instance NIC specifies a
1513 1513
        # network, but the relevant network entry was not in the config. This
1514 1514
        # should be made impossible.
1515
        env["INSTANCE_NIC%d_NETWORK" % idx] = net
1515
        env["INSTANCE_NIC%d_NETWORK_NAME" % idx] = net
1516 1516
      if mode == constants.NIC_MODE_BRIDGED:
1517 1517
        env["INSTANCE_NIC%d_BRIDGE" % idx] = link
1518 1518
  else:
b/lib/hypervisor/hv_kvm.py
148 148
  return (ifname, tapfd)
149 149

  
150 150

  
151
def _BuildNetworkEnv(name, network, gateway, network6, gateway6,
152
                     mac_prefix, tags, env):
153
  """Build environment variables concerning a Network.
154

  
155
  """
156
  if name:
157
    env["NETWORK_NAME"] = name
158
  if network:
159
    env["NETWORK_SUBNET"] = network
160
  if gateway:
161
    env["NETWORK_GATEWAY"] = gateway
162
  if network6:
163
    env["NETWORK_SUBNET6"] = network6
164
  if gateway6:
165
    env["NETWORK_GATEWAY6"] = gateway6
166
  if mac_prefix:
167
    env["NETWORK_MAC_PREFIX"] = mac_prefix
168
  if tags:
169
    env["NETWORK_TAGS"] = " ".join(tags)
170

  
171
  return env
172

  
173

  
174 151
class QmpMessage:
175 152
  """QEMU Messaging Protocol (QMP) message.
176 153

  
......
854 831

  
855 832
    if nic.network:
856 833
      n = objects.Network.FromDict(nic.netinfo)
857
      _BuildNetworkEnv(nic.network, n.network, n.gateway,
858
                       n.network6, n.gateway6,
859
                       n.mac_prefix, n.tags, env)
834
      env.update(n.HooksDict())
860 835

  
861 836
    if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED:
862 837
      env["BRIDGE"] = nic.nicparams[constants.NIC_LINK]
b/lib/objects.py
2043 2043
    "ext_reservations",
2044 2044
    ] + _TIMESTAMPS + _UUID
2045 2045

  
2046
  def HooksDict(self, prefix):
2046
  def HooksDict(self, prefix=""):
2047 2047
    """Export a dictionary used by hooks with a network's information.
2048 2048

  
2049 2049
    @type prefix: String
......
2051 2051

  
2052 2052
    """
2053 2053
    result = {
2054
      "%sNETWORK" % prefix: self.name,
2054
      "%sNETWORK_NAME" % prefix: self.name,
2055 2055
      "%sNETWORK_UUID" % prefix: self.uuid,
2056 2056
      "%sNETWORK_TAGS" % prefix: " ".join(self.tags),
2057 2057
    }
b/man/ganeti-os-interface.rst
118 118
    instance, this can be one of: ``rtl8139``, ``ne2k_pci``,
119 119
    ``ne2k_isa``, ``paravirtual``.
120 120

  
121
NIC_%d_NETWORK
121
NIC_%d_NETWORK_NAME
122 122
    (Optional) If a NIC network is specified, the network's name.
123 123

  
124 124
NIC_%d_NETWORK_UUID

Also available in: Unified diff