From be3d1fedf9f8c778fd03ace86c5178f295ed7846 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 19 Jan 2012 12:36:41 +0100 Subject: [PATCH 01/20] feature #985: Add path support for EC2 signature --- src/cloud/common/CloudAuth/EC2CloudAuth.rb | 5 ++++- src/cloud/ec2/lib/EC2QueryClient.rb | 3 ++- src/cloud/ec2/lib/econe-server.rb | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/cloud/common/CloudAuth/EC2CloudAuth.rb b/src/cloud/common/CloudAuth/EC2CloudAuth.rb index 639743597f..38afacd64f 100644 --- a/src/cloud/common/CloudAuth/EC2CloudAuth.rb +++ b/src/cloud/common/CloudAuth/EC2CloudAuth.rb @@ -44,6 +44,7 @@ module EC2CloudAuth params.delete('Signature') params.delete('econe_host') params.delete('econe_port') + params.delete('econe_path') req_desc = params.sort {|x,y| x[0].downcase <=> y[0].downcase}.to_s digest_generator = OpenSSL::Digest::Digest.new(digest) @@ -59,6 +60,7 @@ module EC2CloudAuth server_host = params.delete('econe_host') server_port = params.delete('econe_port') + server_path = params.delete('econe_path') || '/' if include_port server_str = "#{server_host}:#{server_port}" else @@ -68,7 +70,8 @@ module EC2CloudAuth canonical_str = AWS.canonical_string( params, server_str, - env['REQUEST_METHOD']) + env['REQUEST_METHOD'], + server_path) # Use the correct signature strength sha_strength = case params['SignatureMethod'] diff --git a/src/cloud/ec2/lib/EC2QueryClient.rb b/src/cloud/ec2/lib/EC2QueryClient.rb index eb1ae27776..96a0da7d6f 100644 --- a/src/cloud/ec2/lib/EC2QueryClient.rb +++ b/src/cloud/ec2/lib/EC2QueryClient.rb @@ -76,7 +76,8 @@ module EC2QueryClient :secret_access_key => @access_key_secret, :server => @uri.host, :port => @uri.port, - :use_ssl => @uri.scheme == 'https') + :use_ssl => @uri.scheme == 'https', + :path => @uri.path) end diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index 4647114203..293446ae1d 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -44,6 +44,7 @@ $: << RUBY_LIB_LOCATION+"/cloud/econe" require 'rubygems' require 'sinatra' require 'yaml' +require 'uri' require 'EC2QueryServer' require 'CloudAuth' @@ -89,12 +90,21 @@ end set :cloud_auth, cloud_auth -econe_host = conf[:ssl_server] -econe_host ||= conf[:server] -econe_port = conf[:port] +if conf +if conf[:ssl_server] + uri = URI.parse(conf[:ssl_server]) + econe_host = uri.host + econe_port = uri.port + econe_path = uri.path +else + econe_host = conf[:server] + econe_port = conf[:port] + econe_path = '/' +end set :econe_host, econe_host set :econe_port, econe_port +set :econe_path, econe_path ############################################################################## # Actions @@ -104,6 +114,7 @@ before do begin params['econe_host'] = settings.econe_host params['econe_port'] = settings.econe_port + params['econe_path'] = settings.econe_path username = settings.cloud_auth.auth(request.env, params) rescue Exception => e error 500, error_xml("AuthFailure", 0) From 0323a1511ff4268eadd903554c34c4d385b0efb6 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 19 Jan 2012 15:49:17 +0100 Subject: [PATCH 02/20] feature #985: Fix minor bug --- src/cloud/ec2/lib/econe-server.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index 293446ae1d..0a8ccc1d98 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -90,7 +90,6 @@ end set :cloud_auth, cloud_auth -if conf if conf[:ssl_server] uri = URI.parse(conf[:ssl_server]) econe_host = uri.host From 404b34c98ab1f404a1874d53a5f7c2208f8f58d4 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 26 Jan 2012 11:28:07 +0100 Subject: [PATCH 03/20] bug #1087: More work on the cache (cherry picked from commit f05942f6e4b3658ccd3f17226514b2f97683d4c0) --- src/pool/PoolSQL.cc | 6 +++++- src/rm/RequestManagerChown.cc | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pool/PoolSQL.cc b/src/pool/PoolSQL.cc index f763dd2b38..0d167e2d4f 100644 --- a/src/pool/PoolSQL.cc +++ b/src/pool/PoolSQL.cc @@ -356,7 +356,11 @@ void PoolSQL::update_cache_index(string& old_name, if ( index != name_pool.end() ) { name_pool.erase(old_key); - name_pool.insert(make_pair(new_key, index->second)); + + if ( name_pool.find(new_key) == name_pool.end()) + { + name_pool.insert(make_pair(new_key, index->second)); + } } unlock(); diff --git a/src/rm/RequestManagerChown.cc b/src/rm/RequestManagerChown.cc index e1563dfd83..4ecbf9ee48 100644 --- a/src/rm/RequestManagerChown.cc +++ b/src/rm/RequestManagerChown.cc @@ -69,6 +69,9 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList, PoolObjectSQL * object; + string obj_name; + int old_uid; + // ------------- Check new user and group id's --------------------- if ( noid > -1 ) @@ -138,12 +141,11 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList, if ( noid != -1 ) { - string obj_name = object->get_name(); - int old_uid = object->get_uid(); + obj_name = object->get_name(); + old_uid = object->get_uid(); object->set_user(noid,nuname); - pool->update_cache_index(obj_name, old_uid, obj_name, noid); } if ( ngid != -1 ) @@ -155,6 +157,11 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList, object->unlock(); + if ( noid != -1 ) + { + pool->update_cache_index(obj_name, old_uid, obj_name, noid); + } + success_response(oid, att); return; From 48efe0bf4c16a4bdb3c7077882c78306d7999577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 25 Jan 2012 09:45:28 -0800 Subject: [PATCH 04/20] Create new onedb migrator for 3.2.1 (cherry picked from commit 81aae224217294a7a1dfa4869c423b8a3d04d66d) --- install.sh | 1 + src/onedb/3.2.0_to_3.2.1.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/onedb/3.2.0_to_3.2.1.rb diff --git a/install.sh b/install.sh index fb6452dba2..4dcf332d88 100755 --- a/install.sh +++ b/install.sh @@ -817,6 +817,7 @@ ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.rb \ src/onedb/3.0.0_to_3.1.0.rb \ src/onedb/3.1.0_to_3.1.80.rb \ src/onedb/3.1.80_to_3.2.0.rb \ + src/onedb/3.2.0_to_3.2.1.rb \ src/onedb/onedb.rb \ src/onedb/onedb_backend.rb" diff --git a/src/onedb/3.2.0_to_3.2.1.rb b/src/onedb/3.2.0_to_3.2.1.rb new file mode 100644 index 0000000000..2ae7cca937 --- /dev/null +++ b/src/onedb/3.2.0_to_3.2.1.rb @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- * +# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # +# Licensed under the Apache License, Version 2.0 (the "License"); you may * +# not use this file except in compliance with the License. You may obtain * +# a copy of the License at * +# * +# http://www.apache.org/licenses/LICENSE-2.0 * +# * +# Unless required by applicable law or agreed to in writing, software * +# distributed under the License is distributed on an "AS IS" BASIS, * +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +# See the License for the specific language governing permissions and * +# limitations under the License. * +# -------------------------------------------------------------------------- * + +module Migrator + def db_version + "3.2.1" + end + + def one_version + "OpenNebula 3.2.1" + end + + def up + return true + end +end From dc4ac8ca95c6a6219c2176516db6db59ca1fc889 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 26 Jan 2012 16:29:34 +0100 Subject: [PATCH 05/20] Links now point always to latest versiony --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec8ae4d0b1..1e3841533a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ distributed data center infrastructures. Complete documentation can be found at - http://opennebula.org/documentation:rel3.0 + http://opennebula.org/documentation:documentation ## INSTALLATION @@ -42,7 +42,7 @@ include a handy script to install them and the requirements. It is located at `share/install_gems/install_gems` and you should use it to install the required gems. You have more information at: - http://opennebula.org/documentation:rel3.0:compile + http://opennebula.org/documentation:documentation:compile ### OPTIONAL PACKAGES @@ -122,7 +122,7 @@ where **install_options** can be one or more of: ## CONFIGURATION Information on how to configure OpenNebula is located at -http://opennebula.org/documentation:rel3.0:cg +http://opennebula.org/documentation:documentation:cg ## CONTACT From 01e024892998fdb5c9ada65fcd85267436c9782c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 26 Jan 2012 16:50:33 +0100 Subject: [PATCH 06/20] Bug #1086: Core tests for cache bug (cherry picked from commit 7a5b42b184b8017ebe66e2cdbfb4920a41172ab0) --- src/group/test/GroupPoolTest.cc | 65 +++++++++++++++++++++ src/host/test/HostPoolTest.cc | 65 +++++++++++++++++++++ src/image/test/ImagePoolTest.cc | 64 +++++++++++++++++++++ src/um/test/UserPoolTest.cc | 62 ++++++++++++++++++++ src/vm_template/test/VMTemplatePoolTest.cc | 66 +++++++++++++++++++++ src/vnm/test/VirtualNetworkPoolTest.cc | 67 ++++++++++++++++++++++ 6 files changed, 389 insertions(+) diff --git a/src/group/test/GroupPoolTest.cc b/src/group/test/GroupPoolTest.cc index 2624bb4a73..a96a1c7d56 100644 --- a/src/group/test/GroupPoolTest.cc +++ b/src/group/test/GroupPoolTest.cc @@ -67,6 +67,8 @@ class GroupPoolTest : public PoolTest CPPUNIT_TEST (duplicates); CPPUNIT_TEST (dump); + CPPUNIT_TEST (name_index); + CPPUNIT_TEST_SUITE_END (); protected: @@ -222,6 +224,69 @@ public: CPPUNIT_ASSERT( oss.str() == group_xml_dump ); } + + /* ********************************************************************* */ + + void name_index() + { + Group *group_oid, *group_name; + int oid_0; + int uid_0; + string name_0; + + oid_0 = allocate(0); + + CPPUNIT_ASSERT(oid_0 != -1); + + // --------------------------------- + // Get by oid + group_oid = gpool->get(oid_0, true); + CPPUNIT_ASSERT(group_oid != 0); + + name_0 = group_oid->get_name(); + uid_0 = group_oid->get_uid(); + + group_oid->unlock(); + + // Get by name and check it is the same object + group_name = gpool->get(name_0, true); + CPPUNIT_ASSERT(group_name != 0); + group_name->unlock(); + + CPPUNIT_ASSERT(group_oid == group_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + gpool->clean(); + + // Get by oid + group_oid = gpool->get(oid_0, true); + CPPUNIT_ASSERT(group_oid != 0); + group_oid->unlock(); + + // Get by name and check it is the same object + group_name = gpool->get(name_0, true); + CPPUNIT_ASSERT(group_name != 0); + group_name->unlock(); + + CPPUNIT_ASSERT(group_oid == group_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + gpool->clean(); + + // Get by name + group_name = gpool->get(name_0, true); + CPPUNIT_ASSERT(group_name != 0); + group_name->unlock(); + + // Get by oid and check it is the same object + group_oid = gpool->get(oid_0, true); + CPPUNIT_ASSERT(group_oid != 0); + group_oid->unlock(); + + CPPUNIT_ASSERT(group_oid == group_name); + } }; /* ************************************************************************* */ diff --git a/src/host/test/HostPoolTest.cc b/src/host/test/HostPoolTest.cc index 044d154d63..dbc4a0b419 100644 --- a/src/host/test/HostPoolTest.cc +++ b/src/host/test/HostPoolTest.cc @@ -139,6 +139,7 @@ class HostPoolTest : public PoolTest CPPUNIT_TEST (discover); CPPUNIT_TEST (duplicates); CPPUNIT_TEST (update_info); + CPPUNIT_TEST (name_index); // CPPUNIT_TEST (scale_test); @@ -492,6 +493,70 @@ public: CPPUNIT_ASSERT( host != 0 ); CPPUNIT_ASSERT( host->to_xml(str) == host0_updated ); } + + /* ********************************************************************* */ + + void name_index() + { + HostPool * hp = static_cast(pool); + Host *host_oid, *host_name; + int oid_0; + int uid_0; + string name_0; + + oid_0 = allocate(0); + + CPPUNIT_ASSERT(oid_0 != -1); + + // --------------------------------- + // Get by oid + host_oid = hp->get(oid_0, true); + CPPUNIT_ASSERT(host_oid != 0); + + name_0 = host_oid->get_name(); + uid_0 = host_oid->get_uid(); + + host_oid->unlock(); + + // Get by name and check it is the same object + host_name = hp->get(name_0, true); + CPPUNIT_ASSERT(host_name != 0); + host_name->unlock(); + + CPPUNIT_ASSERT(host_oid == host_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + hp->clean(); + + // Get by oid + host_oid = hp->get(oid_0, true); + CPPUNIT_ASSERT(host_oid != 0); + host_oid->unlock(); + + // Get by name and check it is the same object + host_name = hp->get(name_0, true); + CPPUNIT_ASSERT(host_name != 0); + host_name->unlock(); + + CPPUNIT_ASSERT(host_oid == host_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + hp->clean(); + + // Get by name + host_name = hp->get(name_0, true); + CPPUNIT_ASSERT(host_name != 0); + host_name->unlock(); + + // Get by oid and check it is the same object + host_oid = hp->get(oid_0, true); + CPPUNIT_ASSERT(host_oid != 0); + host_oid->unlock(); + + CPPUNIT_ASSERT(host_oid == host_name); + } }; diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index feb835aea9..818454324b 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -150,6 +150,8 @@ class ImagePoolTest : public PoolTest CPPUNIT_TEST ( dump_where ); CPPUNIT_TEST ( get_using_name ); CPPUNIT_TEST ( wrong_get_name ); + CPPUNIT_TEST ( name_index ); + CPPUNIT_TEST_SUITE_END (); protected: @@ -962,6 +964,68 @@ public: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ + + void name_index() + { + Image *img_oid, *img_name; + int oid_0; + int uid_0; + string name_0; + + oid_0 = allocate(0); + + CPPUNIT_ASSERT(oid_0 != -1); + + + // --------------------------------- + // Get by oid + img_oid = ipool->get(oid_0, true); + CPPUNIT_ASSERT(img_oid != 0); + + name_0 = img_oid->get_name(); + uid_0 = img_oid->get_uid(); + + img_oid->unlock(); + + // Get by name and check it is the same object + img_name = ipool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(img_name != 0); + img_name->unlock(); + + CPPUNIT_ASSERT(img_oid == img_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + ipool->clean(); + + // Get by oid + img_oid = ipool->get(oid_0, true); + CPPUNIT_ASSERT(img_oid != 0); + img_oid->unlock(); + + // Get by name and check it is the same object + img_name = ipool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(img_name != 0); + img_name->unlock(); + + CPPUNIT_ASSERT(img_oid == img_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + ipool->clean(); + + // Get by name + img_name = ipool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(img_name != 0); + img_name->unlock(); + + // Get by oid and check it is the same object + img_oid = ipool->get(oid_0, true); + CPPUNIT_ASSERT(img_oid != 0); + img_oid->unlock(); + + CPPUNIT_ASSERT(img_oid == img_name); + } }; /* ************************************************************************* */ diff --git a/src/um/test/UserPoolTest.cc b/src/um/test/UserPoolTest.cc index 9ae1b6f78b..fd111fcd4a 100644 --- a/src/um/test/UserPoolTest.cc +++ b/src/um/test/UserPoolTest.cc @@ -77,6 +77,7 @@ class UserPoolTest : public PoolTest CPPUNIT_TEST (duplicates); //CPPUNIT_TEST (dump); CPPUNIT_TEST (dump_where); + CPPUNIT_TEST (name_index); CPPUNIT_TEST_SUITE_END (); @@ -374,6 +375,67 @@ public: CPPUNIT_ASSERT( oss.str() == dump_where_result ); } + + void name_index() + { + User *user_oid, *user_name; + int oid_0; + int uid_0; + string name_0; + + oid_0 = allocate(0); + + CPPUNIT_ASSERT(oid_0 != -1); + + // --------------------------------- + // Get by oid + user_oid = upool->get(oid_0, true); + CPPUNIT_ASSERT(user_oid != 0); + + name_0 = user_oid->get_name(); + uid_0 = user_oid->get_uid(); + + user_oid->unlock(); + + // Get by name and check it is the same object + user_name = upool->get(name_0, true); + CPPUNIT_ASSERT(user_name != 0); + user_name->unlock(); + + CPPUNIT_ASSERT(user_oid == user_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + upool->clean(); + + // Get by oid + user_oid = upool->get(oid_0, true); + CPPUNIT_ASSERT(user_oid != 0); + user_oid->unlock(); + + // Get by name and check it is the same object + user_name = upool->get(name_0, true); + CPPUNIT_ASSERT(user_name != 0); + user_name->unlock(); + + CPPUNIT_ASSERT(user_oid == user_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + upool->clean(); + + // Get by name + user_name = upool->get(name_0, true); + CPPUNIT_ASSERT(user_name != 0); + user_name->unlock(); + + // Get by oid and check it is the same object + user_oid = upool->get(oid_0, true); + CPPUNIT_ASSERT(user_oid != 0); + user_oid->unlock(); + + CPPUNIT_ASSERT(user_oid == user_name); + } }; /* ************************************************************************* */ diff --git a/src/vm_template/test/VMTemplatePoolTest.cc b/src/vm_template/test/VMTemplatePoolTest.cc index 5e5c074b9d..dc6febbd7b 100644 --- a/src/vm_template/test/VMTemplatePoolTest.cc +++ b/src/vm_template/test/VMTemplatePoolTest.cc @@ -110,6 +110,7 @@ class VMTemplatePoolTest : public PoolTest CPPUNIT_TEST ( duplicates ); CPPUNIT_TEST ( dump ); CPPUNIT_TEST ( dump_where ); + CPPUNIT_TEST ( name_index ); CPPUNIT_TEST_SUITE_END (); @@ -447,6 +448,71 @@ public: CPPUNIT_ASSERT( result == xml_dump_where ); } +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + void name_index() + { + VMTemplatePool *tpool = static_cast(pool); + VMTemplate *vnet_oid, *vnet_name; + int oid_0; + int uid_0; + string name_0; + + oid_0 = allocate(0); + + CPPUNIT_ASSERT(oid_0 != -1); + + + // --------------------------------- + // Get by oid + vnet_oid = tpool->get(oid_0, true); + CPPUNIT_ASSERT(vnet_oid != 0); + + name_0 = vnet_oid->get_name(); + uid_0 = vnet_oid->get_uid(); + + vnet_oid->unlock(); + + // Get by name and check it is the same object + vnet_name = tpool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(vnet_name != 0); + vnet_name->unlock(); + + CPPUNIT_ASSERT(vnet_oid == vnet_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + tpool->clean(); + + // Get by oid + vnet_oid = tpool->get(oid_0, true); + CPPUNIT_ASSERT(vnet_oid != 0); + vnet_oid->unlock(); + + // Get by name and check it is the same object + vnet_name = tpool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(vnet_name != 0); + vnet_name->unlock(); + + CPPUNIT_ASSERT(vnet_oid == vnet_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + tpool->clean(); + + // Get by name + vnet_name = tpool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(vnet_name != 0); + vnet_name->unlock(); + + // Get by oid and check it is the same object + vnet_oid = tpool->get(oid_0, true); + CPPUNIT_ASSERT(vnet_oid != 0); + vnet_oid->unlock(); + + CPPUNIT_ASSERT(vnet_oid == vnet_name); + } /* ********************************************************************* */ }; diff --git a/src/vnm/test/VirtualNetworkPoolTest.cc b/src/vnm/test/VirtualNetworkPoolTest.cc index a88378a321..7f5f97f83c 100644 --- a/src/vnm/test/VirtualNetworkPoolTest.cc +++ b/src/vnm/test/VirtualNetworkPoolTest.cc @@ -180,6 +180,8 @@ class VirtualNetworkPoolTest : public PoolTest CPPUNIT_TEST (range_definition); + CPPUNIT_TEST (name_index); + CPPUNIT_TEST_SUITE_END (); protected: @@ -1690,6 +1692,71 @@ public: vnpool->drop(vnet, err); } } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + void name_index() + { + VirtualNetwork *vnet_oid, *vnet_name; + int oid_0; + int uid_0; + string name_0; + + oid_0 = allocate(0); + + CPPUNIT_ASSERT(oid_0 != -1); + + + // --------------------------------- + // Get by oid + vnet_oid = vnpool->get(oid_0, true); + CPPUNIT_ASSERT(vnet_oid != 0); + + name_0 = vnet_oid->get_name(); + uid_0 = vnet_oid->get_uid(); + + vnet_oid->unlock(); + + // Get by name and check it is the same object + vnet_name = vnpool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(vnet_name != 0); + vnet_name->unlock(); + + CPPUNIT_ASSERT(vnet_oid == vnet_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + vnpool->clean(); + + // Get by oid + vnet_oid = vnpool->get(oid_0, true); + CPPUNIT_ASSERT(vnet_oid != 0); + vnet_oid->unlock(); + + // Get by name and check it is the same object + vnet_name = vnpool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(vnet_name != 0); + vnet_name->unlock(); + + CPPUNIT_ASSERT(vnet_oid == vnet_name); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + vnpool->clean(); + + // Get by name + vnet_name = vnpool->get(name_0, uid_0, true); + CPPUNIT_ASSERT(vnet_name != 0); + vnet_name->unlock(); + + // Get by oid and check it is the same object + vnet_oid = vnpool->get(oid_0, true); + CPPUNIT_ASSERT(vnet_oid != 0); + vnet_oid->unlock(); + + CPPUNIT_ASSERT(vnet_oid == vnet_name); + } }; /* ************************************************************************* */ From 498f6aa2bacde85596fac295da81bd28a182f535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 26 Jan 2012 17:26:57 +0100 Subject: [PATCH 07/20] Fix core tests in master --- src/image/test/ImagePoolTest.cc | 106 ++------------------------ src/test/NebulaTest.cc | 8 +- src/vm/test/VirtualMachinePoolTest.cc | 11 ++- 3 files changed, 22 insertions(+), 103 deletions(-) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 818454324b..5e56e25485 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -87,13 +87,15 @@ public: class ImagePoolFriend : public ImagePool { public: - ImagePoolFriend(SqlDB * db, - const string& _default_type, - const string& _default_dev_prefix): + ImagePoolFriend(SqlDB * db, + const string& _default_type, + const string& _default_dev_prefix, + vector _restricted_attrs): ImagePool( db, _default_type, - _default_dev_prefix){}; + _default_dev_prefix, + _restricted_attrs){}; int allocate(const int& uid, const std::string& stemplate, int* oid) @@ -251,7 +253,8 @@ public: // Create a new pool, using the same DB. This new pool should read the // allocated images. - imp = new ImagePool(db,"OS", "hd"); + vector restricted_attrs; + imp = new ImagePool(db,"OS", "hd", restricted_attrs); img = imp->get(0, false); CPPUNIT_ASSERT( img != 0 ); @@ -654,99 +657,6 @@ public: delete disk; } -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* - void public_attribute() - { - int oid; - ImagePoolFriend * imp = static_cast(pool); - Image * img; - - string templates[] = - { - // false - "NAME = \"name A\"\n" - "PATH = \"/tmp/nothing\"\n", - - // true - "NAME = \"name B\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = YES", - - // false - "NAME = \"name C\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = NO", - - // false - "NAME = \"name D\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = 1", - - // true - "NAME = \"name E\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = Yes", - - // false - "NAME = \"name F\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = TRUE", - - // true - "NAME = \"name G\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = yes", - - // false - "NAME = \"name H\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = 'YES'", - - // true - "NAME = \"name I\"\n" - "PATH = \"/tmp/nothing\"\n" - "PUBLIC = \"YES\"", - - "END" - }; - - bool results[] = { false, true, false, false, - true, false, true, false, true }; - - int i = 0; - while( templates[i] != "END" ) - { - - imp->allocate(0, templates[i], &oid); - - CPPUNIT_ASSERT( oid >= 0 ); - - img = imp->get( oid, false ); - CPPUNIT_ASSERT( img != 0 ); -//cout << endl << i << " : exp. " << results[i] << " got " << img->is_public(); - - CPPUNIT_ASSERT( img->isPublic() == results[i] ); - - i++; - } - - int success; - - // img 0 is not public. - img = imp->get( 0, false ); - CPPUNIT_ASSERT( img != 0 ); - - success = img->publish(false); - CPPUNIT_ASSERT( success == 0 ); - CPPUNIT_ASSERT( img->isPublic() == false ); - - success = img->publish(true); - CPPUNIT_ASSERT( success == 0 ); - CPPUNIT_ASSERT( img->isPublic() == true ); - } -*/ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* diff --git a/src/test/NebulaTest.cc b/src/test/NebulaTest.cc index e3cf978463..eda496815d 100644 --- a/src/test/NebulaTest.cc +++ b/src/test/NebulaTest.cc @@ -22,7 +22,9 @@ VirtualMachinePool* NebulaTest::create_vmpool(SqlDB* db, string hook_location, string vloc) { vector hooks; - return new VirtualMachinePool(db, hooks, hook_location, vloc); + vector restricted_attrs; + + return new VirtualMachinePool(db, hooks, hook_location, vloc, restricted_attrs); } HostPool* NebulaTest::create_hpool(SqlDB* db, string hook_location, string vloc) @@ -45,7 +47,9 @@ ImagePool* NebulaTest::create_ipool( SqlDB* db, string default_image_type, string default_device_prefix) { - return new ImagePool(db,default_image_type,default_device_prefix); + vector restricted_attrs; + + return new ImagePool(db, default_image_type, default_device_prefix, restricted_attrs); } VMTemplatePool* NebulaTest::create_tpool(SqlDB* db) diff --git a/src/vm/test/VirtualMachinePoolTest.cc b/src/vm/test/VirtualMachinePoolTest.cc index ae6ecd8b1d..d74ecfbc3d 100644 --- a/src/vm/test/VirtualMachinePoolTest.cc +++ b/src/vm/test/VirtualMachinePoolTest.cc @@ -74,8 +74,11 @@ const string xml_history_dump = class VirtualMachinePoolFriend : public VirtualMachinePool { public: - VirtualMachinePoolFriend(SqlDB * db, vector hook_mads): - VirtualMachinePool(db, hook_mads, "./", "./") + VirtualMachinePoolFriend( + SqlDB * db, + vector hook_mads, + vector restricted_attrs): + VirtualMachinePool(db, hook_mads, "./", "./", restricted_attrs) {}; @@ -138,7 +141,9 @@ protected: { // The VM pool needs a vector containing the vm hooks vector vm_hooks; - return new VirtualMachinePoolFriend(db, vm_hooks); + vector restricted_attrs; + + return new VirtualMachinePoolFriend(db, vm_hooks, restricted_attrs); }; int allocate(int index) From a0d0bd1dbbca38be23624fd0fc18c9f3ac594705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 26 Jan 2012 17:47:13 +0100 Subject: [PATCH 08/20] Fix ImagePoolTest::persistence test --- src/image/test/ImagePoolTest.cc | 37 +++++++++++---------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 5e56e25485..8015f15cac 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -145,8 +145,7 @@ class ImagePoolTest : public PoolTest CPPUNIT_TEST ( wrong_templates ); CPPUNIT_TEST ( target_generation ); CPPUNIT_TEST ( bus_source_assignment ); -// CPPUNIT_TEST ( public_attribute ); -// CPPUNIT_TEST ( persistence ); + CPPUNIT_TEST ( persistence ); CPPUNIT_TEST ( imagepool_disk_attribute ); CPPUNIT_TEST ( dump ); CPPUNIT_TEST ( dump_where ); @@ -659,7 +658,7 @@ public: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -/* + void persistence() { int oid; @@ -672,44 +671,32 @@ public: { "NAME = \"Image 1\"\n" "PERSISTENT = NO\n" - "PUBLIC = NO\n" "PATH = /dev/null\n", "NAME = \"Image 2\"\n" "PERSISTENT = NO\n" - "PUBLIC = YES\n" "PATH = /dev/null\n", "NAME = \"Image 3\"\n" "PERSISTENT = YES\n" - "PUBLIC = NO\n" - "PATH = /dev/null\n", - - "NAME = \"Image 4\"\n" - "PERSISTENT = YES\n" - "PUBLIC = YES\n" "PATH = /dev/null\n", "END" }; - bool results[] = { true, true, true, false }; bool persistent[] = { false, false, true }; int i = 0; while( templates[i] != "END" ) { imp->allocate(0, templates[i], &oid); -//cout << endl << i << " : exp. " << results[i] << " got " << (oid >= 0); - CPPUNIT_ASSERT( (oid >= 0) == results[i] ); - if( oid >= 0 ) - { - img = imp->get( oid, false ); - CPPUNIT_ASSERT( img != 0 ); + CPPUNIT_ASSERT( oid >= 0 ); - CPPUNIT_ASSERT( img->isPersistent() == persistent[i] ); - } + img = imp->get( oid, false ); + CPPUNIT_ASSERT( img != 0 ); + + CPPUNIT_ASSERT( img->isPersistent() == persistent[i] ); i++; } @@ -724,12 +711,12 @@ public: CPPUNIT_ASSERT( img->isPersistent() == true ); // it isn't public, try to unpublish - success = img->publish(false); + success = img->set_permissions(1,1,0, 0,0,0, 0,0,0, error_msg); CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPublic() == false ); // try to publish, should fail because it is persistent - success = img->publish(true); + success = img->set_permissions(1,1,0, 1,0,0, 0,0,0, error_msg); CPPUNIT_ASSERT( success == -1 ); CPPUNIT_ASSERT( img->isPublic() == false ); @@ -740,16 +727,16 @@ public: CPPUNIT_ASSERT( img->isPersistent() == false ); // it isn't public, try to unpublish - success = img->publish(false); + success = img->set_permissions(1,1,0, 0,0,0, 0,0,0, error_msg); CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPublic() == false ); // try to publish, now it should be possible - success = img->publish(true); + success = img->set_permissions(1,1,0, 1,0,0, 0,0,0, error_msg); CPPUNIT_ASSERT( success == 0 ); CPPUNIT_ASSERT( img->isPublic() == true ); } -*/ + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ From 03e9b52c559ed5bc7083ab81101feb3e837bb081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 26 Jan 2012 19:00:55 +0100 Subject: [PATCH 09/20] Bug #1087: Core tests (cherry picked from commit f10e852fe4c693c069026475e36ecd16b6b32d2a) --- src/image/test/ImagePoolTest.cc | 65 +++++++++++++++++++++ src/vm_template/test/VMTemplatePoolTest.cc | 67 ++++++++++++++++++++++ src/vnm/test/VirtualNetworkPoolTest.cc | 65 +++++++++++++++++++++ 3 files changed, 197 insertions(+) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 8015f15cac..8427243e70 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -152,6 +152,7 @@ class ImagePoolTest : public PoolTest CPPUNIT_TEST ( get_using_name ); CPPUNIT_TEST ( wrong_get_name ); CPPUNIT_TEST ( name_index ); + CPPUNIT_TEST ( chown_name_index ); CPPUNIT_TEST_SUITE_END (); @@ -921,6 +922,70 @@ public: CPPUNIT_ASSERT(img_oid != 0); img_oid->unlock(); + CPPUNIT_ASSERT(img_oid == img_name); + } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + void chown_name_index() + { + Image *img_oid, *img_name; + int oid; + int old_uid; + int new_uid = 3456; + string name; + + oid = allocate(0); + + CPPUNIT_ASSERT(oid != -1); + + + // --------------------------------- + // Get by oid + img_oid = ipool->get(oid, true); + CPPUNIT_ASSERT(img_oid != 0); + + name = img_oid->get_name(); + old_uid = img_oid->get_uid(); + + // Change owner and update cache index + img_oid->set_user(new_uid, "new_username"); + ipool->update(img_oid); + img_oid->unlock(); + + ipool->update_cache_index(name, old_uid, name, new_uid); + + // Get by name, new_uid and check it is the same object + img_name = ipool->get(name, new_uid, true); + CPPUNIT_ASSERT(img_name != 0); + img_name->unlock(); + + CPPUNIT_ASSERT(img_oid == img_name); + + // Get by name, old_uid and check it does not exist + img_name = ipool->get(name, old_uid, true); + CPPUNIT_ASSERT(img_name == 0); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + ipool->clean(); + + + // Get by name, old_uid and check it does not exist + img_name = ipool->get(name, old_uid, true); + CPPUNIT_ASSERT(img_name == 0); + + // Get by oid + img_oid = ipool->get(oid, true); + CPPUNIT_ASSERT(img_oid != 0); + img_oid->unlock(); + + // Get by name, new_uid and check it is the same object + img_name = ipool->get(name, new_uid, true); + CPPUNIT_ASSERT(img_name != 0); + img_name->unlock(); + CPPUNIT_ASSERT(img_oid == img_name); } }; diff --git a/src/vm_template/test/VMTemplatePoolTest.cc b/src/vm_template/test/VMTemplatePoolTest.cc index dc6febbd7b..e3c0259d8d 100644 --- a/src/vm_template/test/VMTemplatePoolTest.cc +++ b/src/vm_template/test/VMTemplatePoolTest.cc @@ -111,6 +111,7 @@ class VMTemplatePoolTest : public PoolTest CPPUNIT_TEST ( dump ); CPPUNIT_TEST ( dump_where ); CPPUNIT_TEST ( name_index ); + CPPUNIT_TEST ( chown_name_index ); CPPUNIT_TEST_SUITE_END (); @@ -513,6 +514,72 @@ public: CPPUNIT_ASSERT(vnet_oid == vnet_name); } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + void chown_name_index() + { + VMTemplatePool *tpool = static_cast(pool); + VMTemplate *obj_oid, *obj_name; + int oid; + int old_uid; + int new_uid = 3456; + string name; + + oid = allocate(0); + + CPPUNIT_ASSERT(oid != -1); + + + // --------------------------------- + // Get by oid + obj_oid = tpool->get(oid, true); + CPPUNIT_ASSERT(obj_oid != 0); + + name = obj_oid->get_name(); + old_uid = obj_oid->get_uid(); + + // Change owner and update cache index + obj_oid->set_user(new_uid, "new_username"); + tpool->update(obj_oid); + obj_oid->unlock(); + + tpool->update_cache_index(name, old_uid, name, new_uid); + + // Get by name, new_uid and check it is the same object + obj_name = tpool->get(name, new_uid, true); + CPPUNIT_ASSERT(obj_name != 0); + obj_name->unlock(); + + CPPUNIT_ASSERT(obj_oid == obj_name); + + // Get by name, old_uid and check it does not exist + obj_name = tpool->get(name, old_uid, true); + CPPUNIT_ASSERT(obj_name == 0); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + tpool->clean(); + + + // Get by name, old_uid and check it does not exist + obj_name = tpool->get(name, old_uid, true); + CPPUNIT_ASSERT(obj_name == 0); + + // Get by oid + obj_oid = tpool->get(oid, true); + CPPUNIT_ASSERT(obj_oid != 0); + obj_oid->unlock(); + + // Get by name, new_uid and check it is the same object + obj_name = tpool->get(name, new_uid, true); + CPPUNIT_ASSERT(obj_name != 0); + obj_name->unlock(); + + CPPUNIT_ASSERT(obj_oid == obj_name); + } + /* ********************************************************************* */ }; diff --git a/src/vnm/test/VirtualNetworkPoolTest.cc b/src/vnm/test/VirtualNetworkPoolTest.cc index 7f5f97f83c..5e57f71373 100644 --- a/src/vnm/test/VirtualNetworkPoolTest.cc +++ b/src/vnm/test/VirtualNetworkPoolTest.cc @@ -181,6 +181,7 @@ class VirtualNetworkPoolTest : public PoolTest CPPUNIT_TEST (range_definition); CPPUNIT_TEST (name_index); + CPPUNIT_TEST (chown_name_index); CPPUNIT_TEST_SUITE_END (); @@ -1755,6 +1756,70 @@ public: CPPUNIT_ASSERT(vnet_oid != 0); vnet_oid->unlock(); + CPPUNIT_ASSERT(vnet_oid == vnet_name); + } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + void chown_name_index() + { + VirtualNetwork *vnet_oid, *vnet_name; + int oid; + int old_uid; + int new_uid = 3456; + string name; + + oid = allocate(0); + + CPPUNIT_ASSERT(oid != -1); + + + // --------------------------------- + // Get by oid + vnet_oid = vnpool->get(oid, true); + CPPUNIT_ASSERT(vnet_oid != 0); + + name = vnet_oid->get_name(); + old_uid = vnet_oid->get_uid(); + + // Change owner and update cache index + vnet_oid->set_user(new_uid, "new_username"); + vnpool->update(vnet_oid); + vnet_oid->unlock(); + + vnpool->update_cache_index(name, old_uid, name, new_uid); + + // Get by name, new_uid and check it is the same object + vnet_name = vnpool->get(name, new_uid, true); + CPPUNIT_ASSERT(vnet_name != 0); + vnet_name->unlock(); + + CPPUNIT_ASSERT(vnet_oid == vnet_name); + + // Get by name, old_uid and check it does not exist + vnet_name = vnpool->get(name, old_uid, true); + CPPUNIT_ASSERT(vnet_name == 0); + + // --------------------------------- + // Clean the cache, forcing the pool to read the objects from the DB + vnpool->clean(); + + + // Get by name, old_uid and check it does not exist + vnet_name = vnpool->get(name, old_uid, true); + CPPUNIT_ASSERT(vnet_name == 0); + + // Get by oid + vnet_oid = vnpool->get(oid, true); + CPPUNIT_ASSERT(vnet_oid != 0); + vnet_oid->unlock(); + + // Get by name, new_uid and check it is the same object + vnet_name = vnpool->get(name, new_uid, true); + CPPUNIT_ASSERT(vnet_name != 0); + vnet_name->unlock(); + CPPUNIT_ASSERT(vnet_oid == vnet_name); } }; From bb3543720616affd1f076084a0b09f686967a4f0 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 30 Jan 2012 18:37:11 +0100 Subject: [PATCH 10/20] bug #1063: fix oneacct for systemwide installations (cherry picked from commit 00deb1e441791fabaa8e9f7cc990e51783c3f998) --- src/cli/oneacct | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cli/oneacct b/src/cli/oneacct index 065d2c09eb..ef32432d0a 100755 --- a/src/cli/oneacct +++ b/src/cli/oneacct @@ -22,10 +22,16 @@ # -------------------------------------------------------------------------- -ONE_LOCATION=ENV['ONE_LOCATION'] +ONE_LOCATION=ENV["ONE_LOCATION"] -$: << ONE_LOCATION+'/lib/ruby' -$: << ONE_LOCATION+'/lib/ruby/cli' +if !ONE_LOCATION + RUBY_LIB_LOCATION="/usr/lib/one/ruby" +else + RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" +end + +$: << RUBY_LIB_LOCATION +$: << RUBY_LIB_LOCATION+"/cli" require 'rubygems' From 309390a0f153da2d115a1d33b0991a80d1c18d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 30 Jan 2012 19:57:59 +0100 Subject: [PATCH 11/20] Bug #1097: free error message in PoolObjectSQL::replace_template (cherry picked from commit 85149f77d25a1bf1c22b469fa600a935bd31f77c) --- src/pool/PoolObjectSQL.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pool/PoolObjectSQL.cc b/src/pool/PoolObjectSQL.cc index f10ba658ce..ce25d74e9b 100644 --- a/src/pool/PoolObjectSQL.cc +++ b/src/pool/PoolObjectSQL.cc @@ -183,6 +183,8 @@ int PoolObjectSQL::replace_template(const string& tmpl_str, string& error) if (error_msg != 0) { oss << ": " << error_msg; + + free(error_msg); } error = oss.str(); From eb0d5fb36c5c0bf1e6b94c5d4756e92cd5d775fa Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 6 Feb 2012 15:53:52 +0100 Subject: [PATCH 12/20] Bug #1084: Added auto answer to libvirt for ESX --- src/vmm_mad/remotes/vmware/vmwarerc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/vmware/vmwarerc b/src/vmm_mad/remotes/vmware/vmwarerc index 9baf506bfc..62d45822a4 100644 --- a/src/vmm_mad/remotes/vmware/vmwarerc +++ b/src/vmm_mad/remotes/vmware/vmwarerc @@ -14,8 +14,8 @@ # limitations under the License. # # ---------------------------------------------------------------------------- # -# Libvirt configuration -:libvirt_uri: "esx://@HOST@/?no_verify=1" +# Libvirt congfiguration +:libvirt_uri: "esx://@HOST@/?no_verify=1&auto_answer=1" # Username and password of the VMware hypervisor :username: "oneadmin" From 9cdfe8276412b10e5cb69a7622e7459a627cb636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Mon, 6 Feb 2012 11:59:07 -0600 Subject: [PATCH 13/20] Bug #1084: Fix for bad background process spawning --- src/vmm_mad/remotes/vmware/vmwarerc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/vmware/vmwarerc b/src/vmm_mad/remotes/vmware/vmwarerc index 62d45822a4..0cde6b3a09 100644 --- a/src/vmm_mad/remotes/vmware/vmwarerc +++ b/src/vmm_mad/remotes/vmware/vmwarerc @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- # # Libvirt congfiguration -:libvirt_uri: "esx://@HOST@/?no_verify=1&auto_answer=1" +:libvirt_uri: "'esx://@HOST@/?no_verify=1&auto_answer=1'" # Username and password of the VMware hypervisor :username: "oneadmin" @@ -23,4 +23,4 @@ # VMotion configuration attributes :datacenter: "ha-datacenter" -:vcenter: \ No newline at end of file +:vcenter: From cdb47d12c77de69625ad306f293f2b8556b25581 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 2 Feb 2012 10:22:34 +0100 Subject: [PATCH 14/20] Bug #1085: Increase cookie expiration time in web-UIs. Skewed clocks can cause that cookie does not work. Expiration time increased from 1 to 10 minutes, which is the same as the default duration of the session. (cherry picked from commit f9b9f1a0cd9b492239411d2150834e00291540b0) --- src/cloud/occi/lib/occi-server.rb | 2 +- src/ozones/Server/ozones-server.rb | 2 +- src/sunstone/sunstone-server.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb index 5eb9a97846..470ec9e19a 100755 --- a/src/cloud/occi/lib/occi-server.rb +++ b/src/cloud/occi/lib/occi-server.rb @@ -340,7 +340,7 @@ get '/ui' do return File.read(File.dirname(__FILE__)+'/ui/templates/login.html') end - time = Time.now + 60 + time = Time.now + 60*10 response.set_cookie("occi-user", :value=>"#{session[:user]}", :expires=>time) diff --git a/src/ozones/Server/ozones-server.rb b/src/ozones/Server/ozones-server.rb index e7cb7ab908..84dc77d9b7 100755 --- a/src/ozones/Server/ozones-server.rb +++ b/src/ozones/Server/ozones-server.rb @@ -192,7 +192,7 @@ get '/' do return File.read(File.dirname(__FILE__)+ '/templates/login.html') unless authorized? - time = Time.now + 60 + time = Time.now + 60*10 response.set_cookie("ozones-user", :value=>"#{session[:user]}", :expires=>time) diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 4f32a63433..2ece360837 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -169,7 +169,7 @@ get '/' do return File.read(File.dirname(__FILE__)+'/templates/'+templ) end - time = Time.now + 60 + time = Time.now + 60*10 response.set_cookie("one-user", :value=>"#{session[:user]}", :expires=>time) From ab79e3bb411c5ca58cb0b832f9be42518ea9246b Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 2 Feb 2012 11:02:54 +0100 Subject: [PATCH 15/20] feature #1030: add %i wildcard support to cli when instantiating multiple VMs. (cherry picked from commit 76506b57377bc5d8ed4a798ac0ada1d8aad7dcb6) --- src/cli/one_helper/onetemplate_helper.rb | 6 +++++- src/cli/onetemplate | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cli/one_helper/onetemplate_helper.rb b/src/cli/one_helper/onetemplate_helper.rb index 8b56fbe2c4..308d3a9193 100644 --- a/src/cli/one_helper/onetemplate_helper.rb +++ b/src/cli/one_helper/onetemplate_helper.rb @@ -22,7 +22,11 @@ class OneTemplateHelper < OpenNebulaHelper::OneHelper :short => "-n vm_name", :large => "--name vm_name", :format => String, - :description => "Name of the new Virtual Machine" + :description => <<-EOT +Name of the new Virtual Machine. When instantiating + multiple VMs you can use the\"%i\" wildcard to produce + different names such as vm-0, vm-1... +EOT } MULTIPLE={ diff --git a/src/cli/onetemplate b/src/cli/onetemplate index a75b4352b0..7a27e194fa 100755 --- a/src/cli/onetemplate +++ b/src/cli/onetemplate @@ -108,9 +108,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do exit_code=0 number = options[:multiple] || 1 - number.times do + number.times do |i| exit_code=helper.perform_action(args[0],options,"instantiated") do |t| - res = t.instantiate(options[:vm_name]) + name = options[:vm_name].gsub("%i",i.to_s) + res = t.instantiate(name) if !OpenNebula.is_error?(res) puts "VM ID: #{res}" From 99ba655813577f0227b9a9edd1e248057f18d2e7 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 25 Jan 2012 23:47:39 +0100 Subject: [PATCH 16/20] Feature #1030: Allow parametric values when creating several VMs in SelfService (cherry picked from commit 986c1282baaceeaf743e555a83d27283696e534b) --- .../occi/lib/ui/public/js/plugins/compute.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js index 5550566e49..993faf93ab 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js @@ -89,8 +89,11 @@ var create_vm_tmpl ='
\ \ \
\ - \ - \ +
\ + \ + \ +
'+tr("You can use the wildcard %i. When creating several VMs, %i will be replaced with a different number starting from 0 in each of them")+'.
\ +
\
\
\ \ @@ -686,6 +689,8 @@ function popUpCreateVMDialog(){ text: true }); + setupTips(dialog); + var net_select = makeSelectOptions(dataTable_vNetworks, 1,//id_col 2,//name_col @@ -772,17 +777,19 @@ function popUpCreateVMDialog(){ if (n_times.length){ n_times_int=parseInt(n_times,10); - } + }; - if (n_times_int>1){ - if (!vm_name.length){ - vm_name = $('#template_id option:selected',this).text(); - } + if (vm_name.indexOf("%i") == -1){ //no wildcard for (var i=0; i< n_times_int; i++){ Sunstone.runAction("VM.create",vm); }; - } else { - Sunstone.runAction("VM.create",vm); + } else { //wildcard present: replace wildcard + var name = ""; + for (var i=0; i< n_times_int; i++){ + name = vm_name.replace(/%i/gi,i); + vm["NAME"] = name; + Sunstone.runAction("VM.create",vm); + }; }; popUpVMDashboard(); From aa86d4c0d17ba0e9e4a6063f7ab367d07619ffa3 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 25 Jan 2012 23:46:58 +0100 Subject: [PATCH 17/20] Feature #1030: Allow parametric values when creating several VMs in Sunstone. (cherry picked from commit aafd0087c2a0e9a33832628e05d8601eb6ebafd2) --- src/sunstone/public/js/plugins/vms-tab.js | 36 +++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 43c71961be..fa69971dd6 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -75,13 +75,21 @@ var vms_tab_content = var create_vm_tmpl ='\
\
\ - \ -
\ - \ -
\ - \ - \ +
\ + \ + \ +
'+tr("Defaults to template name when emtpy")+'.
\ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
'+tr("You can use the wildcard %i. When creating several VMs, %i will be replaced with a different number starting from 0 in each of them")+'.
\ +
\
\
\
\ @@ -846,6 +854,7 @@ function setupCreateVMDialog(){ }); $('button',dialog).button(); + setupTips(dialog); $('#create_vm_form',dialog).submit(function(){ var vm_name = $('#vm_name',this).val(); @@ -866,8 +875,16 @@ function setupCreateVMDialog(){ vm_name = $('#template_id option:selected',this).text(); }; - for (var i=0; i< n_times_int; i++){ - Sunstone.runAction("Template.instantiate",template_id,vm_name); + if (vm_name.indexOf("%i") == -1){ //no wildcard + for (var i=0; i< n_times_int; i++){ + Sunstone.runAction("Template.instantiate",template_id,vm_name); + }; + } else { //wildcard present: replace wildcard + var name = ""; + for (var i=0; i< n_times_int; i++){ + name = vm_name.replace(/%i/gi,i); + Sunstone.runAction("Template.instantiate",template_id,name); + }; }; Sunstone.runAction("VM.list"); @@ -1285,6 +1302,7 @@ $(document).ready(function(){ setupSaveasDialog(); setVMAutorefresh(); setupVNC(); + setupTips initCheckAllBoxes(dataTable_vMachines); tableCheckboxesListener(dataTable_vMachines); From a0eedf34a94fa29b05d317f084df68599f4e0926 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 7 Feb 2012 18:25:42 +0100 Subject: [PATCH 18/20] Bug #1111: Improve constraints when creating a ranged virtual network. (cherry picked from commit 22b888e2ebadebbb8acd2149c2da3460f6f782bd) --- src/sunstone/public/js/plugins/vnets-tab.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index 66856161ce..87a153b4e9 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -822,8 +822,8 @@ function setupCreateVNetDialog() { var ip_start = $('#ip_start',this).val(); var ip_end = $('#ip_end',this).val(); - if (!network_addr.length){ - notifyError(tr("Please provide a network address")); + if (!(ip_start.length && ip_end.length) && !network_addr.length){ + notifyError(tr("There are missing network parameters")); return false; }; @@ -832,11 +832,15 @@ function setupCreateVNetDialog() { "vnet" : { "type" : "RANGED", "bridge" : bridge, - "network_mask" : network_mask, - "network_address" : network_addr, "name" : name } }; + if (network_addr.length) + network_json["vnet"]["network_address"]=network_addr; + + if (network_mask.length) + network_json["vnet"]["network_mask"]=network_mask; + if (custom){ if (ip_start.length) network_json["vnet"]["ip_start"] = ip_start; From ca24b854603a699be3e69a7f34cf6b1f65e7f872 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 7 Feb 2012 17:21:30 +0100 Subject: [PATCH 19/20] Bug #1110: Add VMware IM,TM and VMM drivers to Sunstone host creation dialog. (cherry picked from commit 7f485ad179311a3d30b7f366bc850692c697be1f) --- src/sunstone/public/js/plugins/hosts-tab.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 77db99cb93..bffa341124 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -67,6 +67,7 @@ var create_host_tmpl = \ @@ -76,6 +77,7 @@ var create_host_tmpl = \ @@ -95,6 +97,7 @@ var create_host_tmpl = \
\ From 0f1195e336c5474e51974961f472339784f2c1f9 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 7 Feb 2012 23:36:58 +0100 Subject: [PATCH 20/20] bug #1115: Remove error messages from templates before inserting new ones --- src/pool/PoolObjectSQL.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pool/PoolObjectSQL.cc b/src/pool/PoolObjectSQL.cc index ce25d74e9b..208687f42c 100644 --- a/src/pool/PoolObjectSQL.cc +++ b/src/pool/PoolObjectSQL.cc @@ -155,8 +155,11 @@ void PoolObjectSQL::set_template_error_message(const string& message) error_value.insert(make_pair("TIMESTAMP",str)); error_value.insert(make_pair("MESSAGE",message)); + //Replace previous error message and insert the new one + attr = new VectorAttribute(error_attribute_name,error_value); + obj_template->erase(error_attribute_name); obj_template->set(attr); }