-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVolume.py
More file actions
26 lines (21 loc) · 753 Bytes
/
Copy pathVolume.py
File metadata and controls
26 lines (21 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
# ONTAP cluster details
CLUSTER = "https://192.168.0.101" # no tab or spaces
#USER = "admin"
#PASS = "Netapp1!"
header = {"Authorization": "Basic YWRtaW46TmV0YXBwMSE="}
# Volume details
payload = {
"name": "vol_4",
"svm": {"name": "svm1"},
"aggregates": [{"name": "cluster1_01_SSD_1"}],
"size": 1073741824 # 1 GiB in bytes
}
url = f"{CLUSTER}/api/storage/volumes"
# add timeout and better error handling
try:
r = requests.post(url, json=payload, headers=header, verify=False, timeout=15)
print("Status:", r.status_code)
print("Response:", r.json() if r.headers.get("Content-Type","").startswith("application/json") else r.text)
except requests.RequestException as e:
print("Connection error:", e)