Class: Vmreverter::VMManager
- Inherits:
-
Object
- Object
- Vmreverter::VMManager
- Defined in:
- lib/vmreverter/vmmanager.rb
Overview
Collection using Proxy Pattern - Proxy normalized access to specific Hypervisors such as VSphere through creation by the Hypervisor Factory
Instance Attribute Summary collapse
-
#hypervisor_collection ⇒ Object
Returns the value of attribute hypervisor_collection.
Instance Method Summary collapse
- #close_connection ⇒ Object
-
#initialize(config, options, logger) ⇒ VMManager
constructor
A new instance of VMManager.
- #invoke ⇒ Object
Constructor Details
#initialize(config, options, logger) ⇒ VMManager
Returns a new instance of VMManager.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vmreverter/vmmanager.rb', line 18 def initialize(config, , logger) @logger = logger @options = @hosts = [] @config = config @hypervisor_collection = {} @virtual_machines = {} @config['HOSTS'].each_key do |name| hypervisor = @config['HOSTS'][name]['hypervisor'] @logger.debug "Hypervisor for #{name} is #{hypervisor}" @virtual_machines[hypervisor] = [] unless @virtual_machines[hypervisor] @virtual_machines[hypervisor] << name end ## Data Model Looks like # @virtual_machines.inspect # {"vsphere" => ["test_server01","test_server02"], "blimpy" => ["aws_test_server01","aws_test_server01"]} @virtual_machines.each do |type, names| @hypervisor_collection[type] = Vmreverter::Hypervisor.register(type, names, @options, @config) end #return instance created return self end |
Instance Attribute Details
#hypervisor_collection ⇒ Object
Returns the value of attribute hypervisor_collection.
16 17 18 |
# File 'lib/vmreverter/vmmanager.rb', line 16 def hypervisor_collection @hypervisor_collection end |
Instance Method Details
#close_connection ⇒ Object
52 53 54 55 56 57 |
# File 'lib/vmreverter/vmmanager.rb', line 52 def close_connection @hypervisor_collection.each do |hypervisor_type, hypervisor_instance| @logger.notify("Disconnecting from #{hypervisor_type}") hypervisor_instance.close_connection end end |
#invoke ⇒ Object
45 46 47 48 49 50 |
# File 'lib/vmreverter/vmmanager.rb', line 45 def invoke @hypervisor_collection.each do |hypervisor_type, hypervisor_instance| @logger.notify("Invoking #{hypervisor_type} hosts") hypervisor_instance.invoke end end |