Esempio n. 1
0
    def start(self):
        """This function invokes start-stop daemon to bring up flowgrindd"""
        args = ["-p", "%u" % self._config["port"]]
        if (self._config["verbose"]):
            args.append("-d")
        if (self._config["dumpdir"]):
            args.append("-w")
            args.append(self._config["dumpdir"])

        cmd = ["start-stop-daemon", "--start", "--exec", self._daemon, "--"]
        cmd.extend(args)
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("flowgrindd.start(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" % line)
            # when an error occurs stdout is important too
            if len(stdout):
                stderr = stderr + stdout

        yield self._parent._dbpool.startedService(self._config,
                                                  rc,
                                                  message=stderr)
        defer.returnValue(rc)
Esempio n. 2
0
    def start(self):
        """This function invokes start-stop daemon to bring up the route monitor"""

        args = [ '-h', self._config['sink_host'],
                 '-p', str(self._config['sink_port']) ]
        if self._config['interface']:
            args.extend([ '-i', self.config['interface'] ] )
        cmd = [ "start-stop-daemon", "--start",
                "--pidfile", self._pidfile,
                "--exec", self._daemon,
                "--"]
        cmd.extend(args)
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("routemonitor.start(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" %line)
            # when an error occurs stdout is important too
            if len(stdout):
                stderr = stderr+stdout

        yield self._parent._dbpool.startedService(self._config,
                                                  rc, message=stderr)
        defer.returnValue(rc)
Esempio n. 3
0
    def start(self):
        """This function invokes start-stop daemon to bring up the route monitor"""

        args = [
            '-h', self._config['sink_host'], '-p',
            str(self._config['sink_port'])
        ]
        if self._config['interface']:
            args.extend(['-i', self.config['interface']])
        cmd = [
            "start-stop-daemon", "--start", "--pidfile", self._pidfile,
            "--exec", self._daemon, "--"
        ]
        cmd.extend(args)
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("routemonitor.start(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" % line)
            # when an error occurs stdout is important too
            if len(stdout):
                stderr = stderr + stdout

        yield self._parent._dbpool.startedService(self._config,
                                                  rc,
                                                  message=stderr)
        defer.returnValue(rc)
Esempio n. 4
0
 def reboot(self):
     # used to do calls in "parallel"
     deferredList = list()
     # set MeshConf node status
     deferredList.append(xmlrpc_meshconf("XmlRpcNodeStatusHandler.nodeRebooted",
                         socket.gethostname()))
     # do the actual reboot
     deferredList.append(twisted_execute(["/sbin/shutdown", "-r","now"],
                         shell=False))
     return defer.DeferredList(deferredList)
Esempio n. 5
0
 def reboot(self):
     # used to do calls in "parallel"
     deferredList = list()
     # set MeshConf node status
     deferredList.append(
         xmlrpc_meshconf("XmlRpcNodeStatusHandler.nodeRebooted",
                         socket.gethostname()))
     # do the actual reboot
     deferredList.append(
         twisted_execute(["/sbin/shutdown", "-r", "now"], shell=False))
     return defer.DeferredList(deferredList)
Esempio n. 6
0
    def stop(self):
        """This function unloads the netconsole module"""

        cmd = [ "/sbin/rmmod", "netconsole" ]
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("netconsole.stop(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" %line)
        yield self._parent._dbpool.stoppedService(self._config,
                                                  rc, message=stderr)
        defer.returnValue(rc)
Esempio n. 7
0
    def start(self):
        """This function loads the netconsole module."""

        cmd = [ "/usr/local/sbin/um_netconsole", self._config['logserver'],
                self._config['logport'].__str__() ]
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("netconsole.start(): Command failed with RC=%d", rc)
            for line in stderr.splitlines():
                error(" %s" %line)
        yield self._parent._dbpool.startedService(self._config,
                                                  rc, message=stderr)
        defer.returnValue(rc)
Esempio n. 8
0
    def stop(self):
        """This function unloads the netconsole module"""

        cmd = ["/sbin/rmmod", "netconsole"]
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("netconsole.stop(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" % line)
        yield self._parent._dbpool.stoppedService(self._config,
                                                  rc,
                                                  message=stderr)
        defer.returnValue(rc)
Esempio n. 9
0
    def stop(self):
        """ This function invokes start-stop-daemon to stop olsrd """

        cmd = [ "start-stop-daemon", "--stop",  "--quiet",
                "--exec", self._daemon,
                "--signal", "TERM",
                "--retry",  "5"]
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("relayd.stop(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" %line)
        yield self._parent._dbpool.stoppedService(self._config,
                                                  rc, message=stderr)
        defer.returnValue(rc)
Esempio n. 10
0
    def stop(self):
        """This function invokes start-stop-daemon to stop rinetd"""

        cmd = [
            "start-stop-daemon", "--stop", "--quiet", "--exec", self._daemon,
            "--signal", "TERM", "--retry", "5"
        ]
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("rinetd.stop(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" % line)
        yield self._parent._dbpool.stoppedService(self._config,
                                                  rc,
                                                  message=stderr)
        defer.returnValue(rc)
