Package: actoolkit
NetApp Astra Control Python SDKThe NetApp Astra Control Python SDK is designed to provide guidance for working with the NetApp Astra Control API.You can use theastraSDK/library out of the box, and as a set of example recommended code and processes, "cookbook" style. Thetoolkit.pyscript provides a command line interface to interact with Astra Control with built-in guardrails, and since it utilizesastraSDK/it can provide additional context around the requirements of the astraSDK classes.When usingtoolkit.py/actoolkitin automation, it ishighlyrecommended to tie your workflows to a specifictagorrelease(as functionality may change over time), and be sure to thoroughly test all workflows to ensure expected behavior.Note: Support for all components of the Astra Control Python SDK is exclusively handled in a best effort fashion by thecommunityviaGitHub issues, and isnotsupported by NetApp Support. Use of this SDK is entirely at your own risk.InstallationThe NetApp Astra Control SDK can be utilized three different ways, depending upon your use case:Administrator: if you want to use the toolkit as quickly as possible without modifications, it is recommended to utilize theprepared Docker image, as it has all of the required dependencies and binaries configured and ready to go (includingactoolkit).DevOps / GitOps: if utilizing the toolkit in a software pipeline, thepython package(actoolkit) istypicallythe most straightforward method of consumption. A simplepip installcommand results in toolkit.py (asactoolkit) being available in the user's PATH and all python-related dependencies installed.  It also installs theastraSDK/library for use in custom scripts.Developer: if you plan to modify the SDK for internal consumption,manual installationis recommended by cloning (or forking) this repository and working in your local development environment. Ensure that all dependencies mentioned below are met.ThisPython SDK Installation videowalks through all three use cases / installation methods.PrerequisitesFor theadministratoruse case with theprepared Docker image:Docker 20.10.7+For theDevOps / GitOpsuse case with thepython package(actoolkit):Python 3.8+Pip 21.1.2+For thedeveloperuse case or tomanually installthe NetApp Astra Control SDK:Python 3.8+Pip 21.1.2+Git 2.30.2+Kubectl 1.23+Azure CLI (az) 2.25.0+ or Google Cloud SDK (gcloud) 345.0.0+ or AWS CLI (aws) 1.22.0+Helm 3.2.1+AuthenticationNo matter the method of installation, the SDK authenticates by reading in theconfig.yamlfile from the following locations (in order):The current working directory that the executed function is located in~/.config/astra-toolkits//etc/astra-toolkits/The directory pointed to by the shell env varASTRATOOLKITS_CONFAgain, no matter the method of installation, theconfig.yamlfile should have the following syntax:headers:
  Authorization: Bearer <Bearer-Token-From-API-Access-Page>
uid: <Account-ID-From-API-Access-Page>
astra_project: <Shortname-or-FQDN>
verifySSL: <True-or-False>ThisAstra Control API Credentialsvideo walks through creating theconfig.yamlfile, or follow the instructions below.Create (if usingactoolkit) or edit (if using the git repo) theconfig.yamlfile in one of the above mentioned locations with your NetApp Astra Control account information:Authorization: Bearer: Your API tokenuid: Your Astra Control Account IDastra_project: Your Astra Control instance (shortnames get astra.netapp.io appended to them, FQDNs [anything with a.] are used unchanged)verifySSL: True or False, useful for self-signed certs (if this field isn't included it's treated as True)You can find this information in your NetApp Astra Control account profile. Click the user icon in the upper right-hand corner, then chooseAPI Accessfrom the drop-down menu which appears.Copy and paste your Astra Control account ID into theconfig.yamlfile.To get your API token, click+ Generate API token. Generate a new API token, then copy and paste the token into theconfig.yamlWhen you are done, theconfig.yamllooks like:headers:
  Authorization: Bearer thisIsJustAnExample_token-replaceWithYours==
uid: 12345678-abcd-4efg-1234-567890abcdef
astra_project: astra.netapp.io
verifySSL: True1. Docker InstallationLaunch the prepared Docker image. Docker will automatically download the image if you don't already have it on your system.docker run -it netapp/astra-toolkits:latest /bin/bashNOTE: From this point forward, you will be working in the Docker container you just launched.Set up your kubeconfig to successfully run kubectl commands against your cluster with the appropriate command (e.g.export KUBECONFIG=/path/to/kubeconfig,gcloud container clusters get-credentials,az aks get-credentials, oraws eks update-kubeconfig).Configure yourconfig.yamlas detailed in theauthenticationsection.Since theactoolkitpython package is bundled with the Docker image, you can immediately use it to interact with Astra Control:actoolkit list clustersAlternatively, you can also follow themanual installationsteps to clone the git repo and optionally make modifications to the code base, all while not having to worry about software dependencies.2. Python Package InstallationInstallactoolkitwith the following command:python3 -m pip install actoolkitConfigure yourconfig.yamlas detailed in theauthenticationsection.You can now useactoolkitto invoke the NetApp Astra Control SDK. For example,listyour Astra Control Kubernetes clusters with the command:actoolkit list clustersAdditionally, theastraSDK/library is available for import for use when creating custom scripts:>>> import astraSDK
>>> print(astraSDK.clusters.getClusters(output="table").main())
+----------------------+--------------------------------------+---------------+----------------+
| clusterName          | clusterID                            | clusterType   | managedState   |
+======================+======================================+===============+================+
| uscentral1-cluster   | 0412fd41-51b8-478a-b055-0bd50e34b1fe | gke           | managed        |
+----------------------+--------------------------------------+---------------+----------------+
| prod-cluster         | c69d8281-d4ea-4902-b03e-0c39c7da4543 | gke           | managed        |
+----------------------+--------------------------------------+---------------+----------------+3. Manual InstallationClone the NetApp Astra Control SDK repo.git clone https://github.com/NetApp/netapp-astra-toolkits.gitMove into the repo directory.cd netapp-astra-toolkitsRun the following commands to add the required Python elements:python3 -m venv toolkit
source toolkit/bin/activate
pip install -r requirements.txtConfigure yourconfig.yamlas detailed in theauthenticationsection.You can now use./toolkit.pyto invoke the NetApp Astra Control SDK. For example,listyour Astra Control Kubernetes clusters with the command:./toolkit.py list clustersAdditional ResourcesSeethe documentationfor more information.