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
-
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
(group, username, pid, task_id=None, build_id=None, chroot=None)[source]¶ Try to acquire VM from pool
Parameters: - group (int) – builder group id, as defined in config
- username – build owner username, VMM prefer to reuse an existing VM which was used by the same user
- pid – builder pid to release VM after build process unhandled death
Return type: Raises: NoVmAvailable when manager couldn’t find suitable VM for the given group and user
-
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_name
(vm_name)[source]¶ Return type: VmDescriptor
-
get_vm_by_task_id
(task_id)[source]¶ Return type: VmDescriptor
-
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 groups - state_list – VM state should be in the
state_list
.
Returns: Filtered VM-s
Return type: list of VmDescriptor
- group – filter VM-s by the build group. If