Revision cbe4a0a5

b/lib/client/gnt_instance.py
1178 1178
    FormatParameterDict(buf, instance["be_instance"], be_actual, level=2)
1179 1179
    # TODO(ganeti 2.7) rework the NICs as well
1180 1180
    buf.write("    - NICs:\n")
1181
    for idx, (ip, mac, mode, link, network) in enumerate(instance["nics"]):
1181
    for idx, (ip, mac, mode, link, network, _) in enumerate(instance["nics"]):
1182 1182
      buf.write("      - nic/%d: MAC: %s, IP: %s,"
1183 1183
                " mode: %s, link: %s, network: %s\n" %
1184 1184
                (idx, mac, ip, mode, link, network))
b/lib/hypervisor/hv_kvm.py
775 775
    if nic.nicparams[constants.NIC_LINK]:
776 776
      env["LINK"] = nic.nicparams[constants.NIC_LINK]
777 777

  
778
    def _BuildNetworkEnv(name, network, gateway, network6, gateway6,
779
                         network_type, mac_prefix, tags, env):
780
      if name:
781
        env["NETWORK_NAME"] = name
782
      if network:
783
        env["NETWORK_SUBNET"] = network
784
      if gateway:
785
        env["NETWORK_GATEWAY"] = gateway
786
      if network6:
787
        env["NETWORK_SUBNET6"] = network6
788
      if gateway6:
789
        env["NETWORK_GATEWAY6"] = gateway6
790
      if mac_prefix:
791
        env["NETWORK_MAC_PREFIX"] = mac_prefix
792
      if network_type:
793
        env["NETWORK_TYPE"] = network_type
794
      if tags:
795
        env["NETWORK_TAGS"] = " ".join(tags)
796

  
797
      return env
798

  
799

  
778 800
    if nic.network:
779
      env["NETWORK"] = nic.network
801
      n = objects.Network.FromDict(nic.netinfo)
802
      _BuildNetworkEnv(nic.network, n.network, n.gateway,
803
                       n.network6, n.gateway6, n.network_type,
804
                       n.mac_prefix, n.tags, env)
780 805

  
781 806
    if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED:
782 807
      env["BRIDGE"] = nic.nicparams[constants.NIC_LINK]
b/lib/objects.py
503 503

  
504 504
class NIC(ConfigObject):
505 505
  """Config object representing a network card."""
506
  __slots__ = ["mac", "ip", "network", "nicparams"]
506
  __slots__ = ["mac", "ip", "network", "nicparams", "netinfo"]
507 507

  
508 508
  @classmethod
509 509
  def CheckParameterSyntax(cls, nicparams):
b/lib/rpc.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
35 35
import base64
36 36
import pycurl
37 37
import threading
38
import copy
38 39

  
39 40
from ganeti import utils
40 41
from ganeti import objects
......
666 667
      rpc_defs.ED_INST_DICT: self._InstDict,
667 668
      rpc_defs.ED_INST_DICT_HVP_BEP_DP: self._InstDictHvpBepDp,
668 669
      rpc_defs.ED_INST_DICT_OSP_DP: self._InstDictOspDp,
670
      rpc_defs.ED_NIC_DICT: self._NicDict,
669 671

  
670 672
      # Encoders annotating disk parameters
671 673
      rpc_defs.ED_DISKS_DICT_DP: self._DisksDictDP,
......
691 693
    _generated_rpc.RpcClientDnsOnly.__init__(self)
692 694
    _generated_rpc.RpcClientDefault.__init__(self)
693 695

  
696
  def _NicDict(self, nic):
697
    """Convert the given nic to a dict and encapsulate netinfo
698

  
699
    """
700
    n = copy.deepcopy(nic)
701
    if n.network:
702
      net_uuid = self._cfg.LookupNetwork(n.network)
703
      if net_uuid:
704
        nobj = self._cfg.GetNetwork(net_uuid)
705
        n.netinfo = objects.Network.ToDict(nobj)
706
    return n.ToDict()
707

  
694 708
  def _InstDict(self, instance, hvp=None, bep=None, osp=None):
695 709
    """Convert the given instance to a dict.
696 710

  
......
721 735
    idict["osparams"] = cluster.SimpleFillOS(instance.os, instance.osparams)
722 736
    if osp is not None:
723 737
      idict["osparams"].update(osp)
738
    idict["disks"] = self._DisksDictDP((instance.disks, instance))
724 739
    for nic in idict["nics"]:
725 740
      nic["nicparams"] = objects.FillDict(
726 741
        cluster.nicparams[constants.PP_DEFAULT],
727 742
        nic["nicparams"])
728
    idict["disks"] = self._DisksDictDP((instance.disks, instance))
743
      network = nic.get("network", None)
744
      if network:
745
        net_uuid = self._cfg.LookupNetwork(network)
746
        if net_uuid:
747
          nobj = self._cfg.GetNetwork(net_uuid)
748
          nic["netinfo"] = objects.Network.ToDict(nobj)
729 749
    return idict
730 750

  
731 751
  def _InstDictHvpBepDp(self, (instance, hvp, bep)):
b/lib/rpc_defs.py
70 70
 ED_COMPRESS,
71 71
 ED_BLOCKDEV_RENAME,
72 72
 ED_DISKS_DICT_DP,
73
 ED_SINGLE_DISK_DICT_DP) = range(1, 14)
73
 ED_SINGLE_DISK_DICT_DP,
74
 ED_NIC_DICT) = range(1, 15)
74 75

  
75 76

  
76 77
def _Prepare(calls):

Also available in: Unified diff