backend.vm_manage.manager¶
-
class
backend.vm_manage.manager.
VmManager
(opts, logger=None)[source]¶ VM manager, it is used for two purposes: - Daemon which control VMs lifecycle, requires params spawner,terminator - Client to acquire and release VM in builder process
- Parameters
opts (Munch) – Global backend configuration
logger (logging.Logger) – Logger instance to use inside of manager, if None manager would create new logger using helpers.get_redis_logger
-
property
vm_groups
¶ - Returns
VM build groups
- Return type
list of int
-
add_vm_to_pool
(vm_ip, vm_name, group)[source]¶ Adds newly spawned VM into the pool of available builders
- Parameters
vm_ip (str) – IP
vm_name (str) – VM name
group (int) – builder group
- Return type
-
lookup_vms_by_ip
(vm_ip)[source]¶ - Parameters
vm_ip –
- Returns
List of found VMD with the give ip
- Return type
list of VmDescriptor
-
can_user_acquire_more_vm
(username, group)[source]¶ - Return bool
True when user are allowed to acquire more VM
-
acquire_vm
(groups, ownername, sandbox, pid, task_id='None', build_id='None', chroot='None')[source]¶ Try to acquire VM from pool.
- Parameters
groups (list) – builder group ids where the build can be launched as defined in config
ownername – the owner name (user or group) this build is going to be accounted to, at this moment there’s max limit for concurrent jobs accounted to a single owner
sandbox – sandbox ID required by the build; we prefer to reuse existing VMs previously used for the same sandbox
pid – worker process id
- Return type
- Raises
NoVmAvailable when manager couldn’t find suitable VM for the given groups and owner
-
start_vm_termination
(vm_name, allowed_pre_state='None')[source]¶ Initiate VM termination process using redis publish.
- Parameters
allowed_pre_state (str constant from VmState) – When defined force check that old state is among allowed ones.
-
remove_vm_from_pool
(vm_name)[source]¶ Backend forgets about VM after this method
- Raises
VmError – if VM has wrong state
-
get_vm_by_group_and_state_list
(group, state_list)[source]¶ Select VM-s for the given group and allowed states
- Parameters
group – filter VM-s by the build group. If
group is None
select VM-s from the all groupsstate_list – VM state should be in the
state_list
.
- Returns
Filtered VM-s
- Return type
list of VmDescriptor