mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
5275c4ea06
@ -14,6 +14,8 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
$: << '../'
|
||||
|
||||
require 'spec_common'
|
||||
|
||||
require 'client_mock'
|
||||
@ -21,7 +23,7 @@ require 'one_usage'
|
||||
|
||||
describe "OneUsage" do
|
||||
before(:all) do
|
||||
mock_data=YAML::load(File.read('spec/oca_vms.yaml'))
|
||||
mock_data=YAML::load(File.read('oca_vms.yaml'))
|
||||
client=ClientMock.new(mock_data)
|
||||
@one_usage=OneUsage.new(client)
|
||||
end
|
||||
|
@ -14,6 +14,8 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
$: << '../'
|
||||
|
||||
require 'spec_common'
|
||||
|
||||
require 'client_mock'
|
||||
@ -30,7 +32,7 @@ end
|
||||
describe 'Quota' do
|
||||
before(:all) do
|
||||
@db=Sequel.sqlite
|
||||
mock_data=YAML::load(File.read('spec/oca_vms.yaml'))
|
||||
mock_data=YAML::load(File.read('oca_vms.yaml'))
|
||||
client=ClientMock.new(mock_data)
|
||||
@quota=Quota.new(@db, client)
|
||||
end
|
||||
|
@ -14,6 +14,8 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
$: << '../'
|
||||
|
||||
require 'spec_common'
|
||||
|
||||
require 'client_mock'
|
||||
@ -64,7 +66,7 @@ end
|
||||
describe SimplePermissions do
|
||||
before(:all) do
|
||||
@db=Sequel.sqlite
|
||||
mock_data=YAML::load(File.read('spec/oca_vms.yaml'))
|
||||
mock_data=YAML::load(File.read('oca_vms.yaml'))
|
||||
client=ClientMock.new(mock_data)
|
||||
@perm=SimplePermissions.new(@db, client, YAML::load(CONF))
|
||||
end
|
||||
|
@ -16,10 +16,11 @@
|
||||
|
||||
require 'pp'
|
||||
|
||||
$: << '../../oca/ruby'
|
||||
$: << '..'
|
||||
|
||||
require 'db_helpers'
|
||||
|
||||
$: << '../oca/ruby'
|
||||
$: << './spec'
|
||||
|
||||
|
||||
|
||||
|
@ -160,15 +160,6 @@ private
|
||||
end
|
||||
|
||||
class RemotesCommand < SSHCommand
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
REMOTES_LOCATION="/var/lib/one/remotes"
|
||||
else
|
||||
REMOTES_LOCATION=ONE_LOCATION+"/var/remotes/"
|
||||
end
|
||||
|
||||
MAGIC_RC = 42
|
||||
|
||||
# Creates a command and runs it
|
||||
def self.run(command, host, remote_dir, logger=nil, stdin=nil, retries=0)
|
||||
@ -182,10 +173,7 @@ class RemotesCommand < SSHCommand
|
||||
|
||||
while cmd.code != 0 and retries != 0
|
||||
if cmd.code == MAGIC_RC
|
||||
cmd.update_remotes(host, remote_dir, logger)
|
||||
|
||||
@command = command
|
||||
cmd.run
|
||||
update_remotes(host, remote_dir, logger)
|
||||
end
|
||||
|
||||
sleep 1
|
||||
@ -196,9 +184,26 @@ class RemotesCommand < SSHCommand
|
||||
cmd
|
||||
end
|
||||
|
||||
def update_remotes(host, remote_dir, logger=nil)
|
||||
log("Remote worker node files not found")
|
||||
log("Updating remotes")
|
||||
private
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
REMOTES_LOCATION="/var/lib/one/remotes"
|
||||
else
|
||||
REMOTES_LOCATION=ONE_LOCATION+"/var/remotes/"
|
||||
end
|
||||
|
||||
MAGIC_RC = 42
|
||||
|
||||
def self.update_remotes(host, remote_dir, logger=nil)
|
||||
if logger != nil
|
||||
logger.call("Remote worker node files not found")
|
||||
logger.call("Updating remotes")
|
||||
end
|
||||
|
||||
#recreate remote dir structure
|
||||
SSHCommand.run("mkdir -p #{remote_dir}",host,logger)
|
||||
|
||||
# Use SCP to sync:
|
||||
sync_cmd = "scp -r #{REMOTES_LOCATION}/. #{host}:#{remote_dir}"
|
||||
|
@ -149,7 +149,7 @@ class OpenNebulaDriver < ActionManager
|
||||
if action_is_local? aname
|
||||
local_action(command, id, aname)
|
||||
else
|
||||
remotes_action(command, id, host, aname, @remote_scripts_path,
|
||||
remotes_action(command, id, host, aname, @remote_scripts_base_path,
|
||||
options[:stdin])
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
$: << '..'
|
||||
|
||||
require 'OpenNebulaDriver'
|
||||
require 'test/MonkeyPatcher'
|
||||
@ -26,7 +27,7 @@ class OpenNebulaDriver
|
||||
|
||||
def read_configuration
|
||||
old_one_location=ENV['ONE_LOCATION']
|
||||
ENV['ONE_LOCATION']=File.join(ENV['PWD'], 'test', 'fixtures')
|
||||
ENV['ONE_LOCATION']=File.join(ENV['PWD'], 'fixtures')
|
||||
result=read_configuration_old
|
||||
ENV['ONE_LOCATION']=old_one_location
|
||||
result
|
||||
|
Loading…
x
Reference in New Issue
Block a user