Пример #1
0
 def auth_handler(self, url, method, timeout, headers, data):
     return basic_auth_handler(
         url=url,
         method=method,
         timeout=timeout,
         headers=headers,
         data=data,
         username=self.gateway_user,
         password=self.gateway_password,
     )
Пример #2
0
    def _auth_handler(self, url: str, method: str, timeout: int,
                      headers: Dict[str, str], data: Any) -> Callable:
        """
        Returns a authentication handler against the Prometheus Pushgateway to use in the pushadd_to_gateway method.

        Args:
            url:      Push gateway
            method:   HTTP method
            timeout:  Request timeout (seconds)
            headers:  HTTP headers
            data:     Data to send

        Returns:
            prometheus_client.exposition.basic_auth_handler: A authentication handler based on this client.
        """
        return basic_auth_handler(url, method, timeout, headers, data,
                                  self.username, self.password)
Пример #3
0
    def auth_handler(self, url, method, timeout, headers, data):
        """Handles authentication for pushing to Prometheus gateway.

        Args:
            url (str): Prometheus gateway URL.
            method (str): Prometheus query method.
            timeout (int): Prometheus timeout.
            headers (dict): Headers.
            data (dict): Data to send.

        Returns:
            func: Auth handler function.
        """
        username = self.username
        password = self.password
        return basic_auth_handler(url, method, timeout, headers, data,
                                  username, password)
Пример #4
0
 def run(self):
     try:
         from prometheus_client import CollectorRegistry, Gauge, push_to_gateway, pushadd_to_gateway
         from prometheus_client.exposition import basic_auth_handler, default_handler
         from urllib import quote_plus
         from socket import gethostname
         has_prometheus = True
         try:
             coshshuser = getpass.getuser()
         except Exception:
             coshshuser = os.getenv("username")
         hostname = gethostname()
         cookbook = self.cookbook
         if hasattr(self, "pg_username"):
             pg_auth_handler = lambda url, method, timeout, headers, data: basic_auth_handler(url, method, timeout, headers, data, self.pg_username, self.pg_password)
         else:
             pg_auth_handler = default_handler
     except Exception, e:
         if hasattr(self, "pg_job"):
             logger.critical("problem with prometheus modules: %s" % e)
         has_prometheus = False
Пример #5
0
 def authentication_handler(self, url, method, timeout, headers, data):
     '''This function handles the basic auth credtials for prometheus-client'''
     return basic_auth_handler(url, method, timeout, headers, data, self.username, self.password)
Пример #6
0
def promAuthHandler(url, method, timeout, headers, data):
    user = os.environ['PROMBBQ_BASIC_AUTH_USER']
    passwd = os.environ['PROMBBQ_BASIC_AUTH_PASSSWORD']
    return basic_auth_handler(url, method, timeout, headers, data, user,
                              passwd)
Пример #7
0
 def my_auth_handler(url, method, timeout, headers, data):
     username = Utils.get_mandatory_env("PROMETHEUS_PUSHGATEWAY_USERNAME")
     password = Utils.get_mandatory_env("PROMETHEUS_PUSHGATEWAY_PASSWORD")
     return basic_auth_handler(url, method, timeout, headers, data, username, password)
Пример #8
0
 def auth_handler(self, url, method, timeout, headers, data):
     username = self.prom_basic_auth_user
     password = self.prom_basic_auth_passwd
     return basic_auth_handler(url, method, timeout, headers, data,
                               username, password)
Пример #9
0
 def auth_handler(url, method, timeout, headers, data, creds):
     return basic_auth_handler(url, method, timeout, headers, data,
                               creds['username'], creds['password'])
Пример #10
0
 def my_auth_handler(url, method, timeout, headers, data):
     return basic_auth_handler(url, method, timeout, headers, data,
                               METRICS_PUSHGATEWAY_USER,
                               METRICS_PUSHGATEWAY_PASSWORD)
Пример #11
0
 def auth_handler(url, method, timeout, headers, data):
     username = get_config_values('pushgateway', 'username')
     password = get_config_values('pushgateway', 'password')
     return basic_auth_handler(url, method, timeout, headers, data,
                               username, password)
Пример #12
0
def basicAuthHandler(url, method, timeout, headers, data):
    username = "******"
    password = "******"
    return basic_auth_handler(url, method, timeout, headers, data, username,
                              password)
Пример #13
0
 def auth_handler(url, method, timeout, headers, data):
     return basic_auth_handler(url, method, timeout, headers, data, self.username, self.password)
Пример #14
0
 def auth_handler(url, method, timeout, headers, data):
     return basic_auth_handler(url, method, timeout, headers, data,
                               username, secret)
Пример #15
0
 def my_auth_handler(url, method, timeout, headers, data):
     return basic_auth_handler(url, method, timeout, headers, data,
                               "foo", "bar")
Пример #16
0
 def auth_handler(url, method, timeout, headers, data):
     return basic_auth_handler(url, method, timeout, headers, data,
                               self.username, self.password)
Пример #17
0
def my_auth_handler(url, method, timeout, headers, data):
    username = config['user']
    password = config['password']
    return basic_auth_handler(url, method, timeout, headers, data, username,
                              password)
Пример #18
0
 def auth_handler(url, method, timeout, headers, data):
     return exposition.basic_auth_handler(
             url, method, timeout, headers, data, username, password)
Пример #19
0
 def my_auth_handler(url, method, timeout, headers, data):
     return basic_auth_handler(url, method, timeout, headers, data,
                               pgw_config['username'],
                               pgw_config['password'])
def my_auth_handler(url, method, timeout, headers, data):
    username = PUSH_GATEWAY_USERNAME
    password = PUSH_GATEWAY_PASSWORD
    return basic_auth_handler(url, method, timeout, headers, data, username,
                              password)