Skip to content

Commit 3aae0dd

Browse files
committed
Config: deprecate vm_* with vm dict
Replace all vm_* parameters by the same parameters in vm dict (eg. vm_image is becoming vm > image). All vm_* parameters are marked as deprecated, ie. they are still supported but Rift emits warning visible by end users to report the new parameter name.
1 parent 57c0017 commit 3aae0dd

File tree

8 files changed

+257
-150
lines changed

8 files changed

+257
-150
lines changed

lib/rift/Config.py

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -181,49 +181,88 @@ class Config():
181181
}
182182
}
183183
},
184-
'vm_image': {
184+
'vm': {
185+
'check': 'dict',
185186
'required': True,
186-
# XXX?: default value?
187+
'syntax': {
188+
'image': {
189+
'required': True,
190+
# XXX?: default value?
191+
},
192+
'image_copy': {
193+
'check': 'digit',
194+
'default': 0,
195+
},
196+
'port_range': {
197+
'check': 'dict',
198+
'syntax': {
199+
'min': {
200+
'check': 'digit',
201+
'default': _DEFAULT_VM_PORT_RANGE_MIN,
202+
},
203+
'max': {
204+
'check': 'digit',
205+
'default': _DEFAULT_VM_PORT_RANGE_MAX,
206+
}
207+
}
208+
},
209+
'cpu': {},
210+
'cpus': {
211+
'check': 'digit',
212+
'default': _DEFAULT_VM_CPUS,
213+
},
214+
'memory': {
215+
'check': 'digit',
216+
'default': _DEFAULT_VM_MEMORY,
217+
},
218+
'address': {
219+
'default': _DEFAULT_VM_ADDRESS,
220+
},
221+
'images_cache': {},
222+
'additional_rpms': {
223+
'check': 'list',
224+
'default': _DEFAULT_VM_ADDITIONAL_RPMS,
225+
},
226+
'cloud_init_tpl': {
227+
'default': _DEFAULT_VM_CLOUD_INIT_TPL,
228+
},
229+
'build_post_script': {
230+
'default': _DEFAULT_VM_BUILD_POST_SCRIPT,
231+
},
232+
}
233+
},
234+
'vm_image': {
235+
'deprecated': 'vm.image'
187236
},
188237
'vm_image_copy': {
189-
'check': 'digit',
190-
'default': 0,
238+
'deprecated': 'vm.image_copy'
191239
},
192240
'vm_port_range': {
193-
'check': 'dict',
194-
'syntax': {
195-
'min': {
196-
'check': 'digit',
197-
'default': _DEFAULT_VM_PORT_RANGE_MIN,
198-
},
199-
'max': {
200-
'check': 'digit',
201-
'default': _DEFAULT_VM_PORT_RANGE_MAX,
202-
}
203-
}
241+
'deprecated': 'vm.port_range'
242+
},
243+
'vm_cpu': {
244+
'deprecated': 'vm.cpu'
204245
},
205-
'vm_cpu': {},
206246
'vm_cpus': {
207-
'check': 'digit',
208-
'default': _DEFAULT_VM_CPUS,
247+
'deprecated': 'vm.cpus'
209248
},
210249
'vm_memory': {
211-
'check': 'digit',
212-
'default': _DEFAULT_VM_MEMORY,
250+
'deprecated': 'vm.memory'
213251
},
214252
'vm_address': {
215-
'default': _DEFAULT_VM_ADDRESS,
253+
'deprecated': 'vm.address'
254+
},
255+
'vm_images_cache': {
256+
'deprecated': 'vm.images_cache'
216257
},
217-
'vm_images_cache': {},
218258
'vm_additional_rpms': {
219-
'check': 'list',
220-
'default': _DEFAULT_VM_ADDITIONAL_RPMS,
259+
'deprecated': 'vm.additional_rpms'
221260
},
222261
'vm_cloud_init_tpl': {
223-
'default': _DEFAULT_VM_CLOUD_INIT_TPL,
262+
'deprecated': 'vm.cloud_init_tpl'
224263
},
225264
'vm_build_post_script': {
226-
'default': _DEFAULT_VM_BUILD_POST_SCRIPT,
265+
'deprecated': 'vm.build_post_script'
227266
},
228267
'gerrit_realm': {},
229268
'gerrit_server': {},

lib/rift/Controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def vm_build(vm, args, config):
677677
"Both --deploy and -o,--output options cannot be used together"
678678
)
679679
if args.deploy:
680-
output = config.get('vm_image')
680+
output = config.get('vm').get('image')
681681
else:
682682
output = args.output
683683
message(f"Building new vm image {output}")

lib/rift/VM.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,25 +123,26 @@ def __init__(self, config, arch, tmpmode=True, extra_repos=None):
123123
self.version = config.get('version', '0')
124124
self.arch = arch
125125

126-
self._image = config.get('vm_image', arch=arch)
126+
vm_config = config.get('vm', arch=arch)
127+
self._image = vm_config.get('image')
127128
self._project_dir = config.project_dir
128129

129130
if extra_repos is None:
130131
extra_repos = []
131132

132133
self._repos = ProjectArchRepositories(config, arch).all + extra_repos
133134

134-
self.address = config.get('vm_address')
135-
self.port = self.default_port(config.get('vm_port_range'))
136-
self.cpus = config.get('vm_cpus', 1)
137-
self.memory = config.get('vm_memory')
135+
self.address = vm_config.get('address')
136+
self.port = self.default_port(vm_config.get('port_range'))
137+
self.cpus = vm_config.get('cpus', 1)
138+
self.memory = vm_config.get('memory')
138139
self.qemu = config.get('qemu', arch=arch)
139140

