1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-27 14:03:40 +03:00

feature #466: SSH VMM driver can execute polls locally. Also VMM drivers get options for the number of threads and retries

This commit is contained in:
Ruben S. Montero 2011-02-02 23:19:05 +01:00
parent 334223dbca
commit 73b13ff4a8
5 changed files with 140 additions and 87 deletions

View File

@ -177,17 +177,23 @@ IM_MAD = [
#-------------------------------------------------------------------------------
# KVM Virtualization Driver Manager Configuration
# -r number of retries when monitoring a host
# -t number of threads, i.e. number of hosts monitored at the same time
# -l do not perform the VM polling in the node
#-------------------------------------------------------------------------------
VM_MAD = [
name = "vmm_kvm",
executable = "one_vmm_ssh",
arguments = "kvm",
arguments = "-t 15 -r0 kvm",
default = "vmm_ssh/vmm_ssh_kvm.conf",
type = "kvm" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# XEN Virtualization Driver Manager Configuration
# -r number of retries when monitoring a host
# -t number of threads, i.e. number of hosts monitored at the same time
# -l do not perform the VM polling in the node
#-------------------------------------------------------------------------------
#VM_MAD = [
# name = "vmm_xen",

View File

@ -121,7 +121,5 @@ if ARGV.length >= 1
hypervisor = ARGV.shift
end
puts retries, threads, hypervisor
im = InformationManager.new(hypervisor, threads, retries)
im.start_driver

View File

@ -145,7 +145,7 @@ class VirtualMachineDriver < OpenNebulaDriver
info = "-" if info == nil || info.empty?
send_message(ACTION[action],RESULT[result],id)
send_message(ACTION[action],RESULT[result],id,info)
end
# -------------------------------------------------------------------------

View File

@ -35,20 +35,25 @@ $: << RUBY_LIB_LOCATION
require "VirtualMachineDriver"
# ---------------------------------------------------------------------------- #
# The main class for the Sh driver #
# The main class for the Sh driver #
# ---------------------------------------------------------------------------- #
class ShDriver < VirtualMachineDriver
# ------------------------------------------------------------------------ #
# ShDriver constructor #
# ShDriver constructor #
# ------------------------------------------------------------------------ #
def initialize(hypervisor)
super(15,true)
def initialize(hypervisor,threads)
super(threads,true)
@config = read_configuration
@hypervisor = hypervisor
@actions_path =
"#{ENV['ONE_LOCATION']}/lib/remotes/vmm/#{hypervisor}"
if ONE_LOCATION == nil
@actions_path = "/usr/lib/one"
else
@actions_path = "#{ENV['ONE_LOCATION']}/lib"
end
@actions_path << "/remotes/vmm/#{hypervisor}"
end
# ------------------------------------------------------------------------ #
@ -62,70 +67,68 @@ class ShDriver < VirtualMachineDriver
"Can not open deployment file #{local_dfile}")
return
end
deploy_exe = nil
cmd = "#{@actions_path}/deploy #{host} #{local_dfile}"
deploy_exe = LocalCommand.run(cmd, log_method(id))
if deploy_exe.code != 0
send_message(ACTION[:deploy],RESULT[:failure],id)
else
send_message(ACTION[:deploy],RESULT[:success],id,deploy_exe.stdout)
end
local_action("#{@actions_path}/deploy #{host} #{local_dfile}",id,:deploy)
end
# ------------------------------------------------------------------------ #
# Basic Domain Management Operations #
# ------------------------------------------------------------------------ #
def shutdown(id, host, deploy_id, not_used)
local_action("#{@actions_path}/shutdown #{host} #{deploy_id}",
id,
local_action("#{@actions_path}/shutdown #{host} #{deploy_id}", id,
:shutdown)
end
def cancel(id, host, deploy_id, not_used)
local_action("#{@actions_path}/cancel #{host} #{deploy_id}",
id,
:cancel)
local_action("#{@actions_path}/cancel #{host} #{deploy_id}", id, :cancel)
end
def save(id, host, deploy_id, file)
local_action("#{@actions_path}/save #{host} #{deploy_id} #{file}",
id,
local_action("#{@actions_path}/save #{host} #{deploy_id} #{file}", id,
:save)
end
def restore(id, host, deploy_id, file)
local_action("#{@actions_path}/restore #{host} #{file}",
id,
:restore)
local_action("#{@actions_path}/restore #{host} #{file}", id, :restore)
end
def migrate(id, host, deploy_id, dest_host)
local_action(
"#{@actions_path}/migrate #{host} #{deploy_id} #{dest_host}",
id,
:migrate)
"#{@actions_path}/migrate #{host} #{deploy_id} #{dest_host}", id,
:migrate)
end
def poll(id, host, deploy_id, not_used)
cmd = "#{@actions_path}/poll #{host} #{deploy_id}"
poll_exe = LocalCommand.run(cmd, log_method(id))
if poll_exe.code != 0
send_message(ACTION[:poll],RESULT[:failure],id)
else
send_message(ACTION[:poll],RESULT[:success],id,poll_exe.stdout)
end
local_action("#{@actions_path}/poll #{host} #{deploy_id}",id,:poll)
end
end
# ---------------------------------------------------------------------------- #
# ShDriver Main program
# ShDriver Main program #
# ---------------------------------------------------------------------------- #
hypervisor = ARGV[0]
opts = GetoptLong.new(
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ]
)
sh_driver = ShDriver.new(hypervisor)
hypervisor = ''
threads = 15
begin
opts.each do |opt, arg|
case opt
when '--threads'
threads = arg.to_i
end
end
rescue Exception => e
exit(-1)
end
if ARGV.length >= 1
hypervisor = ARGV.shift
else
exit(-1)
end
sh_driver = ShDriver.new(hypervisor,threads)
sh_driver.start_driver

View File

@ -1,20 +1,20 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# -------------------------------------------------------------------------.- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#---------------------------------------------------------------------------- #
# ---------------------------------------------------------------------------- #
# Set up the environment for the driver #
@ -34,20 +34,31 @@ $: << RUBY_LIB_LOCATION
require "VirtualMachineDriver"
# ---------------------------------------------------------------------------- #
# The main class for the Sh driver #
# ---------------------------------------------------------------------------- #
# ----------------------------------------------------------------------------
# The main class for the Sh driver
# ----------------------------------------------------------------------------
class SshDriver < VirtualMachineDriver
# ------------------------------------------------------------------------ #
# SshDriver constructor #
# ------------------------------------------------------------------------ #
def initialize(hypervisor)
super(15,true)
# ------------------------------------------------------------------------
# SshDriver constructor
# ------------------------------------------------------------------------
def initialize(hypervisor, threads, retries, localpoll)
super(threads,true,retries)
@config = read_configuration
@hypervisor = hypervisor
@remote_dir = @config['SCRIPTS_REMOTE_DIR']
@hypervisor = hypervisor
@remote_dir = @config['SCRIPTS_REMOTE_DIR']
@remote_path = "#{@config['SCRIPTS_REMOTE_DIR']}/vmm/#{@hypervisor}"
if ONE_LOCATION == nil
@actions_path = "/usr/lib/one"
else
@actions_path = "#{ENV['ONE_LOCATION']}/lib"
end
@actions_path << "/remotes/vmm/#{hypervisor}"
@localpoll = localpoll
end
# ------------------------------------------------------------------------ #
@ -66,48 +77,83 @@ class SshDriver < VirtualMachineDriver
domain = tmp.read
tmp.close()
remotes_action("#{@remote_dir}/vmm/#{@hypervisor}/deploy #{remote_dfile}",
id, host, :deploy, @remote_dir, domain)
remotes_action("#{@remote_path}/deploy #{remote_dfile}",
id, host, :deploy, @remote_dir, domain)
end
# ------------------------------------------------------------------------ #
# Basic Domain Management Operations #
# ------------------------------------------------------------------------ #
def shutdown(id, host, deploy_id, not_used)
remotes_action("#{@remote_dir}/vmm/#{@hypervisor}/shutdown #{deploy_id}",
id, host, :shutdown, @remote_dir)
remotes_action("#{@remote_path}/shutdown #{deploy_id}",
id, host, :shutdown, @remote_dir)
end
def cancel(id, host, deploy_id, not_used)
remotes_action("#{@remote_dir}/vmm/#{@hypervisor}/cancel #{deploy_id}",
id, host, :cancel, @remote_dir)
remotes_action("#{@remote_path}/cancel #{deploy_id}",
id, host, :cancel, @remote_dir)
end
def save(id, host, deploy_id, file)
remotes_action("#{@remote_dir}/vmm/#{@hypervisor}/save #{deploy_id} #{file}",
id, host, :save, @remote_dir)
remotes_action("#{@remote_path}/save #{deploy_id} #{file}",
id, host, :save, @remote_dir)
end
def restore(id, host, deploy_id, file)
remotes_action("#{@remote_dir}/vmm/#{@hypervisor}/restore #{file}",
id, host, :restore, @remote_dir)
remotes_action("#{@remote_path}/restore #{file}",
id, host, :restore, @remote_dir)
end
def migrate(id, host, deploy_id, dest_host)
remotes_action("#{@remote_dir}/vmm/#{@hypervisor}/migrate #{deploy_id} #{dest_host}",
id, host, :migrate, @remote_dir)
remotes_action("#{@remote_path}/migrate #{deploy_id} #{dest_host}",
id, host, :migrate, @remote_dir)
end
def poll(id, host, deploy_id, not_used)
remotes_action("#{@remote_dir}/vmm/#{@hypervisor}/poll #{deploy_id}",
id, host, :poll, @remote_dir)
if localpoll == true
local_action("#{@actions_path}/poll_local #{host} #{deploy_id}",id,
:poll)
else
remotes_action("#{@remote_path}/poll #{deploy_id}",
id, host, :poll, @remote_dir)
end
end
end
# ---------------------------------------------------------------------------- #
# SshDriver Main program
# ---------------------------------------------------------------------------- #
hypervisor = ARGV[0]
opts = GetoptLong.new(
[ '--retries', '-r', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--localpoll', '-l', GetoptLong::NO_ARGUMENT ]
)
ssh_driver = SshDriver.new(hypervisor)
hypervisor = ''
retries = 0
threads = 15
localpoll = false
begin
opts.each do |opt, arg|
case opt
when '--retries'
retries = arg.to_i
when '--threads'
threads = arg.to_i
when '--localpoll'
localpoll = true
end
end
rescue Exception => e
exit(-1)
end
if ARGV.length >= 1
hypervisor = ARGV.shift
else
exit(-1)
end
ssh_driver = SshDriver.new(hypervisor, threads, retries, localpoll)
ssh_driver.start_driver