def __init__(self, envs=os.environ): """ Figures out the Consul client hostname based on whether or not we're using a local Consul agent. """ if env('CONSUL_AGENT', False, envs, fn=to_flag): self.host = 'localhost' else: self.host = env('CONSUL', 'consul', envs) self.client = pyconsul.Consul(host=self.host)
def __init__(self, envs=os.environ): self.mysql_db = env('MYSQL_DATABASE', None, envs) self.mysql_user = env('MYSQL_USER', None, envs) self.mysql_password = env('MYSQL_PASSWORD', None, envs) self.mysql_root_password = env('MYSQL_ROOT_PASSWORD', '', envs) self.mysql_random_root_password = env('MYSQL_RANDOM_ROOT_PASSWORD', True, envs, to_flag) self.mysql_onetime_password = env('MYSQL_ONETIME_PASSWORD', False, envs, to_flag) self.repl_user = env('MYSQL_REPL_USER', None, envs) self.repl_password = env('MYSQL_REPL_PASSWORD', None, envs) self.datadir = env('MYSQL_DATADIR', '/var/lib/mysql', envs) self.pool_size = env('INNODB_BUFFER_POOL_SIZE', 0, envs, fn=int) # state self.ip = get_ip() self._conn = None self._query_buffer = OrderedDict()
def __init__(self, envs=os.environ): self.access_key = env('MINIO_ACCESS_KEY', None, envs) self.secret_key = env('MINIO_SECRET_KEY', None, envs) self.bucket = env('MINIO_BUCKET', 'backups', envs) self.location = env('MINIO_LOCATION', 'us-east-1', envs) self.url = env('MINIO_URL', 'minio:9000') timeout = env('MINIO_TIMEOUT', '120', envs) is_tls = env('MINIO_TLS_SECURE', False, envs, fn=to_flag) self.client = pyminio(self.url, access_key=self.access_key, secret_key=self.secret_key, secure=is_tls, timeout=float(timeout))
def load(self, envs=os.environ): """ Fetches the ContainerPilot config file and asks ContainerPilot to render it out so that all environment variables have been interpolated. """ self.path = env('CONTAINERPILOT', None, envs) try: cfg = subprocess.check_output( ['containerpilot', '-config', self.path, '-template'], env=envs.copy()) except (subprocess.CalledProcessError, OSError) as ex: log.error('containerpilot -template returned error: %s', ex) raise (ex) config = json5.loads(cfg) self.config = config
def __init__(self, envs=os.environ): self.access_key = env('MINIO_ACCESS_KEY', None, envs) self.secret_key = env('MINIO_SECRET_KEY', None, envs) self.bucket = env('MINIO_BUCKET', 'backups', envs) self.location = env('MINIO_LOCATION', 'us-east-1', envs) self.url = env('MINIO_URL', 'minio:9000') is_tls = env('MINIO_TLS_SECURE', False, envs, fn=to_flag) self.client = pyminio(self.url, access_key=self.access_key, secret_key=self.secret_key, secure=is_tls) try: self.client.make_bucket(self.bucket, location=self.location) except minioerror.BucketAlreadyOwnedByYou: pass
def __init__(self, envs=os.environ): self.account = env('MANTA_USER', None, envs) self.user = env('MANTA_SUBUSER', None, envs) self.role = env('MANTA_ROLE', None, envs) self.key_id = env('MANTA_KEY_ID', None, envs) self.url = env('MANTA_URL', 'https://us-east.manta.joyent.com', envs) self.bucket = env('MANTA_BUCKET', '/{}/stor'.format(self.account), envs) is_tls = env('MANTA_TLS_INSECURE', False, envs, fn=to_flag) # we don't want to use `env` here because we have a different # de-munging to do self.private_key = envs.get('MANTA_PRIVATE_KEY', '').replace('#', '\n') self.signer = pymanta.PrivateKeySigner(self.key_id, self.private_key) self.client = pymanta.MantaClient( self.url, self.account, subuser=self.user, role=self.role, disable_ssl_certificate_validation=is_tls, signer=self.signer)
def __init__(self, envs=os.environ): self.dir = env('STORAGE_DIR', '/tmp/snapshots', envs)
from datetime import datetime, timedelta import fcntl import json import os import time from manager.env import env, to_flag, \ PRIMARY_KEY, LAST_BACKUP_KEY, \ BACKUP_TTL, BACKUP_LOCK_KEY, LAST_BINLOG_KEY from manager.utils import debug, log, \ WaitTimeoutError, UnknownPrimary # pylint: disable=import-error,invalid-name,dangerous-default-value import consul as pyconsul SESSION_CACHE_FILE = env('SESSION_CACHE_FILE', '/tmp/mysql-session') SESSION_NAME = env('SESSION_NAME', 'mysql-primary-lock') SESSION_TTL = env('SESSION_TTL', 25, fn=int) FAILOVER_KEY = env('FAILOVER_IN_PROGRESS', 'FAILOVER_IN_PROGRESS') FAILOVER_SESSION_FILE = env('FAILOVER_SESSION_FILE', '/tmp/failover-session') MAX_SESSION=3600 class Consul(object): """ Consul represents the Consul instance this node talks to """ def __init__(self, envs=os.environ): """ Figures out the Consul client hostname based on whether or not we're using a local Consul agent. """ if env('CONSUL_AGENT', False, envs, fn=to_flag):