Skip to content

Commit d62b619

Browse files
committed
vcenter sample script
1 parent 6f29b2b commit d62b619

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

automation_api_scripts/get-vcenter-cluster-info/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
USER = "<CS_USER>"
33
PASSWORD = "<CS_PASSWORD>"
44
DOMAIN = "<CS_DOMAIN>"
5-
65
VCENTER_DATASTORE = "<MY_DATASTORE>"
76
SANDBOX_ID = "<SANDBOX_ID>"

automation_api_scripts/get-vcenter-cluster-info/get_cluster_data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
vcenter shell command reference
33
https://github.com/QualiSystems/VMware-vCenter-Cloud-Provider-Shell-2G/blob/166724df98e0d6c67b16c047f8fb58de431ea4b3/src/drivermetadata.xml#L46
44
"""
5+
import json
6+
57
from cloudshell.api.cloudshell_api import CloudShellAPISession, InputNameValue
68
import config
79

@@ -21,4 +23,5 @@
2123
commandName="get_cluster_usage",
2224
commandInputs=command_inputs,
2325
printOutput=True).Output
24-
print(cluster_details)
26+
data = json.loads(cluster_details)
27+
print(json.dumps(data, indent=4))
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Get Vcenter Cluster Info
2+
3+
Debug script to test vcenter shell command
4+
5+
## Usage
6+
7+
Add config data to config.py
8+
9+
```python
10+
SERVER = "<CS_HOST>"
11+
USER = "<CS_USER>"
12+
PASSWORD = "<CS_PASSWORD>"
13+
DOMAIN = "<CS_DOMAIN>"
14+
VCENTER_DATASTORE = "<MY_DATASTORE>"
15+
SANDBOX_ID = "<SANDBOX_ID>"
16+
```
17+
18+
## Sample Response
19+
20+
```json
21+
{
22+
"datastore": {
23+
"capacity": "5.46 TB",
24+
"used": "4.32 TB",
25+
"free": "4.32 TB",
26+
"used_percentage": "79"
27+
},
28+
"cpu": {
29+
"capacity": "35.20 GHz",
30+
"used": "5.85 GHz",
31+
"free": "29.35 GHz",
32+
"used_percentage": "17"
33+
},
34+
"ram": {
35+
"capacity": "383.94 GB",
36+
"used": "52.21 GB",
37+
"free": "331.73 GB",
38+
"used_percentage": "14"
39+
}
40+
}
41+
```

0 commit comments

Comments
 (0)