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)
def _deserialize(cls, serialized): kwargs = {} # add a default value for old conf if not serialized.has_key('reserved_for_ha'): serialized['reserved_for_ha'] = False for attr in Interface._STD_ATTRS: value = deserializeElement(serialized[attr]) kwargs[attr] = value for class_name, key in {RouteRW: 'routes', NetRW: 'nets'}.iteritems(): collection = set() try: for item in dict2list(serialized[key]): collection.add(class_name.deserialize(item,)) except KeyError: pass kwargs[key] = collection return kwargs
def load(self, items): items = deserializeElement(items) self.title = items.get('title', '') self.filters = items.get('filters', ()) self.scenario = items.get('scenario', [])
def success_upload(self, value): self.mainwindow.addToInfoArea(tr('[Keytab upload] Success!')) for item in deserializeElement(value): self.mainwindow.addToInfoArea(tr('[Keytab upload] %s') % item) self.signalModified()