Esempio n. 11
0
    def start(self):
        """This function loads the netconsole module."""

        cmd = [
            "/usr/local/sbin/um_netconsole", self._config['logserver'],
            self._config['logport'].__str__()
        ]
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("netconsole.start(): Command failed with RC=%d", rc)
            for line in stderr.splitlines():
                error(" %s" % line)
        yield self._parent._dbpool.startedService(self._config,
                                                  rc,
                                                  message=stderr)
        defer.returnValue(rc)
Esempio n. 12
0
    def start(self):
        """ This function invokes start-stop daemon to bring up olsrd """

        args = ["-f", self._configfile, "-d", "0"]
        cmd = ["start-stop-daemon", "--start", "--exec", self._daemon, "--"]
        cmd.extend(args)
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("relayd.start(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" % line)
            # when an error occurs stdout is important too
            if len(stdout):
                stderr = stderr + stdout

        yield self._parent._dbpool.startedService(self._config,
                                                  rc,
                                                  message=stderr)
        defer.returnValue(rc)
Esempio n. 13
0
    def start(self):
        """ This function invokes start-stop daemon to bring up olsrd """

        args = ["-f", self._configfile, "-d", "0"]
        cmd = [ "start-stop-daemon", "--start",
                "--exec", self._daemon,
                "--"]
        cmd.extend(args)
        (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
        if len(stdout):
            debug(stdout)
        if (rc != 0):
            error("relayd.start(): Command failed with RC=%s", rc)
            for line in stderr.splitlines():
                error(" %s" %line)
            # when an error occurs stdout is important too
            if len(stdout):
                stderr = stderr+stdout

        yield self._parent._dbpool.startedService(self._config,
                                                  rc, message=stderr)
        defer.returnValue(rc)
Esempio n. 14
0
    def stop(self):
        """This function shuts down masquerading on an interface pair."""

        if not self._configs:
            self.warn("stop(): not initialized with configs")
            defer.returnValue(2)

        final_rc = 0
        for config in self._configs:
            internal_interface = config["internal_interface"]
            external_interface = config["external_interface"]

            self.info("Disabling masquerading for %s..." %internal_interface)
            cmd1 = self.iptables_del(if_in=external_interface,
                                     if_out=internal_interface,
                                     rulespec=self._rule_incoming)
            cmd2 = self.iptables_del(if_in=internal_interface,
                                     if_out=external_interface,
                                     rulespec=self._rule_outgoing)
            cmd3 = self.iptables_del(if_in=None,
                                     if_out=external_interface,
                                     rulespec=self._rule_nat)
            cmds = [ cmd1, cmd2, cmd3 ]

            for cmd in cmds:
                (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
                if len(stdout):
                    debug(stdout)

                if (rc != 0):
                    self.error("stop(): failed to delete rules internal: %s external: %s" %(internal_interface, external_interface))
                    for line in stderr.splitlines():
                        error(" %s" %line)
                    final_rc = rc
                    break

            yield self._parent._dbpool.stoppedService(config,
                                                      rc, message=stderr)
        defer.returnValue(final_rc)
Esempio n. 15
0
    def start(self):
        """This function brings up masquerading on a interface pair"""

        final_rc = 0

        for config in self._configs:
            internal_interface = config["internal_interface"]
            external_interface = config["external_interface"]

            self.info("Enabling masquerading for %s..." %internal_interface)
            cmd1 = self.iptables_add(if_in=external_interface,
                                     if_out=internal_interface,
                                     rulespec=self._rule_incoming)
            cmd2 = self.iptables_add(if_in=internal_interface,
                                     if_out=external_interface,
                                     rulespec=self._rule_outgoing)
            cmd3 = self.iptables_add(if_in=None,
                                     if_out=external_interface,
                                     rulespec=self._rule_nat)
            cmds = [ cmd1, cmd2, cmd3 ]

            for cmd in cmds:
                (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
                if len(stdout):
                    debug(stdout)

                if (rc != 0):
                    self.error("start(): failed to configure internal: %s external: %s" %(internal_interface, external_interface))
                    for line in stderr.splitlines():
                        error(" %s" %line)
                    final_rc = rc
                    break

            yield self._parent._dbpool.startedService(config,
                                                      rc, message=stderr)
        defer.returnValue(final_rc)
Esempio n. 16
0
    def start(self):
        """This function loads the routing entries module."""

        final_rc = 0

        for config in self._config:

            # iterate over routing entries
            errmsg = ""
            # first rc != 0 which happens
            tmp_rc  = 0
            for rentry in config["rentries"]:
                cmd = ["ip", "route", "add",
                       "%s/%s"   %(rentry["dest"], rentry["prefix"]),
                       "via",    rentry["gw"],
                       "dev",    rentry["nic"],
                       "metric", str(rentry["metric"])]
                if rentry["rt_table"]:
                    cmd.append("table")
                    cmd.append(str(rentry["rt_table"]))
                (stdout, stderr, rc) = yield twisted_execute(cmd, shell=False)
                if len(stdout):
                    debug(stdout)

                if (rc != 0):
                    self.error("start(): failed to setup route entry: %s" %rentry)
                    errmsg += stderr
                    tmp_rc = rc
                for line in stderr.splitlines():
                    error(" %s" %line)

            if (tmp_rc != 0):
                final_rc = tmp_rc
            yield self._parent._dbpool.startedService(config,
                                                      tmp_rc, message=errmsg)
        defer.returnValue(final_rc)