Back to snippets
netapp_ontap_cluster_connection_and_version_info.py
pythonThis script establishes a connection to a NetApp ONTAP cluster and retrieve
Agent Votes
1
0
100% positive
netapp_ontap_cluster_connection_and_version_info.py
1from netapp_ontap import HostConnection, NetAppRestError
2from netapp_ontap.resources import Cluster
3
4def get_cluster_info(cluster_ip, username, password):
5 # Establish a connection to the ONTAP cluster
6 with HostConnection(cluster_ip, username=username, password=password, verify=False):
7 try:
8 # Retrieve the cluster's identity and version details
9 cluster = Cluster.get()
10 print(f"Connected to Cluster: {cluster.name}")
11 print(f"ONTAP Version: {cluster.version.full}")
12 except NetAppRestError as err:
13 print(f"Error connecting to the cluster: {err}")
14
15if __name__ == "__main__":
16 # Replace with your actual cluster management IP and credentials
17 CLUSTER_IP = "10.0.0.1"
18 USERNAME = "admin"
19 PASSWORD = "password"
20
21 get_cluster_info(CLUSTER_IP, USERNAME, PASSWORD)