Exemple #1
0
from zato.agent.load_balancer.haproxy_stats import HAProxyStats
from zato.common import MISC, TRACE1, ZATO_OK
from zato.common.haproxy import haproxy_stats, validate_haproxy_config
from zato.common.py23_.spring_ import SSLServer
from zato.common.repo import RepoManager
from zato.common.util import get_lb_agent_json_config, timeouting_popen

public_method_prefix = '_lb_agent_'
config_file = 'zato.config'

logger = logging.getLogger("")
logging.addLevelName('TRACE1', TRACE1)

# All known HAProxy commands
haproxy_commands = {}
for version, commands in haproxy_stats.items():
    haproxy_commands.update(commands)


class LoadBalancerAgent(SSLServer):
    def __init__(self, repo_dir):

        self.repo_dir = os.path.abspath(repo_dir)
        self.json_config = get_lb_agent_json_config(self.repo_dir)

        self.work_dir = os.path.abspath(
            os.path.join(self.repo_dir, self.json_config['work_dir']))
        self.haproxy_command = self.json_config['haproxy_command']
        self.verify_fields = self.json_config['verify_fields']

        self.keyfile = os.path.abspath(
Exemple #2
0
from zato.agent.load_balancer.config import backend_template, config_from_string, string_from_config, zato_item_token
from zato.agent.load_balancer.haproxy_stats import HAProxyStats
from zato.common import ZATO_OK
from zato.common.haproxy import haproxy_stats
from zato.common.repo import RepoManager
from zato.common.util import TRACE1

public_method_prefix = "_lb_agent_"
config_file = "zato.config"

logger = logging.getLogger("")
logging.addLevelName("TRACE1", TRACE1)

# All known HAProxy commands
haproxy_commands = {}
for version, commands in haproxy_stats.items():
    haproxy_commands.update(commands)

# We'll wait up to that many seconds for HAProxy to validate the config file.
HAPROXY_VALIDATE_TIMEOUT = 0.3


class LoadBalancerAgent(SSLServer):
    def __init__(self, repo_dir):

        self.repo_dir = os.path.abspath(repo_dir)
        self.json_config = json.loads(open(os.path.join(self.repo_dir, "lb-agent.conf")).read())

        self.work_dir = os.path.abspath(os.path.join(self.repo_dir, self.json_config["work_dir"]))
        self.haproxy_command = self.json_config["haproxy_command"]
        self.verify_fields = self.json_config["verify_fields"]