ManagedkdbInsights/boto/get_cluster.ipynb (138 lines of code) (raw):

{ "cells": [ { "cell_type": "markdown", "id": "e13084db-c69f-4e70-aa79-acfd2159093a", "metadata": {}, "source": [ "# Get Cluster Details" ] }, { "cell_type": "code", "execution_count": null, "id": "a44654e8-d728-4fb4-a6c5-a15325f7c440", "metadata": { "tags": [] }, "outputs": [], "source": [ "CLUSTER_NAME=\"cluster_welcomedb\"" ] }, { "cell_type": "code", "execution_count": null, "id": "3698017d-42ed-4280-afa1-723f19ae398c", "metadata": { "tags": [] }, "outputs": [], "source": [ "import os\n", "import boto3\n", "import json\n", "import datetime\n", "\n", "from managed_kx import *\n", "from env import *" ] }, { "cell_type": "code", "execution_count": null, "id": "ed241efe-523e-4d2f-8e1b-94a09adf42e7", "metadata": { "tags": [] }, "outputs": [], "source": [ "# Using credentials and create service client\n", "session = boto3.Session()\n", "\n", "# create finspace client\n", "client = session.client(service_name='finspace')" ] }, { "cell_type": "markdown", "id": "6b7294c7-d9a3-4fb2-b671-12ead3e17e83", "metadata": {}, "source": [ "# Cluster Details" ] }, { "cell_type": "code", "execution_count": null, "id": "ccb6b824-4af8-447a-8b0a-ecd4d8136081", "metadata": { "tags": [] }, "outputs": [], "source": [ "try:\n", " resp=client.get_kx_cluster(environmentId=ENV_ID, clusterName=CLUSTER_NAME)\n", " resp.pop('ResponseMetadata')\n", "except client.exceptions.ResourceNotFoundException:\n", " resp=f\"Cluster: {CLUSTER_NAME} Not Found\"\n", "\n", "display(resp)\n", "\n", "print()\n", "print( f\"Last Run: {datetime.datetime.now()}\" )" ] }, { "cell_type": "markdown", "id": "b6f0fcc9-e777-4506-8378-7f0daef05fe8", "metadata": {}, "source": [ "# Connection String for Cluster" ] }, { "cell_type": "code", "execution_count": null, "id": "d5f21dfa-727b-42eb-8ca4-d8495894dad6", "metadata": { "tags": [] }, "outputs": [], "source": [ "conn_str = get_kx_connection_string(client, environmentId=ENV_ID, clusterName=CLUSTER_NAME, userName=KDB_USERNAME, boto_session=session)\n", "print(f\"Connection String:\")\n", "print(conn_str)" ] }, { "cell_type": "code", "execution_count": null, "id": "876590d3-743d-4dda-aeab-074015f12f0e", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "conda_python3", "language": "python", "name": "conda_python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.15" } }, "nbformat": 4, "nbformat_minor": 5 }