Example #1
0
    def serialize(self):
        serialized = PersistentID.serialize(self)
        serialized['label'] = self.label
        serialized['string_desc'] = unicode(self.net)
        serialized['service_ip_addrs'] = serializeElement(self.service_ip_addrs)
        serialized['primary_ip_addrs'] = serializeElement(self.primary_ip_addrs)
        serialized['secondary_ip_addrs'] = serializeElement(self.secondary_ip_addrs)

        return serialized
Example #2
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
Example #3
0
def deserializeNet(serialized, cls):
    #BEGIN backwards compatibility
    ip_addrs = serialized.get('ip_addrs')
    if ip_addrs is not None:
        #convert existing IPs in service IPs
        ip_addrs = set(dict2list(ip_addrs))
        serialized['service_ip_addrs'] = serializeElement(ip_addrs)
        del serialized['ip_addrs']
    #END backwards compatibility

    label = serialized.pop('label')
    net = IPy.IP(serialized.pop('string_desc'), make_net = True)
    for attr in ('primary_ip_addrs', 'secondary_ip_addrs', 'service_ip_addrs'):
        serialized[attr] = deserializeElement(serialized[attr])

    _keys2unicode(serialized)

    return cls(label, net, **serialized)
Example #4
0
def parse_ktutil_list(output):
    #TODO: do more ?
    #note: output is a list of lines
    return serializeElement(output)
Example #5
0
 def properties(self):
     items = {'title':    self.title,
              'filters':  self.filters,
              'scenario': self.scenario
             }
     return serializeElement(items)