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")
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")
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)
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)
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)
def run(self, vtm, name, nodes, algorithm, persistence, monitors): vtm = Vtm(self.config, self.logger, vtm) vtm.addPool(name, nodes, algorithm, persistence, monitors)
def run(self, vtm, name, pool, tip, port, protocol): vtm = Vtm(self.config, self.logger, vtm) vtm.addVserver(name, pool, tip, port, protocol)
def run(self, vtm, name, cert, xproto, headers): vtm = Vtm(self.config, self.logger, vtm) vtm.enableSSLOffload(name, cert, True, xproto, headers)
def run(self, vtm, name): vtm = Vtm(self.config, self.logger, vtm) vtm.delTip(name)
def run(self, vtm, name, vtms, addresses, extra): vtm = Vtm(self.config, self.logger, vtm) vtm.add_tip(name, vtms, addresses, extra)
def run(self, vtm, name): vtm = Vtm(self.config, self.logger, vtm) output = vtm.restore_backup(name) return (True, output)
def run(self, vtm, name): vtm = Vtm(self.config, self.logger, vtm) vtm.del_pool(name) return (True, None)
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)
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)
def run(self, vtm, name, description): vtm = Vtm(self.config, self.logger, vtm) vtm.create_backup(name, description) return (True, None)
def run(self, vtm, name, method, cookie): vtm = Vtm(self.config, self.logger, vtm) vtm.addSessionPersistence(name, method, cookie)
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)
def run(self, vtm, name, method, cookie): vtm = Vtm(self.config, self.logger, vtm) vtm.add_session_persistence(name, method, cookie)
def run(self, vtm, name, verify): vtm = Vtm(self.config, self.logger, vtm) vtm.enableSSLEncryption(name, True, verify)
def run(self, vtm, name): vtm = Vtm(self.config, self.logger, vtm) vtm.delSessionPersistence(name)
def run(self, vtm, name, public, private): vtm = Vtm(self.config, self.logger, vtm) vtm.add_server_cert(name, public, private)
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)
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)
def run(self, vtm, name): vtm = Vtm(self.config, self.logger, vtm) vtm.del_server_cert(name) return (True, None)
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)
def run(self, vtm, pool): vtm = Vtm(self.config, self.logger, vtm) result = vtm.get_pool_nodes(pool) return (True, result)
def run(self, vtm, name, verify): vtm = Vtm(self.config, self.logger, vtm) vtm.enable_ssl_encryption(name, True, verify) return (True, None)
def run(self, vtm, name): vtm = Vtm(self.config, self.logger, vtm) vtm.delete_backup(name) return (True, None)