-
Notifications
You must be signed in to change notification settings - Fork 0
/
Find-VM-ISOs.py
60 lines (40 loc) · 1.38 KB
/
Find-VM-ISOs.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
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python
import sys
import ssl
# Site Package Location in VXRM
sys.path.append("/usr/lib/vmware-marvin/marvind/webapps/ROOT/WEB-INF/classes/scripts/lib/python2.7/site-packages")
from pyVmomi import vim, vmodl
from pyVim import connect
from datetime import datetime
s = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
s.verify_mode = ssl.CERT_NONE
# variables
# connection string
si = connect.SmartConnect(host="192.168.10.10", user="[email protected]", pwd='VMware123$', sslContext=s)
content = si.RetrieveServiceContent()
for child in content.rootFolder.childEntity:
datacenter = child
vmFolder = datacenter.vmFolder
vmList = vmFolder.childEntity
for vm in vmList:
vmname = vm.childEntity
for x in vmname:
print(x.vmname)
# using view
rootFolder = si.
# Create a global view
#
# def get_obj(content, vimtype, name):
# obj = None
# container = content.viewManager.CreateContainerView(
# content.rootFolder, vimtype, True)
# for c in container.view:
# if c.name == name:
# obj = c
# break
# return obj
# specs of the script
# 1 - connect to VC
# 2 - Find all Powered ON VMs on the DataCenter (VxRail CLusters Only)
# 3 - Check for every of those VMs if they have an ISO Mounted
# 4 - Report to the user a list of the VMs Found (we can eventually modify the script to remove the ISO)