def status(self, line): logger.info(f'calling for status on endpoint {self.graph_notebook_config.host}') request_generator = create_request_generator(self.graph_notebook_config.auth_mode, self.graph_notebook_config.iam_credentials_provider_type) logger.info( f'used credentials_provider_mode={self.graph_notebook_config.iam_credentials_provider_type.name} and auth_mode={self.graph_notebook_config.auth_mode.name} to make status request') res = get_status(self.graph_notebook_config.host, self.graph_notebook_config.port, self.graph_notebook_config.ssl, request_generator) logger.info(f'got the response {res}') return res
def test_do_status_without_iam_credentials(self): with self.assertRaises(HTTPError): get_status(self.host, self.port, self.ssl)
def test_do_status_with_iam_credentials(self): request_generator = create_request_generator( AuthModeEnum.IAM, IAMAuthCredentialsProvider.ENV) status = get_status(self.host, self.port, self.ssl, request_generator) self.assertEqual(status['status'], 'healthy')
def test_do_status(self): status = get_status(self.host, self.port, self.ssl) self.assertEqual(status['status'], 'healthy')
def on_button_delete_clicked(b): result = initiate_database_reset(host, port, ssl, request_generator) text_hbox.close() check_box.close() button_delete.close() button_cancel.close() button_hbox.close() if not check_box.value: with output: print('Checkbox is not checked.') return token = result['payload']['token'] if token == "": with output: print('Failed to get token.') print(result) return result = perform_database_reset(token, host, port, ssl, request_generator) if 'status' not in result or result['status'] != '200 OK': with output: print( 'Database reset failed, please try the operation again or reboot the cluster.' ) print(result) logger.error(result) return retry = 10 poll_interval = 5 interval_output = widgets.Output() job_status_output = widgets.Output() status_hbox = widgets.HBox([interval_output]) vbox = widgets.VBox([status_hbox, job_status_output]) display(vbox) last_poll_time = time.time() while retry > 0: time_elapsed = int(time.time() - last_poll_time) time_remaining = poll_interval - time_elapsed interval_output.clear_output() if time_elapsed > poll_interval: with interval_output: print('checking status...') job_status_output.clear_output() with job_status_output: display_html(HTML(loading_wheel_html)) try: retry -= 1 interval_check_response = get_status( host, port, ssl, request_generator) except Exception as e: # Exception is expected when database is resetting, continue waiting with job_status_output: last_poll_time = time.time() time.sleep(1) continue job_status_output.clear_output() with job_status_output: if interval_check_response["status"] == 'healthy': interval_output.close() print('Database has been reset.') return last_poll_time = time.time() else: with interval_output: print( f'checking status in {time_remaining} seconds') time.sleep(1) with output: print(result) if interval_check_response["status"] != 'healthy': print( "Could not retrieve the status of the reset operation within the allotted time. " "If the database is not healthy after 1 min, please try the operation again or " "reboot the cluster.")