Esempio n. 1
0
    def ping_tower_api(self):
        """Wait for Tower API to become available."""
        display.info('Waiting for the Tower API to become reachable')

        config = TowerConfig.parse(self.config_path)

        http = HttpClient(self.args, insecure=True)
        http.username = config.username
        http.password = config.password

        uri = 'https://%s/api/v1/ping/' % config.host

        attempts = 60

        while attempts:
            attempts -= 1
            response = http.get(uri)

            if response.status_code == 200:
                return

            time.sleep(5)

        raise ApplicationError(
            'Timed out waiting for Tower API to become reachable.')