diff --git a/SConstruct b/SConstruct index 2c8a7931a4..06c32afa2f 100644 --- a/SConstruct +++ b/SConstruct @@ -81,6 +81,7 @@ main_env.Append(LIBPATH=[ cwd+'/src/xml', cwd+'/src/document', cwd+'/src/zone', + cwd+'/src/client', ]) # Compile flags @@ -249,7 +250,8 @@ build_scripts=[ 'src/sunstone/locale/languages/SConstruct', 'share/scripts/context-packages/SConstruct', 'share/rubygems/SConstruct', - 'src/im_mad/collectd/SConstruct' + 'src/im_mad/collectd/SConstruct', + 'src/client/SConstruct' ] for script in build_scripts: diff --git a/src/scheduler/include/Client.h b/include/Client.h similarity index 100% rename from src/scheduler/include/Client.h rename to include/Client.h diff --git a/include/GroupPool.h b/include/GroupPool.h index f3f9e74555..363135c0a4 100644 --- a/include/GroupPool.h +++ b/include/GroupPool.h @@ -156,20 +156,7 @@ public: * * @return 0 on success */ - int dump(ostringstream& oss, const string& where, const string& limit) - { - return PoolSQL::dump(oss, "GROUP_POOL", Group::table, where, limit); - }; - -protected: - - /** - * Adds the default quotas xml element, right after all the - * pool objects - * - * @param oss The output stream to dump the xml contents - */ - virtual void add_extra_xml(ostringstream& oss); + int dump(ostringstream& oss, const string& where, const string& limit); private: diff --git a/include/PoolSQL.h b/include/PoolSQL.h index f1e73b9205..f1c1b86744 100644 --- a/include/PoolSQL.h +++ b/include/PoolSQL.h @@ -173,7 +173,7 @@ public: */ int dump(ostringstream& oss, const string& where) { - dump(oss, where, ""); + return dump(oss, where, ""); } /** @@ -292,7 +292,7 @@ protected: const char * table, const string& where) { - dump(oss, elem_name, table, where, ""); + return dump(oss, elem_name, table, where, ""); } /** diff --git a/include/RequestManagerProxy.h b/include/RequestManagerProxy.h index d34ff5aa4c..d6745eff57 100644 --- a/include/RequestManagerProxy.h +++ b/include/RequestManagerProxy.h @@ -36,8 +36,11 @@ public: RequestAttributes& att); private: - Client* client; - string method; + const static size_t MESSAGE_SIZE; + + Client * client; + + string method; }; #endif diff --git a/include/UserPool.h b/include/UserPool.h index 3bbf6415d5..23051f7000 100644 --- a/include/UserPool.h +++ b/include/UserPool.h @@ -156,10 +156,7 @@ public: * * @return 0 on success */ - int dump(ostringstream& oss, const string& where, const string& limit) - { - return PoolSQL::dump(oss, "USER_POOL", User::table, where, limit); - }; + int dump(ostringstream& oss, const string& where, const string& limit); /** * Name for the OpenNebula core authentication process diff --git a/include/ZonePool.h b/include/ZonePool.h index 65b12f6d9c..c91c1c5c90 100644 --- a/include/ZonePool.h +++ b/include/ZonePool.h @@ -120,12 +120,13 @@ public: * query * @param oss the output stream to dump the pool contents * @param where filter for the objects, defaults to all + * @param limit parameters used for pagination * * @return 0 on success */ - int dump(ostringstream& oss, const string& where) + int dump(ostringstream& oss, const string& where, const string& limit) { - return PoolSQL::dump(oss, "ZONE_POOL", Zone::table, where); + return PoolSQL::dump(oss, "ZONE_POOL", Zone::table, where, limit); }; private: diff --git a/src/scheduler/src/client/Client.cc b/src/client/Client.cc similarity index 100% rename from src/scheduler/src/client/Client.cc rename to src/client/Client.cc diff --git a/src/scheduler/src/client/SConstruct b/src/client/SConstruct similarity index 92% rename from src/scheduler/src/client/SConstruct rename to src/client/SConstruct index 1d8123849d..a56db848a5 100644 --- a/src/scheduler/src/client/SConstruct +++ b/src/client/SConstruct @@ -16,11 +16,11 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -Import('sched_env') +Import('env') -lib_name='scheduler_client' +lib_name='nebula_client' source_files=['Client.cc'] # Build library -sched_env.StaticLibrary(lib_name, source_files) +env.StaticLibrary(lib_name, source_files) diff --git a/src/group/GroupPool.cc b/src/group/GroupPool.cc index 190b6d5e29..e2bce9336c 100644 --- a/src/group/GroupPool.cc +++ b/src/group/GroupPool.cc @@ -194,7 +194,7 @@ int GroupPool::drop(PoolObjectSQL * objsql, string& error_msg) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int GroupPool::dump(ostringstream& oss, const string& where) +int GroupPool::dump(ostringstream& oss, const string& where, const string& limit) { int rc; string def_quota_xml; @@ -202,9 +202,9 @@ int GroupPool::dump(ostringstream& oss, const string& where) ostringstream cmd; cmd << "SELECT " << Group::table << ".body, " - << GroupQuotas::db_table << ".body" - << " FROM " << Group::table << " LEFT JOIN " << GroupQuotas::db_table - << " ON " << Group::table << ".oid=" << GroupQuotas::db_table << ".group_oid"; + << GroupQuotas::db_table << ".body" << " FROM " << Group::table + << " LEFT JOIN " << GroupQuotas::db_table << " ON " + << Group::table << ".oid=" << GroupQuotas::db_table << ".group_oid"; if ( !where.empty() ) { @@ -213,6 +213,11 @@ int GroupPool::dump(ostringstream& oss, const string& where) cmd << " ORDER BY oid"; + if ( !limit.empty() ) + { + cmd << " LIMIT " << limit; + } + oss << ""; set_callback(static_cast(&GroupPool::dump_cb), diff --git a/src/nebula/SConstruct b/src/nebula/SConstruct index fdb9e0d35f..adc229ae7f 100644 --- a/src/nebula/SConstruct +++ b/src/nebula/SConstruct @@ -60,6 +60,7 @@ env.Prepend(LIBS=[ 'nebula_common', 'nebula_sql', 'nebula_log', + 'nebula_client', 'nebula_xml', 'crypto', 'xml2' diff --git a/src/rm/RequestManagerProxy.cc b/src/rm/RequestManagerProxy.cc index dac968db3a..166e7574df 100644 --- a/src/rm/RequestManagerProxy.cc +++ b/src/rm/RequestManagerProxy.cc @@ -17,6 +17,8 @@ #include "RequestManagerProxy.h" #include "Nebula.h" +const size_t RequestManagerProxy::MESSAGE_SIZE = 1073741824; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -26,7 +28,7 @@ RequestManagerProxy::RequestManagerProxy(string _method) "Forwards the request to another OpenNebula") { method = _method; - client = new Client("none", Nebula::instance().get_master_oned()); + client = new Client("none", Nebula::instance().get_master_oned(), MESSAGE_SIZE); } /* -------------------------------------------------------------------------- */ diff --git a/src/scheduler/SConstruct b/src/scheduler/SConstruct index 788e17ec79..827d868c9c 100644 --- a/src/scheduler/SConstruct +++ b/src/scheduler/SConstruct @@ -28,7 +28,6 @@ env.Append(CPPPATH=[ # Library dirs env.Append(LIBPATH=[ - cwd+'/src/client', cwd+'/src/pool', cwd+'/src/sched' ]) @@ -38,7 +37,6 @@ env.Append(LIBPATH=[ ################################################################################ build_scripts=[ - 'src/client/SConstruct', 'src/pool/SConstruct', 'src/sched/SConstruct' ] diff --git a/src/scheduler/src/sched/SConstruct b/src/scheduler/src/sched/SConstruct index 5fc550af65..f61c2ddfa5 100644 --- a/src/scheduler/src/sched/SConstruct +++ b/src/scheduler/src/sched/SConstruct @@ -31,7 +31,7 @@ sched_env.Prepend(LIBS=[ 'scheduler_sched', 'scheduler_pool', 'nebula_log', - 'scheduler_client', + 'nebula_client', 'nebula_acl', 'nebula_pool', 'nebula_xml', diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 15a007581e..90c0407b02 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -818,7 +818,7 @@ int UserPool::authorize(AuthRequest& ar) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int UserPool::dump(ostringstream& oss, const string& where) +int UserPool::dump(ostringstream& oss, const string& where, const string& limit) { int rc; string def_quota_xml; @@ -826,9 +826,9 @@ int UserPool::dump(ostringstream& oss, const string& where) ostringstream cmd; cmd << "SELECT " << User::table << ".body, " - << UserQuotas::db_table << ".body" - << " FROM " << User::table << " LEFT JOIN " << UserQuotas::db_table - << " ON " << User::table << ".oid=" << UserQuotas::db_table << ".user_oid"; + << UserQuotas::db_table << ".body"<< " FROM " << User::table + << " LEFT JOIN " << UserQuotas::db_table << " ON " + << User::table << ".oid=" << UserQuotas::db_table << ".user_oid"; if ( !where.empty() ) { @@ -837,6 +837,11 @@ int UserPool::dump(ostringstream& oss, const string& where) cmd << " ORDER BY oid"; + if ( !limit.empty() ) + { + cmd << " LIMIT " << limit; + } + oss << ""; set_callback(static_cast(&UserPool::dump_cb),