Revision d89168ff

b/doc/hooks.rst
286 286
INSTANCE_OS_TYPE, INSTANCE_DISK_TEMPLATE, INSTANCE_MEMORY,
287 287
INSTANCE_DISK_SIZES, INSTANCE_VCPUS, INSTANCE_NIC_COUNT,
288 288
INSTANCE_NICn_IP, INSTANCE_NICn_BRIDGE, INSTANCE_NICn_MAC,
289
INSTANCE_NICn_NETWORK_SUBNET, INSTANCE_NICn_NETWORK_GATEWAY,
290
INSTANCE_NICn_NETWORK_SUBNET6, INSTANCE_NICn_NETWORK_GATEWAY6,
291
INSTANCE_NICn_NETWORK_MAC_PREFIX, INSTANCE_NICn_NETWORK_TYPE,
292
INSTANCE_DISK_COUNT, INSTANCE_DISKn_SIZE, INSTANCE_DISKn_MODE.
289
INSTANCE_NICn_NETWORK, INSTANCE_NICn_NETWORK_FAMILY,
290
INSTANCE_NICn_NETWORK_UUID, INSTANCE_NICn_NETWORK_SUBNET,
291
INSTANCE_NICn_NETWORK_GATEWAY, INSTANCE_NICn_NETWORK_SUBNET6,
292
INSTANCE_NICn_NETWORK_GATEWAY6, INSTANCE_NICn_NETWORK_MAC_PREFIX,
293
INSTANCE_NICn_NETWORK_TYPE, INSTANCE_DISK_COUNT, INSTANCE_DISKn_SIZE,
294
INSTANCE_DISKn_MODE.
293 295

  
294 296
The INSTANCE_NICn_* and INSTANCE_DISKn_* variables represent the
295 297
properties of the *n* -th NIC and disk, and are zero-indexed.
b/lib/backend.py
2498 2498
      result["NIC_%d_BRIDGE" % idx] = nic.nicparams[constants.NIC_LINK]
2499 2499
    if nic.nicparams[constants.NIC_LINK]:
2500 2500
      result["NIC_%d_LINK" % idx] = nic.nicparams[constants.NIC_LINK]
2501
    if nic.network:
2502
      result["NIC_%d_NETWORK" % idx] = nic.network
2501
    if nic.netinfo:
2502
      nobj = objects.Network.FromDict(nic.netinfo)
2503
      result.update(nobj.HooksDict("NIC_%d_" % idx))
2504
    elif nic.network:
2505
      # FIXME: broken network reference: the instance NIC specifies a network,
2506
      # but the relevant network entry was not in the config. This should be
2507
      # made impossible.
2508
      result["INSTANCE_NIC%d_NETWORK" % idx] = nic.network
2503 2509
    if constants.HV_NIC_TYPE in instance.hvparams:
2504 2510
      result["NIC_%d_FRONTEND_TYPE" % idx] = \
2505 2511
        instance.hvparams[constants.HV_NIC_TYPE]
b/lib/cmdlib.py
1453 1453
  @type vcpus: string
1454 1454
  @param vcpus: the count of VCPUs the instance has
1455 1455
  @type nics: list
1456
  @param nics: list of tuples (ip, mac, mode, link, network) representing
1456
  @param nics: list of tuples (ip, mac, mode, link, net, netinfo) representing
1457 1457
      the NICs the instance has
1458 1458
  @type disk_template: string
1459 1459
  @param disk_template: the disk template of the instance
......
1495 1495
      env["INSTANCE_NIC%d_MAC" % idx] = mac
1496 1496
      env["INSTANCE_NIC%d_MODE" % idx] = mode
1497 1497
      env["INSTANCE_NIC%d_LINK" % idx] = link
1498
      if network:
1498
      if netinfo:
1499
        nobj = objects.Network.FromDict(netinfo)
1500
        env.update(nobj.HooksDict("INSTANCE_NIC%d_" % idx))
1501
      elif network:
1502
        # FIXME: broken network reference: the instance NIC specifies a
1503
        # network, but the relevant network entry was not in the config. This
1504
        # should be made impossible.
1499 1505
        env["INSTANCE_NIC%d_NETWORK" % idx] = net
1500
        if netinfo:
1501
          nobj = objects.Network.FromDict(netinfo)
1502
          if nobj.network:
