mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
feature #595: remove whitespace
This commit is contained in:
parent
8974940f1b
commit
2fa210659e
@ -34,7 +34,7 @@ class OpenNebulaDriver < ActionManager
|
||||
attr_reader :local_scripts_base_path, :remote_scripts_base_path
|
||||
# @return [String] Path for scripts
|
||||
attr_reader :local_scripts_path, :remote_scripts_path
|
||||
|
||||
|
||||
# This function parses a string with this form:
|
||||
#
|
||||
# 'deploy,shutdown,poll=poll_ganglia, cancel '
|
||||
@ -94,7 +94,7 @@ class OpenNebulaDriver < ActionManager
|
||||
:retries => 0,
|
||||
:local_actions => {}
|
||||
}.merge!(options)
|
||||
|
||||
|
||||
super(@options[:concurrency], @options[:threaded])
|
||||
|
||||
@retries = @options[:retries]
|
||||
@ -331,27 +331,27 @@ private
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def read_configuration
|
||||
one_config=nil
|
||||
|
||||
|
||||
if ENV['ONE_LOCATION']
|
||||
one_config=ENV['ONE_LOCATION']+'/var/config'
|
||||
else
|
||||
one_config='/var/lib/one/config'
|
||||
end
|
||||
|
||||
|
||||
config=Hash.new
|
||||
cfg=''
|
||||
|
||||
|
||||
begin
|
||||
open(one_config) do |file|
|
||||
cfg=file.read
|
||||
end
|
||||
|
||||
|
||||
cfg.split(/\n/).each do |line|
|
||||
m=line.match(/^([^=]+)=(.*)$/)
|
||||
|
||||
|
||||
if m
|
||||
name=m[1].strip.upcase
|
||||
value=m[2].strip
|
||||
@ -362,7 +362,7 @@ private
|
||||
STDERR.puts "Error reading config: #{e.inspect}"
|
||||
STDERR.flush
|
||||
end
|
||||
|
||||
|
||||
config
|
||||
end
|
||||
end
|
||||
|
@ -71,7 +71,7 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
@options={
|
||||
:threaded => true
|
||||
}.merge!(options)
|
||||
|
||||
|
||||
super(directory, @options)
|
||||
|
||||
@hosts = Array.new
|
||||
|
@ -2,25 +2,25 @@
|
||||
class MonkeyPatcher
|
||||
def self.patch(&block)
|
||||
patcher=self.new
|
||||
|
||||
|
||||
patcher.instance_eval &block
|
||||
patcher.restore_all
|
||||
end
|
||||
|
||||
|
||||
def initialize
|
||||
@objects=Hash.new
|
||||
@klasses=Hash.new
|
||||
end
|
||||
|
||||
|
||||
def patch_class(klass, function, &block)
|
||||
@klasses[klass]={} if !@klasses[klass]
|
||||
@klasses[klass][function]=klass.instance_method(function)
|
||||
|
||||
|
||||
klass.instance_eval do
|
||||
define_method(function, block)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def restore_class(klass)
|
||||
@klasses[klass].each do |function, method|
|
||||
klass.instance_eval do
|
||||
@ -28,7 +28,7 @@ class MonkeyPatcher
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def restore_all
|
||||
@klasses.each do |klass, methods|
|
||||
restore_class(klass)
|
||||
|
@ -23,7 +23,7 @@ local_action_tests=[
|
||||
# modify read configuration to get config file from fixtures dir
|
||||
class OpenNebulaDriver
|
||||
alias :read_configuration_old :read_configuration
|
||||
|
||||
|
||||
def read_configuration
|
||||
old_one_location=ENV['ONE_LOCATION']
|
||||
ENV['ONE_LOCATION']=File.join(ENV['PWD'], 'test', 'fixtures')
|
||||
@ -43,42 +43,42 @@ describe OpenNebulaDriver do
|
||||
'POLL' => 'local_poll',
|
||||
'MIGRATE' => nil
|
||||
}
|
||||
|
||||
|
||||
@create_params=[@concurrecy, @threaded, @retries, @directory,
|
||||
@local_actions]
|
||||
end
|
||||
|
||||
|
||||
before(:each) do
|
||||
ENV['ONE_LOCATION']=nil
|
||||
end
|
||||
|
||||
|
||||
it 'should parse local actions' do
|
||||
local_action_tests.each do |test|
|
||||
OpenNebulaDriver.parse_actions_list(test[0]).should == test[1]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it 'should get correct paths' do
|
||||
driver=create_driver(*@create_params)
|
||||
|
||||
|
||||
driver.local_scripts_base_path.should == '/var/lib/one/remotes'
|
||||
driver.local_scripts_path.should == '/var/lib/one/remotes/vmm/dummy'
|
||||
driver.remote_scripts_base_path.should == '/var/tmp/one'
|
||||
driver.remote_scripts_path.should == '/var/tmp/one/vmm/dummy'
|
||||
|
||||
|
||||
ENV['ONE_LOCATION']='/one'
|
||||
|
||||
|
||||
driver=create_driver(*@create_params)
|
||||
|
||||
|
||||
driver.local_scripts_base_path.should == '/one/var/remotes'
|
||||
driver.local_scripts_path.should == '/one/var/remotes/vmm/dummy'
|
||||
driver.remote_scripts_base_path.should == '/var/tmp/one'
|
||||
driver.remote_scripts_path.should == '/var/tmp/one/vmm/dummy'
|
||||
end
|
||||
|
||||
|
||||
it 'should distinguish local and remote actions' do
|
||||
driver=create_driver(*@create_params)
|
||||
|
||||
|
||||
driver.action_is_local?(:deploy).should == false
|
||||
driver.action_is_local?('SHUTDOWN').should == false
|
||||
driver.action_is_local?(:migrate).should == true
|
||||
@ -86,10 +86,10 @@ describe OpenNebulaDriver do
|
||||
driver.action_is_local?(:MIGRATE).should == true
|
||||
driver.action_is_local?('MIGRATE').should == true
|
||||
end
|
||||
|
||||
|
||||
it 'should call correct executable' do
|
||||
driver=create_driver(*@create_params)
|
||||
|
||||
|
||||
driver.action_command_line(:deploy, 'parameter').should ==
|
||||
'/var/tmp/one/vmm/dummy/deploy parameter'
|
||||
driver.action_command_line(:poll, 'parameter').should ==
|
||||
@ -99,48 +99,48 @@ describe OpenNebulaDriver do
|
||||
driver.action_command_line(:test, 'parameter', 'testscr').should ==
|
||||
'/var/tmp/one/vmm/dummy/testscr parameter'
|
||||
end
|
||||
|
||||
|
||||
it 'should correctly send messages' do
|
||||
result=""
|
||||
driver=create_driver(*@create_params)
|
||||
|
||||
|
||||
MonkeyPatcher.patch do
|
||||
patch_class(IO, :puts) do |*args|
|
||||
result=args
|
||||
end
|
||||
|
||||
|
||||
driver.send_message('action', 'SUCCESS', 15, 'some info')
|
||||
end
|
||||
|
||||
|
||||
result[0].should == "action SUCCESS 15 some info"
|
||||
end
|
||||
|
||||
|
||||
it 'should select remote or local execution correctly' do
|
||||
local_action=[]
|
||||
remotes_action=[]
|
||||
|
||||
|
||||
driver=create_driver(*@create_params)
|
||||
|
||||
|
||||
MonkeyPatcher.patch do
|
||||
patch_class(OpenNebulaDriver, :local_action) do |*args|
|
||||
local_action=args
|
||||
end
|
||||
|
||||
|
||||
patch_class(OpenNebulaDriver, :remotes_action) do |*args|
|
||||
remotes_action=args
|
||||
end
|
||||
|
||||
|
||||
driver.do_action('some parameters', 15, 'localhost', :poll)
|
||||
driver.do_action('some parameters', 15, 'localhost', :deploy,
|
||||
:script_name => 'deploy_script')
|
||||
end
|
||||
|
||||
|
||||
local_action.should == [
|
||||
"/var/lib/one/remotes/vmm/dummy/local_poll some parameters 15"<<
|
||||
" localhost",
|
||||
15,
|
||||
:poll]
|
||||
|
||||
|
||||
remotes_action.should == ["/var/tmp/one/vmm/dummy/deploy_script"<<
|
||||
" some parameters 15 localhost",
|
||||
15,
|
||||
@ -149,6 +149,6 @@ describe OpenNebulaDriver do
|
||||
"/var/tmp/one/vmm/dummy",
|
||||
nil]
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user