-
Notifications
You must be signed in to change notification settings - Fork 0
/
vSAN-Change-Adv-Settings.py
73 lines (41 loc) · 1.81 KB
/
vSAN-Change-Adv-Settings.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import Cache
import ssl
import atexit
from pyVmomi import vim
# import the VSAN API python bindings
#import the vSAN API python bindings
import vsanmgmtObjects
import vsanapiutils
s = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
s.verify_mode = ssl.CERT_NONE
# connection string to connect to vCenter
sc = SmartConnect(host='10.27.44.44', user='[email protected]', pwd='VMware123!', sslContext=s)
# Datacenter Level
dc = sc.content.rootFolder.childEntity[0]
# Find by Child Method to retrive hosts
# retrieves all the hosts from the DC
hosts = sc.content.rootFolder.childEntity[0].hostFolder.childEntity[0].host
print(hosts)
print(hosts[0])
print(hosts[0].configManager.advancedOption)
advsetting = hosts[0].configManager.advancedOption.setting
# setting is type array
# Loop over all the settings and look for vSAN CLomd Repair Time
for i in advsetting:
if i.key == "VSAN.ClomRepairDelay":
print(i.key)
print(i.value)
print(sc.content.rootFolder.childEntity[0].hostFolder.childEntity[0].host[0].configManager.advancedOption.QueryOptions('VSAN.ClomRepairDelay'))
repair = sc.content.rootFolder.childEntity[0].hostFolder.childEntity[0].host[0].configManager.advancedOption.QueryOptions('VSAN.ClomRepairDelay')
changedValue = repair[0]
changedValue.key = 'VSAN.ClomRepairDelay'
changedValue.value = '120'
bn = vim.option.OptionValue(key='VSAN.ClomRepairDelay', value=120)
print(bn)
# creio que tenho erro devido a estar dentro do loop
# TypeError: 'vim.option.OptionValue'
# object is not iterable
# rever isto
sc.content.rootFolder.childEntity[0].hostFolder.childEntity[0].host[0].configManager.advancedOption.UpdateOptions(bn)
atexit.register(Disconnect, sc)