예제 #1
0
    def UpdateConfig(self, adrs, cnfxml, override):
        """
        Update configuration of specified WebBrick from specified file.

        Returns None if the operation is completed successfully, otherwise
        returns a page to be displayed describing the reason for non-completion.

        'adrs' is the IP address of the WebBrick top be updated.

        'cnfxml' is the text of the WebBrick XML configuration file to be uploaded.

        'override' is a dictionary of values that can be used to override values
        in the supplied DOM when generating the configuration commands; e.g.
            "password" - overrides password used with "LG" command
            "IP"       - overrides IP addresss set with "IA" command
        """
        #TODO: may need to add logic to allow rejection of commands/command forms
        #      not supported by older WebBricks?
        try:
            wbcfg = WebBrickConfig()
            dom   = parseXmlString(cnfxml)
            configcmds = wbcfg.makeConfigCommands(dom, override)
            # configcmds.append("RU")
            # Reboot WebBrick to work around RU command bug in some WebBrick firmware versions
            # TODO: 
            #   Consider: should the RU command be withdrawn?  
            #   How many buggy webbricks are in the wild?
            configcmds.append("RB")
            errs = ""
            for line in configcmds:
                if line[0] != '#':
                    SendHTTPCmd(adrs,line)
                    err = Wb6Status(adrs).getCmdStatus()
                    msg = None
                    if err == ERR_NotLoggedIn:
                        msg = "Incorrect WebBrick password ("+line+")"
                        err = 0
                    if err:
                        errs += "WebBrick command error: "+str(err)+",  ("+line+")\n"
                    if msg:
                        Warn(msg, "WbCfgManagerForm.UpdateConfig")
                        raise WbAccessException(msg)
        except Exception, e:
            return self.wbConfigError(
                "Failed to update WebBrick at %s" % (adrs), 
                escapeTextForHtml(str(e)))
예제 #2
0
 def WebBrickAdd(self, wbip):
     if not wbip or wbip == "(None)":
         return "Add WebBrick: no IP address specified"
     err = None
     cherrypy.session.acquire_lock()
     wbs = cherrypy.session.get("DiscoverWbs",[])
     new = True
     for wb in wbs:
         new = new and wb["ipAdr"] != wbip
     if new:
         try:
             wb = WbDiscoverCheck(wbip)
             if wb:
                 wbs.append(wb)
                 cherrypy.session["DiscoverWbs"] = wbs
             else:
                 err = self.wbConfigError(
                     "No WebBrick found with IP address %s"%(wbip))
         except Exception, e:
             err = self.wbConfigError(
                 "Error accessing WebBrick at %s"%(wbip),
                 escapeTextForHtml(str(e)))
예제 #3
0
                    if err == ERR_NotLoggedIn:
                        msg = "Incorrect WebBrick password ("+line+")"
                        err = 0
                    if err:
                        errs += "WebBrick command error: "+str(err)+",  ("+line+")\n"
                    if msg:
                        Warn(msg, "WbCfgManagerForm.UpdateConfig")
                        raise WbAccessException(msg)
        except Exception, e:
            return self.wbConfigError(
                "Failed to update WebBrick at %s" % (adrs), 
                escapeTextForHtml(str(e)))
        if errs:
            return self.wbConfigError(
                "Failure(s) updating WebBrick at %s" % (adrs), 
                escapeTextForHtml(errs))
        self.WebBrickFlushDiscovered()
        return None

    def CopyConfigSet(self, frset, toset):
        """
        Copy configuration set on gateway server
        """
        if frset == toset:
            return self.wbConfigError("Cannot copy configuration set to itself")
        if not ConfigSet.exists(toset):
            return self.wbConfigError("Target configuration set does not exist")
            # ConfigSet.create(toset)
        if Config.listNodes(toset):
            return self.wbConfigError(
                "Copy: target configuration set already contains node configuration data"+