140141
# default emulated cpu architecture
141142
if self.arch == 'aarch64':
142-
self.cpu_type = config.get('vm_cpu', 'cortex-a72')
143+
self.cpu_type = vm_config.get('cpu', 'cortex-a72')
143144
else:
144-
self.cpu_type = config.get('vm_cpu', 'host')
145+
self.cpu_type = vm_config.get('cpu', 'host')
145146

146147
# Specific aarch64 options
147148
self.arch_efi_bios = config.get('arch_efi_bios', ARCH_EFI_BIOS)
@@ -156,21 +157,21 @@ def __init__(self, config, arch, tmpmode=True, extra_repos=None):
156157

157158

158159
self.tmpmode = tmpmode
159-
self.copymode = config.get('vm_image_copy')
160+
self.copymode = vm_config.get('image_copy')
160161
self._vm = None
161162
self._helpers = []
162163
self._tmpimg = None
163164
self.consolesock = f"/tmp/rift-vm-console-{self.vmid}.sock"
164165
self.proxy = config.get('proxy')
165166
self.no_proxy = config.get('no_proxy')
166-
self.additional_rpms = config.get('vm_additional_rpms')
167+
self.additional_rpms = vm_config.get('additional_rpms')
167168
self.cloud_init_tpl = config.project_path(
168-
config.get('vm_cloud_init_tpl')
169+
vm_config.get('cloud_init_tpl')
169170
)
170171
self.build_post_script = config.project_path(
171-
config.get('vm_build_post_script')
172+
vm_config.get('build_post_script')
172173
)
173-
self.images_cache = config.get('vm_images_cache')
174+
self.images_cache = vm_config.get('images_cache')
174175

175176
@property
176177
def vmid(self):

template/project.conf

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ annex: /somewhere/
1515
#
1616
# no_proxy: localhost,.intranet.company.ltd
1717

18-
# VM options
19-
vm_image: images/default.qcow
20-
# full copy of image
21-
vm_image_copy: False
22-
23-
# TCP port range Rift can select for SSH server in the VMs
24-
# vm_port_range:
25-
# min: 10000
26-
# max: 15000
27-
2818
# Build architectures
2919
arch:
3020
- x86_64
@@ -39,37 +29,51 @@ arch:
3929
#rpm_macros:
4030
# kernel_version: 1.2.4.4
4131

42-
# Optional VM settings
43-
#
44-
# Path to directory where downloaded cloud images are stored locally. This
45-
# directory serves as a cache: when images are already present in this directory
46-
# (ie. same filename), download is skipped. If this parameter is not defined,
47-
# images are downloaded in a temporary directory.
48-
#
49-
# vm_images_cache: /path/to/images/cache
50-
#
51-
# List of paths to RPM packages that are copied into the VM before execution of
52-
# build post script. This script is then responsible of their installation in VM
53-
# image.
54-
#
55-
# vm_additional_rpms:
56-
# - /path/to/first-rpm-1.el8.x86_64.rpm
57-
# - /path/to/second-rpm-1.el8.x86_64.rpm
58-
#
59-
# Path to alternative cloud-init template file. By default, Rift uses
60-
# cloud-init.tpl file located in project top folder.
61-
#
62-
# vm_cloud_init_tpl: /path/to/cloud-init.tpl
63-
#
64-
# Path to alternative VM build post script. By default, Rift executes
65-
# build-post.sh script located in project top folder.
66-
#
67-
# vm_build_post_script: /path/to/build-post.sh
32+
# VM options
33+
vm:
34+
image: images/default.qcow
35+
36+
# Optional VM settings
37+
#
38+
# Make a full copy of the image before using it.
39+
# image_copy: False
40+
#
41+
# TCP port range Rift can select for SSH server for its VMs.
42+
# port_range:
43+
# min: 10000
44+
# max: 15000
45+
#
46+
# Path to directory where downloaded cloud images are stored locally. This
47+
# directory serves as a cache: when images are already present in this directory
48+
# (ie. same filename), download is skipped. If this parameter is not defined,
49+
# images are downloaded in a temporary directory.
50+
#
51+
# images_cache: /path/to/images/cache
52+
#
53+
# List of paths to RPM packages that are copied into the VM before execution of
54+
# build post script. This script is then responsible of their installation in VM
55+
# image.
56+
#
57+
# additional_rpms:
58+
# - /path/to/first-rpm-1.el8.x86_64.rpm
59+
# - /path/to/second-rpm-1.el8.x86_64.rpm
60+
#
61+
# Path to alternative cloud-init template file. By default, Rift uses
62+
# cloud-init.tpl file located in project top folder.
63+
#
64+
# cloud_init_tpl: /path/to/cloud-init.tpl
65+
#
66+
# Path to alternative VM build post script. By default, Rift executes
67+
# build-post.sh script located in project top folder.
68+
#
69+
# Emulated CPU model for the VM. The default value is 'cortex-a72' for aarch64
70+
# architecture or 'host' for other architectures.
71+
# cpu: "cortex-a72"
72+
# build_post_script: /path/to/build-post.sh
6873

6974
# Dedicated options for aarch64 builds
7075
#arch: "aarch64"
7176
#arch_efi_bios: "/ccc/home/cont001/ocre/cedeyna/Ocean/rift/vendor/QEMU_EFI.fd"
72-
#vm_cpu: "cortex-a72"
7377

7478
# Example GPG settings for package cryptographic signing
7579
#gpg:
@@ -83,7 +87,8 @@ arch:
8387
# It is possible to declare architecture specific options with a mapping under
8488
# the key named after this architectur.
8589
# x86_64:
86-
# vm_image: images/image-x86_64.qcow2
90+
# vm:
91+
# image: images/image-x86_64.qcow2
8792

8893
# External repositories
8994
#

0 commit comments

Comments
 (0)