From dbe21675faef03b01422c040a643baa7251ed76f Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 8 Mar 2014 02:44:53 +0100 Subject: [PATCH] System attributes, Group and User quotas are local tables needs to be bootstraped locally --- include/Group.h | 8 +------ include/QuotasSQL.h | 56 +++++++++++++++++++++++++++++++++----------- include/User.h | 8 +------ src/nebula/Nebula.cc | 10 ++++---- 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/include/Group.h b/include/Group.h index febd6edc7c..a2f1812e6c 100644 --- a/include/Group.h +++ b/include/Group.h @@ -177,15 +177,9 @@ private: */ static int bootstrap(SqlDB * db) { - int rc; - ostringstream oss_group(Group::db_bootstrap); - ostringstream oss_quota(GroupQuotas::db_bootstrap); - rc = db->exec(oss_group); - rc += db->exec(oss_quota); - - return rc; + return db->exec(oss_group); }; /** diff --git a/include/QuotasSQL.h b/include/QuotasSQL.h index 322c123342..ae66c148ca 100644 --- a/include/QuotasSQL.h +++ b/include/QuotasSQL.h @@ -159,14 +159,16 @@ public: virtual ~GroupQuotas(){}; - // ************************************************************************* - // DataBase implementation - // ************************************************************************* + /** + * Bootstraps the database table for group quotas + * @return 0 on success + */ + static int bootstrap(SqlDB * db) + { + ostringstream oss_quota(GroupQuotas::db_bootstrap); - static const char * db_names; - static const char * db_bootstrap; - static const char * db_table; - static const char * db_oid_column; + return db->exec(oss_quota); + }; protected: @@ -184,6 +186,18 @@ protected: { return db_oid_column; }; + +private: + + friend class GroupPool; + + // ************************************************************************* + // DataBase implementation + // ************************************************************************* + static const char * db_names; + static const char * db_bootstrap; + static const char * db_table; + static const char * db_oid_column; }; /* -------------------------------------------------------------------------- */ @@ -198,14 +212,16 @@ public: "/QUOTAS/IMAGE_QUOTA", "/QUOTAS/VM_QUOTA"){}; - // ************************************************************************* - // DataBase implementation - // ************************************************************************* + /** + * Bootstraps the database table for user quotas + * @return 0 on success + */ + static int bootstrap(SqlDB * db) + { + ostringstream oss_quota(UserQuotas::db_bootstrap); - static const char * db_names; - static const char * db_bootstrap; - static const char * db_table; - static const char * db_oid_column; + return db->exec(oss_quota); + }; protected: @@ -223,6 +239,18 @@ protected: { return db_oid_column; }; + +private: + + friend class UserPool; + + // ************************************************************************* + // DataBase implementation + // ************************************************************************* + static const char * db_names; + static const char * db_bootstrap; + static const char * db_table; + static const char * db_oid_column; }; #endif /*QUOTAS_SQL_H_*/ diff --git a/include/User.h b/include/User.h index 28df797816..0d40bf23c0 100644 --- a/include/User.h +++ b/include/User.h @@ -317,15 +317,9 @@ private: */ static int bootstrap(SqlDB * db) { - int rc; - ostringstream oss_user(User::db_bootstrap); - ostringstream oss_quota(UserQuotas::db_bootstrap); - rc = db->exec(oss_user); - rc += db->exec(oss_quota); - - return rc; + return db->exec(oss_user); }; /** diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index e2cd887bb7..a8b730ac4b 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -330,12 +330,18 @@ void Nebula::start(bool bootstrap_only) rc += DatastorePool::bootstrap(db); rc += ClusterPool::bootstrap(db); rc += DocumentPool::bootstrap(db); + rc += UserQuotas::bootstrap(db); + rc += GroupQuotas::bootstrap(db); // Create the system tables only if bootstrap went well if (rc == 0) { rc += system_db->local_bootstrap(); } + + // Insert default system attributes + rc += default_user_quota.insert(); + rc += default_group_quota.insert(); } if (shared_bootstrap) @@ -353,10 +359,6 @@ void Nebula::start(bool bootstrap_only) { rc += system_db->shared_bootstrap(); } - - // Insert default system attributes - rc += default_user_quota.insert(); - rc += default_group_quota.insert(); } if ( rc != 0 )