Ejemplo n.º 1
0
 def __init__(self, host):
     super().__init__(host)
     self._host = host
     self.DNS_NAME = 'seaweedfs-s3-localnode.tls.ai' if not helpers.is_k8s(self._host.SshDirect) else 'seaweedfs-s3.default.svc.cluster.local'
     self.filer_host = 'seaweedfs-filer-localnode.tls.ai' if not helpers.is_k8s(self._host.SshDirect) else 'seaweedfs-filer.default.svc.cluster.local'
     self.filer_port = 8888
     self.PORT = 8333
Ejemplo n.º 2
0
 def __init__(self, host):
     self._host = host
     self.DNS = 'kafka.tls.ai' if not helpers.is_k8s(self._host.SshDirect) \
             else 'kafka-cluster-kafka-brokers.default.svc.cluster.local'
     self.PORT = '9092'
     self._rpyc = None
     self._init_lock = threading.Lock()
Ejemplo n.º 3
0
 def __init__(self, host):
     self._host = host
     self.DNS_NAME = 'rabbitmq.tls.ai' if not helpers.is_k8s(
         self._host.SshDirect) else 'rabbitmq-ha.default.svc.cluster.local'
     self.PORT = 5672  # amqp
     self.ADMIN_PORT = 15672  # admin
     self.password = "******" if not helpers.is_k8s(
         self._host.SshDirect
     ) else self._host.SshDirect.execute(
         "kubectl get secret --namespace default rabbitmq-secret -o jsonpath='{.data.password}' | base64 --decode"
     )
     self.user = '******' if not helpers.is_k8s(
         self._host.SshDirect) else 'root'
     self.virtual_host = '/'
     self._amqp_tunnel = None
     self._admin_tunnel = None
     self._amqp_connection = None
Ejemplo n.º 4
0
 def __init__(self, host):
     self._host = host
     self.DNS_NAME = 'consul.tls.ai' if not helpers.is_k8s(
         self._host.SshDirect
     ) else 'consul-server.default.svc.cluster.local'
     self.PORT = 8500
     self.DEFAULT_KEY = "DEFAULT"
     self.OVERRIDE_KEY = "OVERRIDE"
     self.APPLICATION_KEY = "APPLICATION"
Ejemplo n.º 5
0
 def _create_connection(self, **kwargs):
     password = "******" if not helpers.is_k8s(
         self._host.SshDirect
     ) else self._host.SshDirect.execute(
         "kubectl get secret --namespace default memsql-secret -o jsonpath='{.data.password}' | base64 --decode"
     )
     memsql_kwargs = copy.copy(kwargs)
     if memsql_kwargs.get('password', None) is None:
         memsql_kwargs['password'] = self.password
     memsql_kwargs.setdefault('password', password)
     memsql_kwargs.setdefault('user', 'root')
     memsql_kwargs.setdefault('client_flag', CLIENT.MULTI_STATEMENTS)
     memsql_kwargs.setdefault('cursorclass', pymysql.cursors.DictCursor)
     return Connection(pymysql.connect(**memsql_kwargs))
Ejemplo n.º 6
0
 def __init__(self, host):
     super().__init__(host)
     self.is_k8s = helpers.is_k8s(self._host.SshDirect)
     self.DNS_NAME = host.ip if not self.is_k8s else prometheus_connection_config[
         'host']['k8s']
     self.PORT = prometheus_connection_config['port']['compose'] if not self.is_k8s \
         else prometheus_connection_config['port']['k8s']
     self.start_tunnel(self.DNS_NAME, self.PORT)
     self.url = f'{prometheus_connection_config["url"]["compose"]}:{self.local_bind_port}' if not self.is_k8s \
         else f'{prometheus_connection_config["url"]["k8s"]}'
     if self.is_k8s:
         with open('/etc/hosts', 'r+') as f:
             content = f.read()
             if f"{host.ip} {self.DNS_NAME}" not in content:
                 logging.info(
                     f"write new line in hosts file: {host.ip} {self.DNS_NAME}"
                 )
                 f.write(f'\n{host.ip} {self.DNS_NAME}\n')
     self.headers = None if not self.is_k8s \
         else {'Authorization': f'Basic {prometheus_connection_config["auth"]}'}
     self._prom = Prometheus(url=self.url, headers=self.headers)
Ejemplo n.º 7
0
 def __init__(self, host):
     self._host = host
     self.DNS_NAME = 'postgres.tls.ai' if not is_k8s(
         self._host.SshDirect) else 'postgres.default.svc.cluster.local'
     self.PORT = 5432
     self._connection = None
Ejemplo n.º 8
0
 def password(self):
     if not helpers.is_k8s(self._host.SshDirect):
         return 'password'
     return self._host.SshDirect.execute(
         "kubectl get secret --namespace default memsql-secret -o jsonpath='{.data.password}' | base64 --decode"
     )
Ejemplo n.º 9
0
 def __init__(self, host):
     self._host = host
     self.DNS_NAME = 'memsql.tls.ai' if not helpers.is_k8s(
         self._host.SshDirect) else 'memsql.default.svc.cluster.local'
     self.PORT = 3306
     self._connection = None
Ejemplo n.º 10
0
def restart_container_by_service(host, name):
    
    if helpers.is_k8s(host.SshDirect):
        host.K8s.restart_pod_by_service_name(name)
    else:
        host.Docker.restart_container_by_service_name(name)
Ejemplo n.º 11
0
def start_container_by_service(host, name):
    if helpers.is_k8s(host.SshDirect):
        raise NotImplementedError("Start container not implemented yet")
    else:
        host.Docker.run_container_by_service(name)
Ejemplo n.º 12
0
 def reset_state(self):
     if not helpers.is_k8s(self._host.SshDirect):
         self.delete_storage_compose()
     else:
         raise Exception(
             "Infra doesnt know how to reset_state of kafka on K8s")
Ejemplo n.º 13
0
 def __init__(self, host):
     self._host = host
     self.DNS_NAME = 'mongodb.tls.ai' if not helpers.is_k8s(
         self._host.SshDirect) else 'mongodb.default.svc.cluster.local'
     self.PORT = 27017
Ejemplo n.º 14
0
 def __init__(self, host):
     self._host = host
     self.DNS_NAME = 'redis.tls.ai' if not helpers.is_k8s(
         self._host.SshDirect) else 'redis-server.default.svc.cluster.local'
     self.PORT = 6379