From d6defb6bb8b421edbc3f2958ae7ddfc6d767f631 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 30 Sep 2011 00:40:51 +0200 Subject: [PATCH] feature #789: Solves minor bugs in host update for VDC. Deals with empty host lists --- src/ozones/Server/lib/OZones/VDC.rb | 17 ++++++++++++----- src/ozones/Server/models/OzonesServer.rb | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) 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