-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.py
47 lines (37 loc) · 1.28 KB
/
deploy.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
import time
from json import load
from multiprocessing import Pool
from vcloud import vcloud
def deployToUser(tup):
user = tup[0]
template = tup[1]
vdc = tup[2]
if user is None:
return
vapp = template.deploy(vdc, name=template.name + '_' + user.name)
if vapp is None:
return
endvapp = vapp.changeOwner(user, timeout=300, check_time=5)
if endvapp is not None:
print(user.name + '_' + template.name, 'deployed successfully deployed to', user.name)
if __name__ == '__main__':
start_time = time.time()
with open("vcloud.json", "r") as file:
config = load(file)
filters = config['Extra']['Filters'].split(',')
vcloud = vcloud(config)
catalog = vcloud.getCatalog(config['Extra']['Catalog'])
vdc = vcloud.getVdc(config['Extra']['Vdc'])
org = vcloud.getOrg(config['Main']['Org'])
role = org.getRole(config['Deploy']['Role'])
p = Pool(12)
templates = catalog.getTemplates(filter='DefSec_ESXi')
template = templates[0]
with open('users.txt', 'r') as f:
users = f.read().split('\n')
l = []
for user in users:
user = org.getUser(user, role=role)
l.append((user, template, vdc))
p.map(deployToUser, l)
print("Deploy took", (time.time() - start_time), "seconds.")