diff --git a/src/ozones/Server/lib/OZones/VDC.rb b/src/ozones/Server/lib/OZones/VDC.rb index bee904a431..6c452af31f 100644 --- a/src/ozones/Server/lib/OZones/VDC.rb +++ b/src/ozones/Server/lib/OZones/VDC.rb @@ -173,8 +173,11 @@ module OZones # Delete existing host ACLs delete_host_acls - @vdc.acls =~ /((\d+,){#{HOST_ACL_FIRST_ID}}).*/ - newacls = $1.chop + if @vdc.acls =~ /((\d+,){#{HOST_ACL_FIRST_ID}}).*/ + newacls = $1.chop + else + newacls = @vdc.acls.clone + end # Create new ACLs. TODO Rollback ACL creation if !host_list.empty? @@ -251,9 +254,13 @@ module OZones ####################################################################### # Deletes ACLs for the hosts def delete_host_acls - @vdc.acls.split(',')[HOST_ACL_FIRST_ID..-1].each{|acl| - OpenNebula::Acl.new_with_id(acl.to_i, @client).delete - } + host_acls = @vdc.acls.split(',')[HOST_ACL_FIRST_ID..-1] + + if host_acls + host_acls.each{|acl| + OpenNebula::Acl.new_with_id(acl.to_i, @client).delete + } + end end # Delete ACLs diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index 120dcfe092..ca47d85fdf 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -256,6 +256,8 @@ class OzonesServer # Check if hosts are already include in any Vdc of the zone def host_uniqueness?(zone, host_list, vdc_id = -1) + return true if host_list.empty? + all_hosts = "" zone.vdcs.all.each{|vdc| if vdc.hosts != nil and !vdc.hosts.empty? and vdc.id != vdc_id