diff --git a/src/onedb/2.0_to_2.9.80.rb b/src/onedb/2.0_to_2.9.80.rb index 01054ecb4d..20d47aeb62 100644 --- a/src/onedb/2.0_to_2.9.80.rb +++ b/src/onedb/2.0_to_2.9.80.rb @@ -256,10 +256,16 @@ module Migrator group = (uid == 0) ? "oneadmin" : "users" public = row[:public] + total_leases = 0 + @db.fetch("SELECT COUNT (ip) FROM old_leases WHERE (oid=#{oid} AND used=1)") do |r| + total_leases = r[:"COUNT (ip)"] + end + + # is stored in the DB, but it is not used to rebuild # the VirtualNetwork object, and it is generated each time the # network is listed. So setting it to 0 is safe - body = "#{oid}#{uid}#{gid}#{get_username(uid)}#{group}#{name}#{row[:type]}#{row[:bridge]}#{public}0#{row[:template]}" + body = "#{oid}#{uid}#{gid}#{get_username(uid)}#{group}#{name}#{row[:type]}#{row[:bridge]}#{public}#{total_leases}#{row[:template]}" @db[:network_pool].insert( :oid => oid, diff --git a/src/scheduler/include/HostPoolXML.h b/src/scheduler/include/HostPoolXML.h index 843790602e..8160262df6 100644 --- a/src/scheduler/include/HostPoolXML.h +++ b/src/scheduler/include/HostPoolXML.h @@ -46,7 +46,7 @@ protected: int get_suitable_nodes(vector& content) { - return get_nodes("/HOST_POOL/HOST[STATE=2]", content); + return get_nodes("/HOST_POOL/HOST[STATE<3]", content); }; void add_object(xmlNodePtr node);