1503
            env["INSTANCE_NIC%d_NETWORK_SUBNET" % idx] = nobj.network
1504
          if nobj.gateway:
1505
            env["INSTANCE_NIC%d_NETWORK_GATEWAY" % idx] = nobj.gateway
1506
          if nobj.network6:
1507
            env["INSTANCE_NIC%d_NETWORK_SUBNET6" % idx] = nobj.network6
1508
          if nobj.gateway6:
1509
            env["INSTANCE_NIC%d_NETWORK_GATEWAY6" % idx] = nobj.gateway6
1510
          if nobj.mac_prefix:
1511
            env["INSTANCE_NIC%d_NETWORK_MAC_PREFIX" % idx] = nobj.mac_prefix
1512
          if nobj.network_type:
1513
            env["INSTANCE_NIC%d_NETWORK_TYPE" % idx] = nobj.network_type
1514
          if nobj.tags:
1515
            env["INSTANCE_NIC%d_NETWORK_TAGS" % idx] = " ".join(nobj.tags)
1516 1506
      if mode == constants.NIC_MODE_BRIDGED:
1517 1507
        env["INSTANCE_NIC%d_BRIDGE" % idx] = link
1518 1508
  else:
b/lib/objects.py
2039 2039
    "ext_reservations",
2040 2040
    ] + _TIMESTAMPS + _UUID
2041 2041

  
2042
  def HooksDict(self, prefix):
2043
    """Export a dictionary used by hooks with a network's information.
2044

  
2045
    @type prefix: String
2046
    @param prefix: Prefix to prepend to the dict entries
2047

  
2048
    """
2049
    result = {
2050
      "%sNETWORK" % prefix: self.name,
2051
      "%sNETWORK_UUID" % prefix: self.uuid,
2052
      "%sNETWORK_FAMILY" % prefix: str(self.family),
2053
      "%sNETWORK_TAGS" % prefix: " ".join(self.tags),
2054
    }
2055
    if self.network:
2056
      result["%sNETWORK_SUBNET" % prefix] = self.network
2057
    if self.gateway:
2058
      result["%sNETWORK_GATEWAY" % prefix] = self.gateway
2059
    if self.network6:
2060
      result["%sNETWORK_SUBNET6" % prefix] = self.network6
2061
    if self.gateway6:
2062
      result["%sNETWORK_GATEWAY6" % prefix] = self.gateway6
2063
    if self.mac_prefix:
2064
      result["%sNETWORK_MAC_PREFIX" % prefix] = self.mac_prefix
2065
    if self.network_type:
2066
      result["%sNETWORK_TYPE" % prefix] = self.network_type
2067

  
2068
    return result
2069

  
2042 2070

  
2043 2071
class SerializableConfigParser(ConfigParser.SafeConfigParser):
2044 2072
  """Simple wrapper over ConfigParse that allows serialization.
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
122
    (Optional) If a NIC network is specified, the network's name.
123

  
124
NIC_%d_NETWORK_UUID
125
    (Optional) If a NIC network is specified, the network's uuid.
126

  
127
NIC_%d_NETWORK_FAMILY
128
    (Optional) If a NIC network is specified, the network's family.
129

  
130
NIC_%d_NETWORK_SUBNET
131
    (Optional) If a NIC network is specified, the network's IPv4 subnet.
132

  
133
NIC_%d_NETWORK_GATEWAY
134
    (Optional) If a NIC network is specified, the network's IPv4
135
    gateway.
136

  
137
NIC_%d_NETWORK_SUBNET6
138
    (Optional) If a NIC network is specified, the network's IPv6 subnet.
139

  
140
NIC_%d_NETWORK_GATEWAY6
141
    (Optional) If a NIC network is specified, the network's IPv6
142
    gateway.
143

  
144
NIC_%d_NETWORK_MAC_PREFIX
145
    (Optional) If a NIC network is specified, the network's mac prefix.
146

  
147
NIC_%d_NETWORK_TYPE
148
    (Optional) If a NIC network is specified, the network's type.
149

  
150
NIC_%d_NETWORK_TAGS
151
    (Optional) If a NIC network is specified, the network's tags, space
152
    separated.
153

  
121 154
OSP_*name*
122 155
    Each OS parameter (see below) will be exported in its own
123 156
    variable, prefixed with ``OSP_``, and upper-cased. For example, a

Also available in: Unified diff