mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
bug #3315: use semantic versioning for remotes
onehost sync was using alphabetical comparison but this method does not work for this comparison: 4.10.0 > 4.8.0 Now the versions are parsed by Gem::Version, that comes with rubygems and should be installed in the frontend. When the version can not be parsed it falls back to text comparison or forces update if the comparison can not be made (one of the two versions is malformed). More information about semantic versioning: http://semver.org/
This commit is contained in:
parent
66400df2f8
commit
ddc4b757e7
@ -16,6 +16,7 @@
|
||||
|
||||
require 'one_helper'
|
||||
require 'one_helper/onevm_helper'
|
||||
require 'rubygems'
|
||||
|
||||
class OneHostHelper < OpenNebulaHelper::OneHelper
|
||||
TEMPLATE_XPATH = '//HOST/TEMPLATE'
|
||||
@ -178,6 +179,12 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
begin
|
||||
current_version = Gem::Version.new(current_version)
|
||||
rescue
|
||||
STDERR.puts "VERSION file is malformed, use semantic versioning."
|
||||
end
|
||||
|
||||
cluster_id = options[:cluster]
|
||||
|
||||
# Get remote_dir (implies oneadmin group)
|
||||
@ -218,8 +225,17 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
host_version=host['TEMPLATE/VERSION']
|
||||
|
||||
begin
|
||||
host_version = Gem::Version.new(host_version)
|
||||
rescue
|
||||
end
|
||||
|
||||
if !options[:force]
|
||||
next if host_version && host_version >= current_version
|
||||
begin
|
||||
next if host_version && host_version >= current_version
|
||||
rescue
|
||||
STDERR.puts "Error comparing versions for host #{host['NAME']}."
|
||||
end
|
||||
end
|
||||
|
||||
puts "* Adding #{host['NAME']} to upgrade"
|
||||
|
Loading…
x
Reference in New Issue
Block a user