Пример #1
0
 def __init__(self):
     vault = Vault()
     secret = vault.load_secret("snow_service")
     self.auth = BasicAuth(login=secret.get("user"),
                           password=secret.get("pwd"),
                           encoding="utf-8")
     try:
         snow_instance = secret.get("instance")
         self.base_api_url = f"https://{snow_instance}/api/now"
         self._session = None
     except ConnectionError as e:
         logger.error("Unable to connect to ServiceNow.")
         logger.error(e)
Пример #2
0
    def __init__(self):
        vault = Vault()
        secret = vault.load_secret("snow_service")
        self.auth = BasicAuth(login=secret.get("user"),
                              password=secret.get("pwd"),
                              encoding="utf-8")
        snow_instance = secret.get("instance")
        self.base_api_url = f"https://{snow_instance}/api/now"
        self._session = None

        # Hook into the os's shutdown signal to
        # asynchronously close the client session.
        loop = asyncio.get_event_loop()
        task = loop.create_task(self.close_session())
        loop.add_signal_handler(signal.SIGTERM, task)
        self._loop = loop