class Vmreverter::VMManager
Collection using Proxy Pattern - Proxy normalized access to specific Hypervisors such as VSphere through creation by the Hypervisor
Factory
Attributes
hypervisor_collection[RW]
Public Class Methods
execute!(config)
click to toggle source
# File lib/vmreverter/vmmanager.rb, line 20 def self.execute!(config) begin @vmmanager = Vmreverter::VMManager.new(config) @vmmanager.invoke @vmmanager.close_connection rescue => e raise e ensure FileUtils.rm config.options[:lockfile], :force => true if config.options[:lockfile] end end
new(config)
click to toggle source
# File lib/vmreverter/vmmanager.rb, line 33 def initialize(config) @logger = config.logger @options = config.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, @config) end #return instance created return self end
Public Instance Methods
close_connection()
click to toggle source
# File lib/vmreverter/vmmanager.rb, line 67 def close_connection @hypervisor_collection.each do |hypervisor_type, hypervisor_instance| @logger.notify("Disconnecting from #{hypervisor_type}") hypervisor_instance.close_connection end end
invoke()
click to toggle source
# File lib/vmreverter/vmmanager.rb, line 60 def invoke @hypervisor_collection.each do |hypervisor_type, hypervisor_instance| @logger.notify("Invoking #{hypervisor_type} hosts") hypervisor_instance.invoke end end