예제 #1
0
    def run(self, errors, error_level):

        errors = json.loads(errors, encoding="utf-8")
        if "name" not in errors:
            raise Exception("Error: Instance name not provided in errors. Can not continue!")

        instance = errors["name"]
        vtm = Vtm(self.config, self.logger, instance)
        bsd = Bsd(self.config, self.logger)
        status = bsd.getStatus(instance)[0]

        nodes = errors["traffic_health"]["failed_nodes"]
        failedPools = {
            pool: [node["node"] for node in nodes for pool in node["pools"]] for node in nodes for pool in node["pools"]
        }

        for pool in failedPools.keys():
            nodes = vtm.getPoolNodes(pool)
            if set(nodes["active"]).issubset(failedPools[pool]):
                self.logger.debug("Pool Dead")
                for vs in status["traffic_health"]["virtual_servers"]:
                    if vs["pool"] == pool:
                        self.logger.debug("Putting VS: {} into maintenance.".format(vs["name"]))
                        vtm.enableMaintenance(vs["name"], "maintenance")
            else:
                self.logger.debug("Pool not dead")
예제 #2
0
    def run(self, errors, error_level):

        errors = json.loads(errors, encoding="utf-8")
        if "name" not in errors:
            raise Exception(
                "Error: Instance name not provided in errors. Can not continue!"
            )

        instance = errors["name"]
        vtm = Vtm(self.config, self.logger, instance)
        bsd = Bsd(self.config, self.logger)
        status = bsd.get_status(instance)[0]

        nodes = errors["traffic_health"]["failed_nodes"]
        failedPools = {
            pool: [node["node"] for node in nodes for pool in node["pools"]]
            for node in nodes for pool in node["pools"]
        }

        for pool in failedPools.keys():
            nodes = vtm.get_pool_nodes(pool)
            if set(nodes["active"]).issubset(failedPools[pool]):
                self.logger.debug("Pool Dead")
                for vs in status["traffic_health"]["virtual_servers"]:
                    if vs["pool"] == pool:
                        self.logger.debug(
                            "Putting VS: {} into maintenance.".format(
                                vs["name"]))
                        vtm.enable_maintenance(vs["name"], "maintenance")
            else:
                self.logger.debug("Pool not dead")
예제 #3
0
    def run(self, vtm, tarball):

        vtm = Vtm(self.config, self.logger, vtm)

        if path.exists(tarball) is True:
            fh = open(tarball, "rb")
            backup = fh.read()
            fh.close()
        else:
            sys.stderr.write("File does not exist: {}\n".format(tarball))
            return (False, None)

        result = vtm.upload_backup(backup)
        return (True, result)
예제 #4
0
    def run(self, vtm, name, outdir):

        vtm = Vtm(self.config, self.logger, vtm)

        if path.isdir(outdir) is True:
            outfile = "{}/backup_{}_{}.tar".format(outdir, vtm.vtm, name)
            if path.exists(outfile) is False:
                fh = open(outfile, "wb")
                backup = vtm.get_backup(name)
                fh.write(backup)
                fh.close()
                return (True, outfile)
            else:
                sys.stderr.write("File exists: {}\n".format(outfile))
                return (False, None)
        else:
            sys.stderr.write("Outdir is not a directory!\n")
            return (False, None)
예제 #5
0
    def run(self, vtm, name, api_hook, api_key, event):

        arguments = [{
            "name": "api-hook",
            "description": "St2 API Webhook",
            "value": api_hook
        }, {
            "name": "api-key",
            "description": "St2 API Token",
            "value": api_key
        }]

        program = "/opt/stackstorm/packs/vadc/files/st2-trigger.py"

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.upload_action_program("st2-trigger.py", program)
        vtm.add_action_program(name, "st2-trigger.py", arguments)
        if event is not None:
            vtm.add_event_type_action(event, name)
        return (True, None)
    def run(self, vtm, pool, nodes, drain):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.drainNodes(pool, nodes, drain)
