-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkers.py
148 lines (125 loc) · 5.15 KB
/
workers.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/python3
from get_creds import creds
from buildbot.plugins import *
import base64
workers = []
# Legacy ARM Builders
workers.append(worker.Worker("hydrogen", creds.hydrogen, max_builds=1))
workers.append(worker.Worker("helium", creds.helium, max_builds=1))
workers.append(worker.Worker("lithium", creds.lithium, max_builds=1))
# Legacy Intel Builders
workers.append(worker.Worker("dasher", creds.dasher))
workers.append(worker.Worker("dancer", creds.dancer))
## AWS based ARM builders
cloud_init_script ='''#!/bin/bash
sudo apt-get update
>&2 echo "Configuring buildbot"
cd /var/lib/buildbot
sudo -u ubuntu bash -c 'source sandbox/bin/activate; buildbot-worker create-worker --use-tls --maxretries 10 worker build.ubiquityrobotics.com {} "{}"'
sudo sh -c "cat <<EOM >/etc/systemd/system/buildbot-worker.service
# This template file assumes the buildbot worker lives in a subdirectory od
# /var/lib/buildbot
# Usage:
# cd /var/lib/buildbot
# buildbot-worker create-worker [directory] [master hostname] [name] [password]
# systemctl enable --now buildbot-worker@[directory].service
[Unit]
Description=Buildbot Worker
After=network.target
[Service]
User=ubuntu
Group=ubuntu
WorkingDirectory=/var/lib/buildbot/
ExecStart=/var/lib/buildbot/sandbox/bin/buildbot-worker start --nodaemon worker
# if using EC2 Latent worker, you want to uncomment following line, and comment out the Restart line
ExecStopPost=sudo shutdown now
[Install]
WantedBy=multi-user.target
EOM"
echo "Rohan Agrawal <[email protected]>" >/var/lib/buildbot/worker/info/admin
echo "AWS {}" >/var/lib/buildbot/worker/info/host
sudo systemctl enable buildbot-worker.service
sudo systemctl start buildbot-worker.service
'''
boron_cloud_init_script = cloud_init_script.format("boron", creds.boron, "m6g.medium")
workers.append(worker.EC2LatentWorker("boron", creds.boron, 'm6g.medium',
region="us-east-2",
ami="ami-031cd6d993a2b9990",
identifier=creds.awsPub,
secret_identifier=creds.awsPriv,
keypair_name='awsBuildbots',
security_name="awsBuildbots",
#spot_instance=True,
#max_spot_price=0.02,
#price_multiplier=None,
max_builds=1,
user_data=boron_cloud_init_script,
block_device_map= [
{
"DeviceName": "/dev/sda1",
"Ebs" : {
"VolumeType": "gp2",
"VolumeSize": 50,
"DeleteOnTermination": True
}
}
]
))
beryllium_cloud_init_script = cloud_init_script.format("beryllium", creds.beryllium, "m6g.medium")
workers.append(worker.EC2LatentWorker("beryllium", creds.beryllium, 'm6g.medium',
region="us-east-2",
ami="ami-031cd6d993a2b9990",
identifier=creds.awsPub,
secret_identifier=creds.awsPriv,
keypair_name='awsBuildbots',
security_name="awsBuildbots",
#spot_instance=True,
#max_spot_price=0.02,
#price_multiplier=None,
max_builds=1,
user_data=beryllium_cloud_init_script,
block_device_map= [
{
"DeviceName": "/dev/sda1",
"Ebs" : {
"VolumeType": "gp2",
"VolumeSize": 50,
"DeleteOnTermination": True
}
}
]
))
# AWS Intel Builders
workers.append(worker.EC2LatentWorker("prancer", creds.prancer, 'm5.large',
region="us-east-2",
ami="ami-0c0e09bda138fbc12",
identifier=creds.awsPub,
secret_identifier=creds.awsPriv,
keypair_name='awsBuildbots',
security_name="awsBuildbots",
# spot_instance=True,
# max_spot_price=0.028,
# price_multiplier=None,
max_builds=1
))
# AWS Windows Builder for firmware builds
workers.append(worker.EC2LatentWorker("tofu", creds.tofu, 't3a.medium',
region="us-east-2",
ami="ami-0bd35b8c6065abdcb",
identifier=creds.awsPub,
secret_identifier=creds.awsPriv,
spot_instance=True,
keypair_name='awsBuildbots',
security_name="awsBuildbots",
max_spot_price=0.032,
price_multiplier=None,
max_builds=1
))
armhf_workers = ["hydrogen", "helium", "lithium", "boron", "beryllium"]
arm64_workers = ["boron", "beryllium"]
amd64_workers = ["dasher", "dancer", "prancer"]
workers_for_arch = {
'armhf' : armhf_workers,
'amd64' : amd64_workers,
'arm64' : arm64_workers
}