module BeakerHostGenerator::Hypervisor
Defines an Interface
for the implementation of a hypervisor, and provides a static module function ‘create(node_info, options)` for instantiating the appropriate hypervisor implementation.
New hypervisor implementations must define the methods in the Interface
class, and add a new element to the ‘builtin_hypervisors` map.
Any number of hypervisors are used by a single Generator
during host generation in the ‘BeakerHostGenerator::Generator#generate` method. Whenever a host specifies a specific hypervisor implementation, the Generator
will instantiate the appropriate hypervisor via `BeakerHostGenerator::Hypervisor.create`.
Public Class Methods
Source
# File lib/beaker-hostgenerator/hypervisor.rb, line 40 def self.builtin_hypervisors { 'abs' => BeakerHostGenerator::Hypervisor::ABS, 'container' => BeakerHostGenerator::Hypervisor::Docker, 'container_docker' => BeakerHostGenerator::Hypervisor::Docker, 'container_podman' => BeakerHostGenerator::Hypervisor::Docker, 'container_swarm' => BeakerHostGenerator::Hypervisor::Docker, 'docker' => BeakerHostGenerator::Hypervisor::Docker, 'hcloud' => BeakerHostGenerator::Hypervisor::Hcloud, 'vagrant' => BeakerHostGenerator::Hypervisor::Vagrant, 'vagrant_libvirt' => BeakerHostGenerator::Hypervisor::Vagrant, 'vmpooler' => BeakerHostGenerator::Hypervisor::Vmpooler, } end
Returns a map of all built-in hypervisor implementations, where the keys are the string names and the values are the implementation classes.
The string names are part of the beaker-hostgenerator API as they are used for specifying the default or per-host hypervisor in the layout specification input string.
@returns [Hash{String=>Hypervisor::Interface}] A map of hypervisor names
and their implementations.
Source
# File lib/beaker-hostgenerator/hypervisor.rb, line 25 def self.create(node_info, options) name = node_info['host_settings']['hypervisor'] || options[:hypervisor] hypervisor = builtin_hypervisors[name] || BeakerHostGenerator::Hypervisor::Unknown hypervisor.new(name) end
Static factory method to instantiate the appropriate hypervisor for the given node. If no hypervisor is specified in the node info, then the hypervisor specified in the options will be created. If the hypervisor is not a built-in implementation, then an ‘Unknown` instance will be used.
@param node_info [Hash{String=>Object}] Node data parsed from the input
spec string.
@option options [String] :hypervisor The string name of the hypervisor to
create.