def _deserializeDhcpConfig(self, serializedNetCfg, serializedDhcpConfig): try: dhcpconfig = deserialize(serializedDhcpConfig, deserializeNetCfg(serializedNetCfg)) except CommonDHCPError: raise DHCPError(*CommonDHCPError.args) ok, msg = dhcpconfig.isValidWithMsg() if not ok: raise DHCPError(msg) return dhcpconfig
def service_setNetconfig(self, context, netcfg, message): """ Overrides the network configuration. Argument: a serialized NetCfg. Deserialization takes care of integrity testing, or should. """ netcfg = deserializeNetCfg(netcfg) ok, errmsg = netcfg.isValidWithMsg() if not ok: raise NetCfgError(errmsg) #if netcfg == self.netcfg: # return self.netcfg = netcfg self.save_config(CONFIG_MODIFICATION, message, context)
else: cm.commit(message) def read_config(self, responsible, *args, **kwargs): #responsible can be none need_autoconf = False try: config = self.core.config_manager.get(self.NAME) except ConfigError, err: self.important("Unable to load network configuration (%s)" % err) return ok = True try: netcfg = deserializeNetCfg(config, NetCfgAutoConf, parent=self) except NetCfgError, err: #FIXME: Try and fix structure when applicable instead of autoconfiguring need_autoconf = True self.writeError(err, title="Unable to load network configuration (%s): " "error while loading %s from configuration" % self.NAME) ok = False except DatastructureIncompatible, err: #FIXME: Upgrade structure when applicable instead of autoconfiguring need_autoconf = True self.important("Unable to load network configuration (%s): " "cannot deal with this unknown datastructure version" % err) ok = False if ok: ok, msg = netcfg.isValidWithMsg()