Exemplo n.º 1
0
 def serialize(self):
     serialized = PersistentID.serialize(self)
     for attr in Interface._STD_ATTRS:
         serialized[attr] = serializeElement(getattr(self, attr))
     for attr in 'nets routes'.split():
         collection = getattr(self, attr)
         serialized[attr] = list2dict(
             (item.serialize() for item in collection)
         )
     return serialized
Exemplo n.º 2
0
    def __init__(self, **kwargs):
        PersistentID.__init__(self, **kwargs)
        system_name = kwargs.get('system_name')
        user_label = kwargs.get('user_label')
        nets = kwargs.get('nets')
        routes = kwargs.get('routes')

        if user_label is None or user_label.strip() == u'':
            user_label = system_name

        assert isinstance(system_name, (unicode, str)), tr("Found system_name to be %s") % type(system_name)
        assert isinstance(user_label, (unicode, str)), tr("Found user_label to be %s") % type(user_label)
        self.system_name = system_name
        self.user_label = user_label

        if nets is None:
            nets = set()
        self.nets = nets

        if routes is None:
            routes = set()
        self.routes = set(routes)
        self.reserved_for_ha = kwargs.get("reserved_for_ha")