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 diff --git a/install.sh b/install.sh index 6a38084d7e..9c10727ba6 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/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' 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..0a8ccc1d98 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,20 @@ end set :cloud_auth, cloud_auth -econe_host = conf[:ssl_server] -econe_host ||= conf[:server] -econe_port = conf[:port] +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 +113,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) 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..8427243e70 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) @@ -143,13 +145,15 @@ 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 ); CPPUNIT_TEST ( get_using_name ); CPPUNIT_TEST ( wrong_get_name ); + CPPUNIT_TEST ( name_index ); + CPPUNIT_TEST ( chown_name_index ); + CPPUNIT_TEST_SUITE_END (); protected: @@ -249,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,100 +659,7 @@ public: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -/* - 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 ); - } -*/ -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* void persistence() { int oid; @@ -760,44 +672,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++; } @@ -812,12 +712,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 ); @@ -828,16 +728,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 ); } -*/ + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -962,6 +862,132 @@ 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); + } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + 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/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 diff --git a/src/pool/PoolObjectSQL.cc b/src/pool/PoolObjectSQL.cc index f10ba658ce..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); } @@ -183,6 +186,8 @@ int PoolObjectSQL::replace_template(const string& tmpl_str, string& error) if (error_msg != 0) { oss << ": " << error_msg; + + free(error_msg); } error = oss.str(); 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; 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 = \ \ 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; 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/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/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) diff --git a/src/vm_template/test/VMTemplatePoolTest.cc b/src/vm_template/test/VMTemplatePoolTest.cc index 5e5c074b9d..e3c0259d8d 100644 --- a/src/vm_template/test/VMTemplatePoolTest.cc +++ b/src/vm_template/test/VMTemplatePoolTest.cc @@ -110,6 +110,8 @@ class VMTemplatePoolTest : public PoolTest CPPUNIT_TEST ( duplicates ); CPPUNIT_TEST ( dump ); CPPUNIT_TEST ( dump_where ); + CPPUNIT_TEST ( name_index ); + CPPUNIT_TEST ( chown_name_index ); CPPUNIT_TEST_SUITE_END (); @@ -447,6 +449,137 @@ 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); + } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + 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/vmm_mad/remotes/vmware/vmwarerc b/src/vmm_mad/remotes/vmware/vmwarerc index 9baf506bfc..0cde6b3a09 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" @@ -23,4 +23,4 @@ # VMotion configuration attributes :datacenter: "ha-datacenter" -:vcenter: \ No newline at end of file +:vcenter: diff --git a/src/vnm/test/VirtualNetworkPoolTest.cc b/src/vnm/test/VirtualNetworkPoolTest.cc index a88378a321..5e57f71373 100644 --- a/src/vnm/test/VirtualNetworkPoolTest.cc +++ b/src/vnm/test/VirtualNetworkPoolTest.cc @@ -180,6 +180,9 @@ class VirtualNetworkPoolTest : public PoolTest CPPUNIT_TEST (range_definition); + CPPUNIT_TEST (name_index); + CPPUNIT_TEST (chown_name_index); + CPPUNIT_TEST_SUITE_END (); protected: @@ -1690,6 +1693,135 @@ 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); + } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + 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); + } }; /* ************************************************************************* */