1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

feature #2371: add pagination to pool info

When the end_id of pool.info xmlrpc call is lower than -1 the parameters
do not refer to object ids but offset and cuantity used for pool pagination.r
The SQL query will have "LIMIT start_id,-end_id".
This commit is contained in:
Javi Fontan 2014-01-13 16:30:43 +01:00
parent a64e27c65b
commit 193e7a9cf6
13 changed files with 92 additions and 26 deletions

View File

@ -135,12 +135,14 @@ 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, "CLUSTER_POOL", Cluster::table, where);
return PoolSQL::dump(oss, "CLUSTER_POOL", Cluster::table, where,
limit);
};
private:

View File

@ -168,12 +168,14 @@ 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, "DATASTORE_POOL", Datastore::table, where);
return PoolSQL::dump(oss, "DATASTORE_POOL", Datastore::table, where,
limit);
};
/**

View File

@ -93,12 +93,14 @@ 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, "DOCUMENT_POOL",Document::table,where);
return PoolSQL::dump(oss, "DOCUMENT_POOL", Document::table, where,
limit);
};
/**

View File

@ -147,12 +147,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, "GROUP_POOL", Group::table, where);
return PoolSQL::dump(oss, "GROUP_POOL", Group::table, where, limit);
};
protected:

View File

@ -178,12 +178,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, "HOST_POOL", Host::table, where);
return PoolSQL::dump(oss, "HOST_POOL", Host::table, where, limit);
};
/**

View File

@ -138,11 +138,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, "IMAGE_POOL", Image::table, where);
return PoolSQL::dump(oss, "IMAGE_POOL", Image::table, where, limit);
}
/**

View File

@ -171,7 +171,23 @@ public:
*
* @return 0 on success
*/
virtual int dump(ostringstream& oss, const string& where) = 0;
int dump(ostringstream& oss, const string& where)
{
dump(oss, where, "");
}
/**
* Dumps the pool in XML format. A filter and limit can be also added
* to the 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
*/
virtual int dump(ostringstream& oss, const string& where,
const string& limit) = 0;
// -------------------------------------------------------------------------
// Function to generate dump filters
@ -244,6 +260,23 @@ protected:
*/
SqlDB * db;
/**
* Dumps the pool in XML format. A filter and limit can be also added
* to the query
* @param oss the output stream to dump the pool contents
* @param elem_name Name of the root xml pool name
* @param table Pool table name
* @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& elem_name,
const char * table,
const string& where,
const string& limit);
/**
* Dumps the pool in XML format. A filter can be also added to the
* query
@ -257,7 +290,10 @@ protected:
int dump(ostringstream& oss,
const string& elem_name,
const char * table,
const string& where);
const string& where)
{
dump(oss, elem_name, table, where, "");
}
/**
* Dumps the output of the custom sql query into an xml

View File

@ -147,12 +147,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, "USER_POOL", User::table, where);
return PoolSQL::dump(oss, "USER_POOL", User::table, where, limit);
};
/**

View File

@ -98,12 +98,14 @@ 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, "VMTEMPLATE_POOL",VMTemplate::table,where);
return PoolSQL::dump(oss, "VMTEMPLATE_POOL", VMTemplate::table, where,
limit);
};
/**

View File

@ -196,12 +196,14 @@ public:
* pool
* @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, "VM_POOL", VirtualMachine::table, where);
return PoolSQL::dump(oss, "VM_POOL", VirtualMachine::table, where,
limit);
};
/**

View File

@ -138,12 +138,14 @@ public:
* to the 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, "VNET_POOL", VirtualNetwork::table,where);
return PoolSQL::dump(oss, "VNET_POOL", VirtualNetwork::table, where,
limit);
}
/**

View File

@ -488,7 +488,8 @@ int PoolSQL::dump_cb(void * _oss, int num, char **values, char **names)
int PoolSQL::dump(ostringstream& oss,
const string& elem_name,
const char * table,
const string& where)
const string& where,
const string& limit)
{
ostringstream cmd;
@ -501,6 +502,11 @@ int PoolSQL::dump(ostringstream& oss,
cmd << " ORDER BY oid";
if ( !limit.empty() )
{
cmd << " LIMIT " << limit;
}
return dump(oss, elem_name, cmd);
}
@ -698,7 +704,7 @@ void PoolSQL::oid_filter(int start_id,
{
ostringstream idfilter;
if ( start_id != -1 )
if ( end_id >= -1 && start_id != -1 )
{
idfilter << "oid >= " << start_id;

View File

@ -343,7 +343,7 @@ void RequestManagerPoolInfoFilter::dump(
const string& or_clause)
{
ostringstream oss;
string where_string;
string where_string, limit_clause;
int rc;
if ( filter_flag < MINE )
@ -362,7 +362,14 @@ void RequestManagerPoolInfoFilter::dump(
or_clause,
where_string);
rc = pool->dump(oss, where_string);
if ( end_id < -1 )
{
oss << start_id << "," << -end_id;
limit_clause = oss.str();
oss.str("");
}
rc = pool->dump(oss, where_string, limit_clause);
if ( rc != 0 )
{