Revision eaa4c57c lib/objects.py

b/lib/objects.py
51 51

  
52 52

  
53 53
__all__ = ["ConfigObject", "ConfigData", "NIC", "Disk", "Instance",
54
           "OS", "Node", "NodeGroup", "Cluster", "FillDict"]
54
           "OS", "Node", "NodeGroup", "Cluster", "FillDict", "Network"]
55 55

  
56 56
_TIMESTAMPS = ["ctime", "mtime"]
57 57
_UUID = ["uuid"]
......
432 432
    "nodes",
433 433
    "nodegroups",
434 434
    "instances",
435
    "networks",
435 436
    "serial_no",
436 437
    ] + _TIMESTAMPS
437 438

  
......
444 445
    """
445 446
    mydict = super(ConfigData, self).ToDict()
446 447
    mydict["cluster"] = mydict["cluster"].ToDict()
447
    for key in "nodes", "instances", "nodegroups":
448
    for key in "nodes", "instances", "nodegroups", "networks":
448 449
      mydict[key] = self._ContainerToDicts(mydict[key])
449 450

  
450 451
    return mydict
......
459 460
    obj.nodes = cls._ContainerFromDicts(obj.nodes, dict, Node)
460 461
    obj.instances = cls._ContainerFromDicts(obj.instances, dict, Instance)
461 462
    obj.nodegroups = cls._ContainerFromDicts(obj.nodegroups, dict, NodeGroup)
463
    obj.networks = cls._ContainerFromDicts(obj.networks, dict, Network)
462 464
    return obj
463 465

  
464 466
  def HasAnyDiskOfType(self, dev_type):
......
495 497
      # gives a good approximation.
496 498
      if self.HasAnyDiskOfType(constants.LD_DRBD8):
497 499
        self.cluster.drbd_usermode_helper = constants.DEFAULT_DRBD_HELPER
500
    if self.networks is None:
501
      self.networks = {}
498 502

  
499 503

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

  
504 508
  @classmethod
505 509
  def CheckParameterSyntax(cls, nicparams):
......
1359 1363
    "hv_state_static",
1360 1364
    "disk_state_static",
1361 1365
    "alloc_policy",
1366
    "networks",
1362 1367
    ] + _TIMESTAMPS + _UUID
1363 1368

  
1364 1369
  def ToDict(self):
......
1406 1411
    if self.ipolicy is None:
1407 1412
      self.ipolicy = MakeEmptyIPolicy()
1408 1413

  
1414
    if self.networks is None:
1415
      self.networks = {}
1416

  
1409 1417
  def FillND(self, node):
1410 1418
    """Return filled out ndparams for L{objects.Node}
1411 1419

  
......
1989 1997
    return True
1990 1998

  
1991 1999

  
2000
class Network(ConfigObject):
2001
  """Object representing a network definition for ganeti.
2002

  
2003
  """
2004
  __slots__ = [
2005
    "name",
2006
    "serial_no",
2007
    "network_type",
2008
    "mac_prefix",
2009
    "family",
2010
    "network",
2011
    "network6",
2012
    "gateway",
2013
    "gateway6",
2014
    "size",
2015
    "reservations",
2016
    "ext_reservations",
2017
    ] + _TIMESTAMPS + _UUID
2018

  
2019

  
1992 2020
class SerializableConfigParser(ConfigParser.SafeConfigParser):
1993 2021
  """Simple wrapper over ConfigParse that allows serialization.
1994 2022

  

Also available in: Unified diff