-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvcenter.py
More file actions
executable file
·36 lines (31 loc) · 907 Bytes
/
vcenter.py
File metadata and controls
executable file
·36 lines (31 loc) · 907 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
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python
name = raw_input("Enter the VM name to search:")
import sys, time
try:
from pysphere import VIServer
def descon(vc):
if server.is_connected() == True:
print "Disconnecting from " + str(vc)
server.disconnect()
else:
print "cannot to vc " + i
except ImportError:
print "try to install pysphere module"
sys.exit(1)
vcenters = [ ]
for i in vcenters:
try:
try:
server = VIServer()
server.connect(i, "SDA\user01", "password")
if server.is_connected() == True:
vm = server.get_vm_by_name(name.upper())
if vm is not None:
print "Found " + name.upper() + " on " + i
#descon(i)
# break
except:
descon(i)
pass
except:
pass