This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
create-image.py
69 lines (59 loc) · 1.95 KB
/
create-image.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
#!/usr/bin/env python
'''
Called by <abracadabra repo>/ccbuild.py so should exist. Because
the Ubuntu DIB element automatically gets the newest image, there
isn't as much to do here relative to the CC-CentOS7 image...
'''
import argparse
import os
import sys
UBUNTU_RELEASES = {
'bionic': '18.04',
'focal': '20.04',
'jammy': '22.04',
}
VARIANTS = {
'base': {
'name-suffix': '',
'extra-elements': '',
},
'gpu': {
'name-suffix': '-',
'extra-elements': 'cc-cuda',
},
'arm64': {
'name-suffix': '-ARM64',
'extra-elements': '',
},
}
def main():
parser = argparse.ArgumentParser(description='__doc__')
parser.add_argument('-n', '--release', type=str, default='focal',
choices=UBUNTU_RELEASES,
help='Ubuntu release adjective name')
parser.add_argument('-v', '--variant', type=str,
choices=VARIANTS,
help='Image variant to build')
parser.add_argument('-g', '--region', type=str, help='Region name')
args = parser.parse_args()
version_number = UBUNTU_RELEASES[args.release]
variant_info = VARIANTS[args.variant]
if args.variant == 'gpu':
variant_info['name-suffix'] = variant_info['name-suffix'] + "CUDA"
variant_info['extra-elements'] = variant_info['extra-elements']
image_name = 'CC-Ubuntu{}{}'.format(version_number, variant_info['name-suffix'])
env_updates = {
'UBUNTU_ADJECTIVE': args.release,
'UBUNTU_VERSION': version_number,
'IMAGE_NAME': image_name,
'EXTRA_ELEMENTS': variant_info['extra-elements'],
'VARIANT': args.variant,
}
# os.exec*e obliterates current environment (was hiding DIB_CC_PROVENANCE)
# so we need to include it, and may as well include it all to match how
# CC-CentOS7 does it.
env = os.environ.copy()
env.update(env_updates)
os.execle('create-image.sh', 'create-image.sh', env)
if __name__ == '__main__':
sys.exit(main())