Exemplo n.º 1
0
    def __init__(self, consul_client: ConsulClient):

        self.consul_client = consul_client

        self.postgres_url = consul_client.get(
            'postgres_url_sites_checker_service',
            prefix='sites-checker-service')

        self.vt_apikey = self.consul_client.get('apikey',
                                                prefix='sites-checker-service')

        self.job_interval = self.consul_client.get(
            'job_interval', prefix='sites-checker-service')

        self.data_src_folder = self.consul_client.get(
            'data_src_folfer', prefix='sites-checker-service')

        self.data_src_url = self.consul_client.get(
            'data_src_url', prefix='sites-checker-service')

        self.virus_total_src_folfer = self.consul_client.get(
            'virus_total_src_folfer', prefix='sites-checker-service')

        self.vt_ip_base_url = self.consul_client.get(
            'vt_ip_base_url', prefix='sites-checker-service')

        self.vt_domains_base_url = self.consul_client.get(
            'vt_domains_base_url', prefix='sites-checker-service')

        self.vt_urls_base_url = self.consul_client.get(
            'vt_urls_base_url', prefix='sites-checker-service')

        #load in env : production , local ant other
        self.run_env = os.environ['RUNS_IN_DOCKER'] or -1
Exemplo n.º 2
0
def create_kv_client(kv_store, host, port):
    '''
    Factory for creating a client interface to a KV store

    :param kv_store: Specify either 'etcd' or 'consul'
    :param host: Name or IP address of host serving the KV store
    :param port: Port number (integer) of the KV service
    :return: Reference to newly created client interface
    '''
    if kv_store == 'etcd':
        return EtcdClient(host, port)
    elif kv_store == 'consul':
        return ConsulClient(host, port)
    return None
Exemplo n.º 3
0
def mount_os_info():
    consul_client = ConsulClient(host=os.getenv('CONSUL_HOST', '127.0.0.1'))
    consul_client.connect()

    display_width = 1920
    display_height = 1080

    # get screen resolution
    try:
        display_width = get_monitors()[0].width
        display_height = get_monitors()[0].height
    except Exception as ex:
        print("Could not determine screen size, fallback is 1920x1080")
        print(ex)

    consul_client.put(key='display_width',
                      value=display_width,
                      prefix='shared')
    consul_client.put(key='display_height',
                      value=display_height,
                      prefix='shared')
Exemplo n.º 4
0
import os
import json
from PyInquirer import prompt
from tabulate import tabulate
from consul_client import ConsulClient

CONFIGS_DIR = os.path.abspath(
    os.path.join(os.path.dirname(__file__), '..', 'configs'))

consul_client = ConsulClient(host=os.getenv('CONSUL_HOST', '127.0.0.1'))

if __name__ == '__main__':
    try:
        print('\n')
        table = []
        all_keys = consul_client.get_all()
        if all_keys:
            for key in all_keys:
                table.append([
                    key['Key'],
                    json.dumps(key['Value'], sort_keys=True, indent=4)
                ])
            print('Current configs in http://localhost:8500')
            print('\n')
            print(tabulate(table, headers=["Key", "Value"]))
            print('\n')
    except TypeError:
        pass
    questions = [{
        'type': 'list',
        'name': 'file',
Exemplo n.º 5
0
 def provide_consul_client(self) -> ConsulClient:
     """innit consul client"""
     consul_client = ConsulClient(host=os.getenv('CONSUL_HOST',
                                                 '127.0.0.1'),
                                  prefix='sites-checker-service')
     return consul_client