Revision 08208574 lib/objects.py

b/lib/objects.py
50 50

  
51 51

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

  
55 55
_TIMESTAMPS = ["ctime", "mtime"]
56 56
_UUID = ["uuid"]
......
439 439
    "nodes",
440 440
    "nodegroups",
441 441
    "instances",
442
    "networks",
442 443
    "serial_no",
443 444
    ] + _TIMESTAMPS
444 445

  
......
451 452
    """
452 453
    mydict = super(ConfigData, self).ToDict()
453 454
    mydict["cluster"] = mydict["cluster"].ToDict()
454
    for key in "nodes", "instances", "nodegroups":
455
    for key in "nodes", "instances", "nodegroups", "networks":
455 456
      mydict[key] = self._ContainerToDicts(mydict[key])
456 457

  
457 458
    return mydict
......
466 467
    obj.nodes = cls._ContainerFromDicts(obj.nodes, dict, Node)
467 468
    obj.instances = cls._ContainerFromDicts(obj.instances, dict, Instance)
468 469
    obj.nodegroups = cls._ContainerFromDicts(obj.nodegroups, dict, NodeGroup)
470
    obj.networks = cls._ContainerFromDicts(obj.networks, dict, Network)
469 471
    return obj
470 472

  
471 473
  def HasAnyDiskOfType(self, dev_type):
......
502 504
      # gives a good approximation.
503 505
      if self.HasAnyDiskOfType(constants.LD_DRBD8):
504 506
        self.cluster.drbd_usermode_helper = constants.DEFAULT_DRBD_HELPER
507
    if self.networks is None:
508
      self.networks = {}
505 509

  
506 510

  
507 511
class NIC(ConfigObject):
508 512
  """Config object representing a network card."""
509
  __slots__ = ["mac", "ip", "nicparams"]
513
  __slots__ = ["mac", "ip", "network", "nicparams"]
510 514

  
511 515
  @classmethod
512 516
  def CheckParameterSyntax(cls, nicparams):
......
1383 1387
    "hv_state_static",
1384 1388
    "disk_state_static",
1385 1389
    "alloc_policy",
1390
    "networks",
1386 1391
    ] + _TIMESTAMPS + _UUID
1387 1392

  
1388 1393
  def ToDict(self):
......
1430 1435
    if self.ipolicy is None:
1431 1436
      self.ipolicy = MakeEmptyIPolicy()
1432 1437

  
1438
    if self.networks is None:
1439
      self.networks = {}
1440

  
1433 1441
  def FillND(self, node):
1434 1442
    """Return filled out ndparams for L{objects.Node}
1435 1443

  
......
2014 2022
    return True
2015 2023

  
2016 2024

  
2025
class Network(ConfigObject):
2026
  """Object representing a network definition for ganeti.
2027

  
2028
  """
2029
  __slots__ = [
2030
    "name",
2031
    "serial_no",
2032
    "network_type",
2033
    "mac_prefix",
2034
    "family",
2035
    "network",
2036
    "network6",
2037
    "gateway",
2038
    "gateway6",
2039
    "size",
2040
    "reservations",
2041
    "ext_reservations",
2042
    ] + _TIMESTAMPS + _UUID
2043

  
2044

  
2017 2045
class SerializableConfigParser(ConfigParser.SafeConfigParser):
2018 2046
  """Simple wrapper over ConfigParse that allows serialization.
2019 2047

  

Also available in: Unified diff