Class: Beaker::NetworkManager
- Inherits:
-
Object
- Object
- Beaker::NetworkManager
- Defined in:
- lib/beaker/network_manager.rb
Constant Summary collapse
- HYPERVISOR_TYPES =
['solaris', 'blimpy', 'vsphere', 'fusion', 'aix', 'vcloud', 'vagrant']
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(options, logger) ⇒ NetworkManager
constructor
A new instance of NetworkManager.
- #provision ⇒ Object
Constructor Details
#initialize(options, logger) ⇒ NetworkManager
Returns a new instance of NetworkManager.
13 14 15 16 17 18 19 |
# File 'lib/beaker/network_manager.rb', line 13 def initialize(, logger) @logger = logger @options = @hosts = [] @virtual_machines = {} @noprovision_machines = [] end |
Instance Method Details
#cleanup ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/beaker/network_manager.rb', line 60 def cleanup #only cleanup if we aren't preserving hosts #shut down connections @hosts.each {|host| host.close } if not @options[:preserve_hosts] if @provisioned_set @provisioned_set.each_key do |type| if @provisioned_set[type] @provisioned_set[type].cleanup end end end end end |
#provision ⇒ Object
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 |
# File 'lib/beaker/network_manager.rb', line 21 def provision #sort hosts into those to be provisioned and those to use non-provisioned @options['HOSTS'].each_key do |name| host_info = @options['HOSTS'][name] #check to see if this host has a hypervisor hypervisor = host_info['hypervisor'] #provision this box # - only if we are running with --provision # - only if we have a hypervisor # - only if either the specific hosts has no specification or has 'provision' in its config if @options[:provision] && hypervisor && (host_info.has_key?('provision') ? host_info['provision'] : true) #obey config file provision, defaults to provisioning vms raise "Invalid hypervisor: #{hypervisor} (#{name})" unless HYPERVISOR_TYPES.include? hypervisor @logger.debug "Hypervisor for #{name} is #{host_info['hypervisor'] || 'default' }, and I'm going to use #{hypervisor}" @virtual_machines[hypervisor] = [] unless @virtual_machines[hypervisor] @virtual_machines[hypervisor] << name else #this is a non-provisioned machine, deal with it without hypervisors @logger.debug "No hypervisor for #{name}, connecting to host without provisioning" @noprovision_machines << name end end @provisioned_set = {} @virtual_machines.each do |type, names| hosts_for_type = [] #set up host objects for provisioned provisioned_set names.each do |name| host = Beaker::Host.create(name, @options) hosts_for_type << host end @provisioned_set[type] = Beaker::Hypervisor.create(type, hosts_for_type, @options) @hosts << hosts_for_type end @noprovision_machines.each do |name| @hosts << Beaker::Host.create(name, @options) end @hosts = @hosts.flatten @hosts end |