#-*- coding: utf-8 -*- """ 获取 cluster, lb 和 vip 信息. """ import time from libs import redisoj from web.const import REDIS_DB_LVS _redis_oj = redisoj.PooledConnection(REDIS_DB_LVS) client = _redis_oj.get() def cluster(name=None): """ 查询 cluster 信息. 如果 name 为 None, 返回所有 cluster 信息. """ if name is not None: key = "cluster:%s" % name _type = client.hget(key, "type") lbinfos = eval(client.hget(key, "lbinfos")) vip2ws = eval(client.hget(key, "vip2ws")) vipnets = eval(client.hget(key, "vipnets")) device = client.hget(key, "device") _cluster = { "name": name, "type": _type,
""" 返回 Nginx 配置文件的下载地址. """ import os import re import functools from libs import log, utils, loki, redisoj, storage from web.const import (NGINX_CONF_DIR, NGINX_TMP_STORAGE_DIR, NGINX_TEMPLATE_DIR, NGINX_UPSTREAM_TEMPLATE_FILE, NGINX_SSL_ORIGIN_DIR, NGINX_SSL_DEST_DIR, REDIS_DB_NGINX) from nginx.libs import global_id, template, upstream _redis_oj = redisoj.PooledConnection(REDIS_DB_NGINX) client = _redis_oj.get() logger = log.get_logger("Nginx CONF ") def _shell(cmd, _logger=logger): """ 执行命令, 记录日志. """ rc, so, se = utils.shell(cmd) if rc == 0: message = "cmd:%s" % cmd _logger.info(message) else: message = "cmd:%s, error:%s" % (cmd, se)