From a935e147fbe9cd26b96666f1de6b7389a01f1d94 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 30 Apr 2012 13:48:40 +0200 Subject: [PATCH 01/11] Bug #1213: Handle errors when listing aggregated resources and zone resources when one or several zones are down. --- src/ozones/Server/lib/OZones/AggregatedPool.rb | 16 +++++++--------- src/ozones/Server/lib/OZones/Zones.rb | 8 +++++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ozones/Server/lib/OZones/AggregatedPool.rb b/src/ozones/Server/lib/OZones/AggregatedPool.rb index 6ac96ce8a8..b098b8d1bb 100644 --- a/src/ozones/Server/lib/OZones/AggregatedPool.rb +++ b/src/ozones/Server/lib/OZones/AggregatedPool.rb @@ -34,26 +34,24 @@ module OZones zone_pool_hash = zone.to_hash["ZONE"] - client = OpenNebula::Client.new("#{zone.ONENAME}:#{zone.ONEPASS}", - zone.ENDPOINT) + client = OpenNebula::Client.new("#{zone.ONENAME}:#{zone.ONEPASS}", + zone.ENDPOINT) pool = factory(client) - if OpenNebula.is_error?(pool) - zone_pool_hash.merge!(pool.to_hash) - next - end - rc = pool.info - if !rc zone_pool_hash.merge!(pool.to_hash) + elsif OpenNebula.is_error?(rc) + error = "Error communicating with #{zone.NAME}." + error << " Retrieving #{self.class.name.split('::').last}: " + error << "#{rc.to_str}" + zone_pool_hash.merge!({:error => {:message => error}}) else zone_pool_hash.merge!(rc.to_hash) end @sup_aggregated_pool[@tag]["ZONE"] << zone_pool_hash - } end diff --git a/src/ozones/Server/lib/OZones/Zones.rb b/src/ozones/Server/lib/OZones/Zones.rb index 95300c0d0d..34b48e655a 100644 --- a/src/ozones/Server/lib/OZones/Zones.rb +++ b/src/ozones/Server/lib/OZones/Zones.rb @@ -199,7 +199,13 @@ module OZones return [404, error.to_json] end - pool.info + rc = pool.info + if OpenNebula.is_error?(rc) + error = "Error communicating with #{@zone.NAME}." + error << " Retrieving #{pool_kind} pool: " + error << "#{rc.to_str}" + return [500, OZones::Error.new(error).to_json] + end return [200, pool.to_json] end From edd607baa9be19ef3d5c39f27b43853fa4705dbb Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 30 Apr 2012 13:56:45 +0200 Subject: [PATCH 02/11] Bug #1215: Add SUNSENDPOINT AND SELFENDPOINT to onezone show command --- src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb b/src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb index 71d85c7610..d255d0b65a 100644 --- a/src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb @@ -44,6 +44,8 @@ class ZonesHelper < OZonesHelper::OZHelper puts str % ["ZONE ADMIN ",zone[:ONENAME].to_s] puts str % ["ZONE PASS ", zone[:ONEPASS].to_s] puts str % ["ENDPOINT ", zone[:ENDPOINT].to_s] + puts str % ["SUNSENDPOINT ", zone[:SUNSENDPOINT].to_s] + puts str % ["SELFENDPOINT ", zone[:SELFENDPOINT].to_s] puts str % ["# VDCS ", zone[:VDCS].size.to_s] puts From 351ae0113862eb37c84804cd240b88c9ef869405 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 30 Apr 2012 14:06:04 +0200 Subject: [PATCH 03/11] Bug #1217: correct hosts, dss, vnets lists in onevdc show --- src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb index 8f8a98b026..808a099e3f 100644 --- a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb @@ -157,9 +157,9 @@ class VDCHelper < OZonesHelper::OZHelper puts str % ["CLUSTER_ID ", vdc[:CLUSTER_ID].to_s] puts str % ["GROUP_ID ", vdc[:GROUP_ID].to_s] puts str % ["VDCADMIN ", vdc[:VDCADMINNAME].to_s] - puts str % ["HOSTS ", vdc[:RESOURCES][:HOSTS].to_s] - puts str % ["DATASTORES ", vdc[:RESOURCES][:DATASTORES].to_s] - puts str % ["NETWORKS ", vdc[:RESOURCES][:NETWORKS].to_s] + puts str % ["HOSTS ", vdc[:RESOURCES][:HOSTS].join(',')] + puts str % ["DATASTORES ", vdc[:RESOURCES][:DATASTORES].join(',')] + puts str % ["NETWORKS ", vdc[:RESOURCES][:NETWORKS].join(',')] puts return 0 From 26c51cb3a3b48174625e56f08e3219dfd24ae19d Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 3 May 2012 13:41:04 +0200 Subject: [PATCH 04/11] Feature #1125: Move ozones to Sequel instead of Datamapper --- src/ozones/Server/lib/OZones/ApacheWritter.rb | 4 +- src/ozones/Server/lib/OZones/VDC.rb | 79 +++++++++++-------- src/ozones/Server/lib/OZones/Zones.rb | 52 +++++++----- src/ozones/Server/models/Auth.rb | 19 +++-- src/ozones/Server/models/OzonesServer.rb | 13 ++- src/ozones/Server/ozones-server.rb | 21 +++-- 6 files changed, 109 insertions(+), 79 deletions(-) diff --git a/src/ozones/Server/lib/OZones/ApacheWritter.rb b/src/ozones/Server/lib/OZones/ApacheWritter.rb index ca3ae1fdd3..47832c93ba 100644 --- a/src/ozones/Server/lib/OZones/ApacheWritter.rb +++ b/src/ozones/Server/lib/OZones/ApacheWritter.rb @@ -24,8 +24,8 @@ module OZones def update htaccess = "RewriteEngine On\n" - OZones::Zones.all.each{|zone| - zone.vdcs.all.each{|vdc| + OZones::Zones.each{|zone| + zone.vdcs.each{|vdc| htaccess << "RewriteRule ^#{vdc.NAME} " + "#{zone.ENDPOINT} [P]\n" diff --git a/src/ozones/Server/lib/OZones/VDC.rb b/src/ozones/Server/lib/OZones/VDC.rb index 46ec6de56f..263f11eabc 100644 --- a/src/ozones/Server/lib/OZones/VDC.rb +++ b/src/ozones/Server/lib/OZones/VDC.rb @@ -22,28 +22,42 @@ module OZones # ID, NAME, the GROUP backing the VDC, the admin credentials and the VDC # resources. VDC resources are stored in JSON document in the DB and used as # a hash in the VDC. - class Vdc - include DataMapper::Resource + class Vdc < Sequel::Model include OpenNebulaJSON::JSONUtils extend OpenNebulaJSON::JSONUtils - property :ID, Serial - property :NAME, String, :required => true, :unique => true - property :GROUP_ID, Integer - property :VDCADMINNAME, String, :required => true - property :VDCADMIN_ID, Integer - property :CLUSTER_ID, Integer - property :RESOURCES, Text + plugin :schema + plugin :validation_helpers - belongs_to :zones + set_schema do + primary_key :ID + String :NAME, :unique => true + Integer :GROUP_ID + foreign_key :ZONES_ID, :zones, :key => :ID + String :VDCADMINNAME + Integer :VDCADMIN_ID + Integer :CLUSTER_ID + String :RESOURCES, :text => true + + end + + create_table unless table_exists? + + many_to_one :zone, :class => 'OZones::Zones', :key => :ZONES_ID + + def validate + super + validates_presence [:NAME, :VDCADMINNAME] + validates_unique :NAME + end def resources rsrc_json = self.RESOURCES parser = JSON.parser.new(rsrc_json, {:symbolize_names => true}) parser.parse - end - + end + def resources=(rsrc_hash) self.RESOURCES = JSON.generate(rsrc_hash) end @@ -55,11 +69,7 @@ module OZones zonePoolHash["VDC_POOL"]["VDC"] = Array.new unless self.all.empty? self.all.each{ |vdc| - # Hack! zones_ID does not respect the "all capital letters" policy - attrs = vdc.attributes.clone - - attrs[:ZONES_ID] = vdc.attributes[:zones_ID] - attrs.delete(:zones_ID) + attrs = vdc.values.clone rsrc_json = attrs.delete(:RESOURCES) parser = JSON.parser.new(rsrc_json, {:symbolize_names=>true}) @@ -74,11 +84,7 @@ module OZones def to_hash vdc_attributes = Hash.new - # Hack! zones_ID does not respect the "all capital letters" policy - attrs = attributes.clone - - attrs[:ZONES_ID] = attributes[:zones_ID] - attrs.delete(:zones_ID) + attrs = @values.clone rsrc_json = attrs.delete(:RESOURCES) parser = JSON.parser.new(rsrc_json, {:symbolize_names=>true}) @@ -99,9 +105,9 @@ module OZones ####################################################################### # Constants ####################################################################### - VDC_ATTRS = [:VDCADMINNAME, - :VDCADMINPASS, - :NAME, + VDC_ATTRS = [:VDCADMINNAME, + :VDCADMINPASS, + :NAME, :CLUSTER_ID, :RESOURCES] @@ -111,13 +117,13 @@ module OZones #Creates an OpenNebula VDC, using its ID, vdcid and the associated zone def initialize(vdcid, zone = nil) if vdcid != -1 - @vdc = Vdc.get(vdcid) + @vdc = Vdc[vdcid] if !@vdc raise "VDC with id #{vdcid} not found." end - @zone = OZones::Zones.get(@vdc.zones_ID) + @zone = OZones::Zones[@vdc.ZONES_ID] else @zone = zone end @@ -150,9 +156,17 @@ module OZones #------------------------------------------------------------------- # Create a vdc record & check cluster consistency #------------------------------------------------------------------- - @vdc = Vdc.new + begin - @vdc.attributes = vdc_data + + @vdc = Vdc.new + + @vdc.update(vdc_data) + @vdc.ZONES_ID = @zone.ID + + rescue => e + return OpenNebula::Error.new(e.message) + end rc = resources_in_cluster?(rsrc) @@ -198,10 +212,11 @@ module OZones rc, acl_ids = create_acls(rules) return rollback(group, user, acl_ids,rc) if OpenNebula.is_error?(rc) - OzonesServer::logger.debug {"ACLs #{acl_ids} created"} + OzonesServer::logger.debug {"ACLs #{acl_ids} created"} rsrc[:ACLS] = acl_ids @vdc.resources = rsrc + @vdc.save return true end @@ -283,10 +298,8 @@ module OZones #Update the VDC Record # ------------------------------------------------------------------ begin - @vdc.raise_on_save_failure = true @vdc.resources = rsrc_hash - - @vdc.save + @vdc.save(:raise_on_failure => true) rescue => e return OpenNebula::Error.new(e.message) end diff --git a/src/ozones/Server/lib/OZones/Zones.rb b/src/ozones/Server/lib/OZones/Zones.rb index 34b48e655a..25340469ed 100644 --- a/src/ozones/Server/lib/OZones/Zones.rb +++ b/src/ozones/Server/lib/OZones/Zones.rb @@ -16,29 +16,42 @@ module OZones - class Zones - include DataMapper::Resource + class Zones < Sequel::Model include OpenNebulaJSON::JSONUtils extend OpenNebulaJSON::JSONUtils + plugin :schema + plugin :validation_helpers + ####################################################################### # Data Model for the Zone ####################################################################### - property :ID, Serial - property :NAME, String, :required => true, :unique => true - property :ONENAME, String, :required => true - property :ONEPASS, String, :required => true - property :ENDPOINT, String, :required => true - property :SUNSENDPOINT, String - property :SELFENDPOINT, String + set_schema do + primary_key :ID + String :NAME, :unique => true + String :ONENAME + String :ONEPASS + String :ENDPOINT + String :SUNSENDPOINT + String :SELFENDPOINT + end - has n, :vdcs + create_table unless table_exists? + + one_to_many :vdcs, :class => 'OZones::Vdc', :key => :ZONES_ID ####################################################################### # Constants ####################################################################### ZONE_ATTRS = [:ONENAME, :ONEPASS, :ENDPOINT, :NAME] + def validate + super + validates_presence ZONE_ATTRS + validates_unique :NAME + end + + ####################################################################### # JSON Functions ####################################################################### @@ -47,11 +60,11 @@ module OZones zonePoolHash["ZONE_POOL"] = Hash.new zonePoolHash["ZONE_POOL"]["ZONE"] = Array.new unless self.all.empty? - self.all.each{|zone| - zattr = zone.attributes.clone + self.each{|zone| + zattr = zone.values.clone zattr[:ONEPASS] = Zones.encrypt(zattr[:ONEPASS]) - zattr[:NUMBERVDCS] = zone.vdcs.all.size + zattr[:NUMBERVDCS] = zone.vdcs.size zonePoolHash["ZONE_POOL"]["ZONE"] << zattr } @@ -62,12 +75,12 @@ module OZones def to_hash zattr = Hash.new - zattr["ZONE"] = attributes.clone + zattr["ZONE"] = @values.clone zattr["ZONE"][:ONEPASS] = Zones.encrypt(zattr["ZONE"][:ONEPASS]) zattr["ZONE"][:VDCS] = Array.new - self.vdcs.all.each{|vdc| - zattr["ZONE"][:VDCS]<< vdc.attributes.clone + self.vdcs.each{|vdc| + zattr["ZONE"][:VDCS]<< vdc.values.clone } return zattr @@ -111,10 +124,7 @@ module OZones # Create the zone begin zone = Zones.new - zone.raise_on_save_failure = true - - zone.attributes = zone_data - zone.save + zone.update(zone_data) rescue => e return OZones::Error.new(e.message) end @@ -165,7 +175,7 @@ module OZones ########################################################################## class OpenNebulaZone def initialize(zoneid) - @zone = Zones.get(zoneid) + @zone = Zones[zoneid] if !@zone raise "Error: Zone with id #{zoneid} not found" diff --git a/src/ozones/Server/models/Auth.rb b/src/ozones/Server/models/Auth.rb index 220c82a2b1..bda86623c9 100644 --- a/src/ozones/Server/models/Auth.rb +++ b/src/ozones/Server/models/Auth.rb @@ -14,12 +14,21 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -class Auth +class Auth < Sequel::Model + plugin :schema + plugin :validation_helpers - include DataMapper::Resource + set_schema do + primary_key :id + String :name, :unique => true + String :password + end - property :id, Serial - property :name, String, :required => true, :unique => true - property :password, String, :required => true + create_table unless table_exists? + def validate + super + validates_unique(:name) + validates_presence [:name, :password] + end end diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index 2777fe6532..ca58210ae1 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -36,7 +36,7 @@ class OzonesServer < CloudServer # Gets a VDC def get_vdc(id) - vdc = OZones::Vdc.get(id) + vdc = OZones::Vdc[id] if vdc return [200, vdc.to_json] @@ -53,7 +53,7 @@ class OzonesServer < CloudServer #Gets a zone def get_zone(id) - zone = OZones::Zones.get(id) + zone = OZones::Zones[id] if zone return [200, zone.to_json] @@ -101,7 +101,7 @@ class OzonesServer < CloudServer "Mandatory attribute zoneid missing.").to_json] end - zone = OZones::Zones.get(zoneid) + zone = OZones::Zones[zoneid] if !zone return [404, OZones::Error.new("Error: Couldn't create vdc. " \ "Zone #{zoneid} not found.").to_json] @@ -126,11 +126,10 @@ class OzonesServer < CloudServer #----------------------------------------------------------------------- #Update the zone and save the vdc #----------------------------------------------------------------------- - zone.raise_on_save_failure = true zone.vdcs << vdc.vdc begin - zone.save + zone.save(:raise_on_failture => true) rescue => e #vdc.clean_bootstrap logger.error {"create_vdc: #{e.resource.errors.inspect}"} @@ -231,7 +230,7 @@ class OzonesServer < CloudServer end def delete_zone(id, pr) - zone = OZones::Zones.get(id) + zone = OZones::Zones[id] if zone rc = zone.destroy @@ -264,7 +263,7 @@ class OzonesServer < CloudServer all_hosts = Array.new - zone.vdcs.all(:CLUSTER_ID =>c_id).each{ |vdc| + zone.vdcs(:CLUSTER_ID =>c_id).each{ |vdc| rsrc = vdc.resources if !rsrc[:HOSTS].empty? and vdc.ID != vdc_data[:ID] diff --git a/src/ozones/Server/ozones-server.rb b/src/ozones/Server/ozones-server.rb index 70eb42323a..dd9634a62e 100755 --- a/src/ozones/Server/ozones-server.rb +++ b/src/ozones/Server/ozones-server.rb @@ -51,7 +51,7 @@ require 'sinatra' require 'yaml' require 'rubygems' -require 'data_mapper' +require 'sequel' require 'digest/sha1' require 'OzonesServer' @@ -102,18 +102,16 @@ enable_logging OZONES_LOG, settings.config[:debug_level].to_i ############################################################################## # DB bootstrapping ############################################################################## -if config[:dbdebug] - DataMapper::Logger.new($stdout, :debug) -end -DataMapper.setup(:default, db_url) +DB = Sequel.connect(db_url) + +if config[:dbdebug] + DB.loggers << settings.logger +end require 'OZones' require 'Auth' -DataMapper.finalize -DataMapper.auto_upgrade! - if Auth.all.size == 0 if ENV['OZONES_AUTH'] && File.exist?(ENV['OZONES_AUTH']) credentials = IO.read(ENV['OZONES_AUTH']).strip.split(':') @@ -123,9 +121,10 @@ if Auth.all.size == 0 exit -1 end credentials[1] = Digest::SHA1.hexdigest(credentials[1]) - @auth=Auth.create({:name => credentials[0], - :password => credentials[1]}) - @auth.save + @auth=Auth.new + @auth.name = credentials[0] + @auth.password = credentials[1] + @auth.save(:raise_on_failure => true) else error_m = "oZones admin credentials not set, missing OZONES_AUTH file." settings.logger.error { error_m } From 77fe50271bfe7d5684bf0f70a99d6ac7900eb09b Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 4 May 2012 13:38:12 +0200 Subject: [PATCH 05/11] Ozones: update tests to work with latest developments --- src/ozones/test/examples/pool/vdcpool0.json | 68 +++++++++---------- .../test/examples/pool/vdcpool_deleted.json | 42 ++++++------ src/ozones/test/examples/pool/zonepool0.json | 28 ++++---- .../test/examples/pool/zonepool_deleted.json | 14 ++-- src/ozones/test/examples/vdc/vdc0.json | 16 ++--- src/ozones/test/examples/zone/zone0.json | 12 ++-- src/ozones/test/spec/VDCManagement_spec.rb | 25 +++++-- src/ozones/test/spec/ZoneManagement_spec.rb | 26 +++++-- 8 files changed, 132 insertions(+), 99 deletions(-) diff --git a/src/ozones/test/examples/pool/vdcpool0.json b/src/ozones/test/examples/pool/vdcpool0.json index a1bdeb5bb3..4029a5a990 100644 --- a/src/ozones/test/examples/pool/vdcpool0.json +++ b/src/ozones/test/examples/pool/vdcpool0.json @@ -2,13 +2,9 @@ "VDC_POOL": { "VDC": [ { - "NAME": "vdcA", + "VDCADMINNAME": "vdcadminA", "VDCADMIN_ID": 2, - "ID": 1, "RESOURCES": { - "DATASTORES": [ - 100 - ], "HOSTS": [ 0, 1, @@ -27,21 +23,21 @@ 8, 9, 10 - ] - }, - "GROUP_ID": 100, - "ZONES_ID": 1, - "VDCADMINNAME": "vdcadminA", - "CLUSTER_ID": 100 - }, - { - "NAME": "vdcB", - "VDCADMIN_ID": 2, - "ID": 2, - "RESOURCES": { + ], "DATASTORES": [ 100 - ], + ] + }, + "NAME": "vdcA", + "CLUSTER_ID": 100, + "ZONES_ID": 1, + "ID": 1, + "GROUP_ID": 100 + }, + { + "VDCADMINNAME": "vdcadminB", + "VDCADMIN_ID": 2, + "RESOURCES": { "HOSTS": [ 1 ], @@ -56,21 +52,21 @@ 6, 7, 8 - ] - }, - "GROUP_ID": 100, - "ZONES_ID": 2, - "VDCADMINNAME": "vdcadminB", - "CLUSTER_ID": 100 - }, - { - "NAME": "vdcC", - "VDCADMIN_ID": 3, - "ID": 3, - "RESOURCES": { + ], "DATASTORES": [ 100 - ], + ] + }, + "NAME": "vdcB", + "CLUSTER_ID": 100, + "ZONES_ID": 2, + "ID": 2, + "GROUP_ID": 100 + }, + { + "VDCADMINNAME": "vdcadminC", + "VDCADMIN_ID": 3, + "RESOURCES": { "HOSTS": [ 3 ], @@ -85,12 +81,16 @@ 15, 16, 17 + ], + "DATASTORES": [ + 100 ] }, - "GROUP_ID": 101, + "NAME": "vdcC", + "CLUSTER_ID": 100, "ZONES_ID": 1, - "VDCADMINNAME": "vdcadminC", - "CLUSTER_ID": 100 + "ID": 3, + "GROUP_ID": 101 } ] } diff --git a/src/ozones/test/examples/pool/vdcpool_deleted.json b/src/ozones/test/examples/pool/vdcpool_deleted.json index 9933c90dc9..1de8ad38a2 100644 --- a/src/ozones/test/examples/pool/vdcpool_deleted.json +++ b/src/ozones/test/examples/pool/vdcpool_deleted.json @@ -2,13 +2,9 @@ "VDC_POOL": { "VDC": [ { - "NAME": "vdcA", + "VDCADMINNAME": "vdcadminA", "VDCADMIN_ID": 2, - "ID": 1, "RESOURCES": { - "DATASTORES": [ - 100 - ], "HOSTS": [ 0, 1, @@ -27,21 +23,21 @@ 8, 9, 10 - ] - }, - "GROUP_ID": 100, - "ZONES_ID": 1, - "VDCADMINNAME": "vdcadminA", - "CLUSTER_ID": 100 - }, - { - "NAME": "vdcB", - "VDCADMIN_ID": 2, - "ID": 2, - "RESOURCES": { + ], "DATASTORES": [ 100 - ], + ] + }, + "NAME": "vdcA", + "CLUSTER_ID": 100, + "ZONES_ID": 1, + "ID": 1, + "GROUP_ID": 100 + }, + { + "VDCADMINNAME": "vdcadminB", + "VDCADMIN_ID": 2, + "RESOURCES": { "HOSTS": [ 1 ], @@ -56,12 +52,16 @@ 6, 7, 8 + ], + "DATASTORES": [ + 100 ] }, - "GROUP_ID": 100, + "NAME": "vdcB", + "CLUSTER_ID": 100, "ZONES_ID": 2, - "VDCADMINNAME": "vdcadminB", - "CLUSTER_ID": 100 + "ID": 2, + "GROUP_ID": 100 } ] } diff --git a/src/ozones/test/examples/pool/zonepool0.json b/src/ozones/test/examples/pool/zonepool0.json index 55e4228586..deb2b87d23 100644 --- a/src/ozones/test/examples/pool/zonepool0.json +++ b/src/ozones/test/examples/pool/zonepool0.json @@ -2,24 +2,24 @@ "ZONE_POOL": { "ZONE": [ { - "NAME": "zoneA", - "SUNSENDPOINT": "http://localhost:9869", - "SELFENDPOINT": null, - "ONENAME": "oneadminA", - "ID": 1, - "ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA==", "ENDPOINT": "http://localhost:2666/RPC2", - "NUMBERVDCS": 0 + "SUNSENDPOINT": "http://localhost:9869", + "NAME": "zoneA", + "SELFENDPOINT": null, + "NUMBERVDCS": 0, + "ID": 1, + "ONENAME": "oneadminA", + "ONEPASS": "e/TkohQckqFcmcWFwrirUapdiLkg87GHPafKnxkzznk=" }, { - "NAME": "zoneB", - "SUNSENDPOINT": null, - "SELFENDPOINT": null, - "ONENAME": "oneadminB", - "ID": 2, - "ONEPASS": "8Si8vlo2P3qn5/SNxkMkDg==", "ENDPOINT": "http://localhost:2667/RPC2", - "NUMBERVDCS": 0 + "SUNSENDPOINT": null, + "NAME": "zoneB", + "SELFENDPOINT": null, + "NUMBERVDCS": 0, + "ID": 2, + "ONENAME": "oneadminB", + "ONEPASS": "DrnuZMnmOFVeYTXTVwTgEmOGw2orTjaU/f1NyuNKlQY=" } ] } diff --git a/src/ozones/test/examples/pool/zonepool_deleted.json b/src/ozones/test/examples/pool/zonepool_deleted.json index 0176e04da5..bf4910f018 100644 --- a/src/ozones/test/examples/pool/zonepool_deleted.json +++ b/src/ozones/test/examples/pool/zonepool_deleted.json @@ -2,14 +2,14 @@ "ZONE_POOL": { "ZONE": [ { - "NAME": "zoneA", - "SUNSENDPOINT": "http://localhost:9869", - "SELFENDPOINT": null, - "ONENAME": "oneadminA", - "ID": 1, - "ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA==", "ENDPOINT": "http://localhost:2666/RPC2", - "NUMBERVDCS": 0 + "SUNSENDPOINT": "http://localhost:9869", + "NAME": "zoneA", + "SELFENDPOINT": null, + "NUMBERVDCS": 0, + "ID": 1, + "ONENAME": "oneadminA", + "ONEPASS": "e/TkohQckqFcmcWFwrirUapdiLkg87GHPafKnxkzznk=" } ] } diff --git a/src/ozones/test/examples/vdc/vdc0.json b/src/ozones/test/examples/vdc/vdc0.json index 35d7a92420..d07db9c90c 100644 --- a/src/ozones/test/examples/vdc/vdc0.json +++ b/src/ozones/test/examples/vdc/vdc0.json @@ -1,12 +1,8 @@ { "VDC": { - "NAME": "vdcA", + "VDCADMINNAME": "vdcadminA", "VDCADMIN_ID": 2, - "ID": 1, "RESOURCES": { - "DATASTORES": [ - 100 - ], "HOSTS": [ 0, 1, @@ -25,11 +21,15 @@ 8, 9, 10 + ], + "DATASTORES": [ + 100 ] }, - "GROUP_ID": 100, + "NAME": "vdcA", + "CLUSTER_ID": 100, "ZONES_ID": 1, - "VDCADMINNAME": "vdcadminA", - "CLUSTER_ID": 100 + "ID": 1, + "GROUP_ID": 100 } } \ No newline at end of file diff --git a/src/ozones/test/examples/zone/zone0.json b/src/ozones/test/examples/zone/zone0.json index 108a250402..b7788ca34f 100644 --- a/src/ozones/test/examples/zone/zone0.json +++ b/src/ozones/test/examples/zone/zone0.json @@ -1,14 +1,14 @@ { "ZONE": { - "NAME": "zoneA", + "ENDPOINT": "http://localhost:2666/RPC2", "SUNSENDPOINT": "http://localhost:9869", + "NAME": "zoneA", + "SELFENDPOINT": null, + "ID": 1, + "ONENAME": "oneadminA", "VDCS": [ ], - "SELFENDPOINT": null, - "ONENAME": "oneadminA", - "ID": 1, - "ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA==", - "ENDPOINT": "http://localhost:2666/RPC2" + "ONEPASS": "e/TkohQckqFcmcWFwrirUapdiLkg87GHPafKnxkzznk=" } } \ No newline at end of file diff --git a/src/ozones/test/spec/VDCManagement_spec.rb b/src/ozones/test/spec/VDCManagement_spec.rb index 1d006721e3..8a5eeca459 100644 --- a/src/ozones/test/spec/VDCManagement_spec.rb +++ b/src/ozones/test/spec/VDCManagement_spec.rb @@ -154,13 +154,25 @@ module OZones it "should be able to retrieve the vdc pool" do vdcpool = @vdchelper.list_pool({:json => true}) vdcpool[0].should eql(0) - vdcpool[1].should eql(File.read(TESTS_PATH+"examples/pool/vdcpool0.json")) + + got = vdcpool[1] + expected = File.read(TESTS_PATH+"examples/pool/vdcpool0.json") + + got = JSON.parser.new(got, {:symbolize_names => true}).parse + expected = JSON.parser.new(expected, {:symbolize_names => true}).parse + got.should eql(expected) end it "should be able to retrieve a particular vdc" do vdc = @vdchelper.show_resource(1, {:json => true}) vdc[0].should eql(0) - vdc[1].should eql(File.read(TESTS_PATH+"examples/vdc/vdc0.json")) + + got = vdc[1] + expected = File.read(TESTS_PATH+"examples/vdc/vdc0.json") + + got = JSON.parser.new(got, {:symbolize_names => true}).parse + expected = JSON.parser.new(expected, {:symbolize_names => true}).parse + got.should eql(expected) end it "should allow deleting a vdc" do @@ -168,8 +180,13 @@ module OZones rc[0].should eql(0) rc = @vdchelper.list_pool({:json => true}) rc[0].should eql(0) - rc[1].should eql(File.read(TESTS_PATH+ - "examples/pool/vdcpool_deleted.json")) + + got = rc[1] + expected = File.read(TESTS_PATH+"examples/pool/vdcpool_deleted.json") + + got = JSON.parser.new(got, {:symbolize_names => true}).parse + expected = JSON.parser.new(expected, {:symbolize_names => true}).parse + got.should eql(expected) end it "should fail on non-existing vdc deletion" do diff --git a/src/ozones/test/spec/ZoneManagement_spec.rb b/src/ozones/test/spec/ZoneManagement_spec.rb index 8826fef7c0..061aab2cf8 100644 --- a/src/ozones/test/spec/ZoneManagement_spec.rb +++ b/src/ozones/test/spec/ZoneManagement_spec.rb @@ -72,14 +72,25 @@ module OZones it "should be able to retrieve the zone pool" do zonepool = @helper.list_pool({:json => true}) zonepool[0].should eql(0) - zonepool[1].should eql(File.read(TESTS_PATH+ - "examples/pool/zonepool0.json")) + + got = zonepool[1] + expected = File.read(TESTS_PATH+"examples/pool/zonepool0.json") + + got = JSON.parser.new(got, {:symbolize_names => true}).parse + expected = JSON.parser.new(expected, {:symbolize_names => true}).parse + got.should eql(expected) end it "should be able to retrieve a particular zone" do zone = @helper.show_resource(1,{:json => true}) zone[0].should eql(0) - zone[1].should eql(File.read(TESTS_PATH+"examples/zone/zone0.json")) + + got = zone[1] + expected = File.read(TESTS_PATH+"examples/zone/zone0.json") + + got = JSON.parser.new(got, {:symbolize_names => true}).parse + expected = JSON.parser.new(expected, {:symbolize_names => true}).parse + got.should eql(expected) end it "should allow deleting a zone" do @@ -87,8 +98,13 @@ module OZones rc[0].should eql(0) rc = @helper.list_pool({:json => true}) rc[0].should eql(0) - rc[1].should eql(File.read(TESTS_PATH+ - "examples/pool/zonepool_deleted.json")) + + got = rc[1] + expected = File.read(TESTS_PATH+"examples/pool/zonepool_deleted.json") + + got = JSON.parser.new(got, {:symbolize_names => true}).parse + expected = JSON.parser.new(expected, {:symbolize_names => true}).parse + got.should eql(expected) end it "should fail on non existing zone deletion" do From 7c6e890bdef2b6c94a26d1d00a84625a4e50ad11 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 4 May 2012 14:52:57 +0200 Subject: [PATCH 06/11] Feature #1229: :server: is now :host: in occi server configuration (cherry picked from commit f437bd461fbf6b9ffc972737c50c603b52d0ec98) --- src/cloud/occi/etc/occi-server.conf | 2 +- src/cloud/occi/lib/occi-server.rb | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/cloud/occi/etc/occi-server.conf b/src/cloud/occi/etc/occi-server.conf index 16f0f6ea6c..f041e6d83e 100644 --- a/src/cloud/occi/etc/occi-server.conf +++ b/src/cloud/occi/etc/occi-server.conf @@ -22,7 +22,7 @@ :one_xmlrpc: http://localhost:2633/RPC2 # Host and port where OCCI server will run -:server: localhost +:host: 127.0.0.1 :port: 4567 # SSL proxy that serves the API (set if is being used) diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb index 851d58dc5c..183ef31c88 100644 --- a/src/cloud/occi/lib/occi-server.rb +++ b/src/cloud/occi/lib/occi-server.rb @@ -89,7 +89,7 @@ enable_logging OCCI_LOG, settings.config[:debug_level].to_i # Set Sinatra configuration use Rack::Session::Pool, :key => 'occi' -set :public, Proc.new { File.join(root, "ui/public") } +set :public_folder, Proc.new { File.join(root, "ui/public") } set :views, settings.root + '/ui/views' if CloudServer.is_port_open?(settings.config[:server], @@ -101,10 +101,20 @@ if CloudServer.is_port_open?(settings.config[:server], exit -1 end -set :bind, settings.config[:server] +host = settings.config[:host] || settings.config[:server] +set :bind, host + +if settings.config[:server] + warning = "Warning: :server: configuration parameter has been deprecated." + warning << " Use :host: instead." + settings.logger.error warning +end + set :port, settings.config[:port] + + # Create CloudAuth begin ENV["ONE_CIPHER_AUTH"] = OCCI_AUTH From 1216fade3f00965ad767b96ecd51d6671d7e7840 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 4 May 2012 17:44:24 +0200 Subject: [PATCH 07/11] feature #1262: manual distro selection if it cannot be detected --- share/install_gems/install_gems | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index 6ef8e1a65f..57671cced8 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -92,6 +92,45 @@ def good_gem_version? version>=Gem::Version.new('1.3.6') end +def select_distribution + items=[] + counter=0 + + puts(<<-EOT.unindent(8)) + Select your distribution or press enter to continue without + installing dependencies. + +EOT + + DISTRIBUTIONS.each do |name, dist| + names=dist[:id].map do |r| + if Regexp===r + r.source.gsub(/[^\w\d]/, '') + else + r + end + end.join('/') + text="#{items.length}. #{names}" + + items << name + + puts text + end + + puts + + options=(0..items.length).to_a.map {|k| k.to_s } + + option=STDIN.readline[0,1] + + if options.include?(option) + item=items[option.to_i] + [item, DISTRIBUTIONS[items[option.to_i]]] + else + nil + end +end + def install_rubygems if !good_gem_version? puts(<<-EOT.unindent()) @@ -288,6 +327,9 @@ def install_gems(packages) end dist=detect_distro + if !dist + dist=select_distribution + end install_dependencies(gems_list, dist) From 7cea1aeb5abb0bc4cab64f08aac84176aa5b2b28 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo Date: Mon, 23 Jan 2012 16:05:01 +0100 Subject: [PATCH 08/11] Adding status command to be LSB compliant --- share/etc/init.d/one.debian | 5 ++++- share/etc/init.d/one.ubuntu | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/share/etc/init.d/one.debian b/share/etc/init.d/one.debian index 7b75fffcaf..2d98d6ceb8 100755 --- a/share/etc/init.d/one.debian +++ b/share/etc/init.d/one.debian @@ -64,6 +64,9 @@ case "$1" in 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; + status) + status_of_proc "oned" "$NAME" && exit 0 || exit $? + ;; restart|force-reload) # # If the "reload" option is implemented then remove the @@ -87,7 +90,7 @@ case "$1" in esac ;; *) - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 exit 3 ;; esac diff --git a/share/etc/init.d/one.ubuntu b/share/etc/init.d/one.ubuntu index 7b75fffcaf..2d98d6ceb8 100755 --- a/share/etc/init.d/one.ubuntu +++ b/share/etc/init.d/one.ubuntu @@ -64,6 +64,9 @@ case "$1" in 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; + status) + status_of_proc "oned" "$NAME" && exit 0 || exit $? + ;; restart|force-reload) # # If the "reload" option is implemented then remove the @@ -87,7 +90,7 @@ case "$1" in esac ;; *) - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 exit 3 ;; esac From 021cfd6fcd6f3cad32327d4a31c6d9788a6f859b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 5 May 2012 03:23:37 +0200 Subject: [PATCH 09/11] feature #1243: Fix compilation warning --- src/dm/DispatchManagerActions.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index f573c3218d..dc3e702bad 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -602,9 +602,6 @@ int DispatchManager::resched(int vid, bool do_resched) if (vm->get_state() == VirtualMachine::ACTIVE && vm->get_lcm_state() == VirtualMachine::RUNNING ) { - Nebula& nd = Nebula::instance(); - LifeCycleManager * lcm = nd.get_lcm(); - vm->set_resched(do_resched); vmpool->update(vm); } From 70677e81b74048931c4e87d3f5de5a19d0d3f6d4 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 7 May 2012 15:24:05 +0200 Subject: [PATCH 10/11] bug #1151: added switch to destroy kvm VMs with ACPI enabled Based on the patch provided by "jan horacek" http://dev.opennebula.org/issues/1151 --- src/vmm_mad/remotes/kvm/kvmrc | 4 ++++ src/vmm_mad/remotes/kvm/shutdown | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/kvm/kvmrc b/src/vmm_mad/remotes/kvm/kvmrc index 8f36a9b9a0..99a66095df 100644 --- a/src/vmm_mad/remotes/kvm/kvmrc +++ b/src/vmm_mad/remotes/kvm/kvmrc @@ -26,3 +26,7 @@ export SHUTDOWN_TIMEOUT=300 # Uncomment this line to force VM cancellation after shutdown timeout #export FORCE_DESTROY=yes +# Uncomment this line to force VM's without ACPI enabled to be destroyed +# on shutdown +#CANCEL_NO_ACPI=yes + diff --git a/src/vmm_mad/remotes/kvm/shutdown b/src/vmm_mad/remotes/kvm/shutdown index 2e6b1099c3..8fbfebd63f 100755 --- a/src/vmm_mad/remotes/kvm/shutdown +++ b/src/vmm_mad/remotes/kvm/shutdown @@ -23,6 +23,16 @@ count=0 deploy_id=$1 +shutdown_command="virsh --connect $LIBVIRT_URI shutdown $deploy_id" + +if [ "x$CANCEL_NO_ACPI" = "xyes" ]; then + virsh --connect $LIBVIRT_URI dumpxml $deploy_id | grep -q acpi + + if [ "x$?" != "x0" ]; then + virsh --connect $LIBVIRT_URI destroy $deploy_id + fi +fi + if [ -z "$SHUTDOWN_TIMEOUT" ]; then TIMEOUT=120 else @@ -36,7 +46,7 @@ function monitor # Issue another shutdown to cover occasional libvirt lack of attention if [ "$count" -eq "$HALF_LOOP" ] then - virsh --connect $LIBVIRT_URI shutdown $deploy_id + $($shutdown_command) fi let count=count+1 @@ -48,7 +58,7 @@ function monitor [ "x$?" != "x0" ] } -exec_and_log "virsh --connect $LIBVIRT_URI shutdown $deploy_id" \ +exec_and_log "$shutdown_command" \ "Could not shutdown $deploy_id" retry $TIMEOUT monitor From b12d9573260c50aa7da2aa2fd0be9ac8bdaa58d9 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 7 May 2012 17:03:33 +0200 Subject: [PATCH 11/11] bug #1151: Work on 1151 bug --- src/vmm_mad/remotes/kvm/shutdown | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/kvm/shutdown b/src/vmm_mad/remotes/kvm/shutdown index 8fbfebd63f..e3ccfbc628 100755 --- a/src/vmm_mad/remotes/kvm/shutdown +++ b/src/vmm_mad/remotes/kvm/shutdown @@ -25,11 +25,12 @@ deploy_id=$1 shutdown_command="virsh --connect $LIBVIRT_URI shutdown $deploy_id" +#If VM does not have ACPI enabled do not try to use it, destroy instead shutdown if [ "x$CANCEL_NO_ACPI" = "xyes" ]; then virsh --connect $LIBVIRT_URI dumpxml $deploy_id | grep -q acpi if [ "x$?" != "x0" ]; then - virsh --connect $LIBVIRT_URI destroy $deploy_id + shutdown_command="virsh --connect $LIBVIRT_URI destroy $deploy_id" fi fi @@ -46,7 +47,7 @@ function monitor # Issue another shutdown to cover occasional libvirt lack of attention if [ "$count" -eq "$HALF_LOOP" ] then - $($shutdown_command) + eval $shutdown_command fi let count=count+1