Exemplo n.º 1
0
def get_current_configuration() -> ApplicationConfiguration:
    """
    Get the configuration for the "current" application

    Returns:
        ApplicationConfiguration
    """
    try:
        return get_configuration(CloudharnessConfig.get_current_app_name())
    except Exception as e:
        raise ConfigurationCallException(
            f'Configuration error: cannot find current app - check env variable CH_CURRENT_APP_NAME'
        ) from e
Exemplo n.º 2
0
from keycloak.exceptions import KeycloakGetError
from kafka import KafkaProducer, KafkaConsumer
from kafka.admin import KafkaAdminClient, NewTopic
from kafka.errors import TopicAlreadyExistsError, UnknownTopicOrPartitionError, KafkaTimeoutError

from cloudharness import log
from cloudharness import applications as apps
from cloudharness.auth.keycloak import AuthClient
from cloudharness.errors import *
from cloudharness.utils import env
from cloudharness.utils.config import CloudharnessConfig as config

logging.getLogger('kafka').setLevel(logging.ERROR)

AUTH_CLIENT = None
CURRENT_APP_NAME = config.get_current_app_name()


def get_authclient():
    global AUTH_CLIENT
    if not AUTH_CLIENT:
        AUTH_CLIENT = AuthClient()
    return AUTH_CLIENT


class EventClient:
    def __init__(self, topic_id):
        self.topic_id = topic_id

    @classmethod
    def _get_bootstrap_servers(cls):