-
Notifications
You must be signed in to change notification settings - Fork 922
/
list_datastore_cluster.py
executable file
·48 lines (37 loc) · 1.31 KB
/
list_datastore_cluster.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
# William Lam
# www.virtuallyghetto.com
"""
vSphere Python SDK program for listing Datastores in Datastore Cluster
"""
from pyVmomi import vim, vmodl
from tools import cli, service_instance
def main():
"""
Simple command-line program for listing Datastores in Datastore Cluster
"""
parser = cli.Parser()
parser.add_required_arguments(cli.Argument.DATASTORECLUSTER_NAME)
args = parser.get_args()
si = service_instance.connect(args)
try:
content = si.RetrieveContent()
# Search for all Datastore Clusters aka StoragePod
obj_view = content.viewManager.CreateContainerView(content.rootFolder,
[vim.StoragePod],
True)
ds_cluster_list = obj_view.view
obj_view.Destroy()
for ds_cluster in ds_cluster_list:
if ds_cluster.name == args.datastorecluster_name:
datastores = ds_cluster.childEntity
print("Datastores: ")
for datastore in datastores:
print(datastore.name)
except vmodl.MethodFault as error:
print("Caught vmodl fault : " + error.msg)
return -1
return 0
# Start program
if __name__ == "__main__":
main()