예제 #7
0
    def run(self, vtm, name, nodes, algorithm, persistence, monitors):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.addPool(name, nodes, algorithm, persistence, monitors)
예제 #8
0
    def run(self, vtm, name, pool, tip, port, protocol):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.addVserver(name, pool, tip, port, protocol)
예제 #9
0
    def run(self, vtm, name, cert, xproto, headers):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.enableSSLOffload(name, cert, True, xproto, headers)
예제 #10
0
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.delTip(name)
예제 #11
0
    def run(self, vtm, name, vtms, addresses, extra):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.add_tip(name, vtms, addresses, extra)
예제 #12
0
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        output = vtm.restore_backup(name)
        return (True, output)
예제 #13
0
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.del_pool(name)
        return (True, None)
예제 #14
0
    def run(self, vtm, name, public, private):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.addServerCert(name, public, private)
    def run(self, vtm, vserver, rule, enable):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.enableMaintenance(vserver, rule, enable)
예제 #16
0
    def run(self, vtm, pool, nodes, drain):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.drain_nodes(pool, nodes, drain)
        return (True, None)
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.delServerCert(name)
예제 #18
0
    def run(self, vtm, pool, nodes, drain):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.drainNodes(pool, nodes, drain)
예제 #19
0
    def run(self, vtm, name, description):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.create_backup(name, description)
        return (True, None)
예제 #20
0
    def run(self, vtm, name, method, cookie):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.addSessionPersistence(name, method, cookie)
예제 #21
0
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.delVserver(name)
    def run(self, vtm, name, verify):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.enableSSLEncryption(name, False, verify)
예제 #23
0
    def run(self, vtm, name, method, cookie):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.add_session_persistence(name, method, cookie)
예제 #24
0
    def run(self, vtm, name, verify):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.enableSSLEncryption(name, True, verify)
예제 #25
0
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.delSessionPersistence(name)
예제 #26
0
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.delTip(name)
    def run(self, vtm, name, public, private):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.add_server_cert(name, public, private)
예제 #28
0
    def run(self, vtm):

        vtm = Vtm(self.config, self.logger, vtm)
        backups = vtm.list_backups()
        return (True, backups)
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.del_session_persistence(name)
        return (True, None)
예제 #30
0
    def run(self, vtm, pool):

        vtm = Vtm(self.config, self.logger, vtm)
        result = vtm.getPoolNodes(pool)
        return result
    def run(self, vtm, pool, active, draining, disabled):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.set_pool_nodes(pool, active, draining, disabled)
        return (True, None)
    def run(self, vtm, vserver, rule, enable):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.enable_maintenance(vserver, rule, enable)
        return (True, None)
예제 #33
0
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.del_server_cert(name)
        return (True, None)
예제 #34
0
    def run(self, vtm, name, xproto, headers):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.enable_ssl_offload(name, "", False, xproto, headers)
        return (True, None)
예제 #35
0
    def run(self, vtm, name, pool, tip, port, protocol):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.addVserver(name, pool, tip, port, protocol)
예제 #36
0
    def run(self, vtm, pool):

        vtm = Vtm(self.config, self.logger, vtm)
        result = vtm.get_pool_nodes(pool)
        return (True, result)
예제 #37
0
    def run(self, vtm, pool):

        vtm = Vtm(self.config, self.logger, vtm)
        result = vtm.getPoolNodes(pool)
        return result
예제 #38
0
    def run(self, vtm, name, verify):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.enable_ssl_encryption(name, True, verify)
        return (True, None)
예제 #39
0
    def run(self, vtm, name):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.delete_backup(name)
        return (True, None)
예제 #40
0
    def run(self, vtm, name, cert, xproto, headers):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.enableSSLOffload(name, cert, True, xproto, headers)
예제 #41
0
    def run(self, vtm, name, nodes, algorithm, persistence, monitors):

        vtm = Vtm(self.config, self.logger, vtm)
        vtm.addPool(name, nodes, algorithm, persistence, monitors)