mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-25 06:03:36 +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:
parent
a64e27c65b
commit
193e7a9cf6
@ -135,12 +135,14 @@ public:
|
|||||||
* query
|
* query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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:
|
private:
|
||||||
|
@ -168,12 +168,14 @@ public:
|
|||||||
* query
|
* query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,12 +93,14 @@ public:
|
|||||||
* query
|
* query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,12 +147,13 @@ public:
|
|||||||
* query
|
* query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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:
|
protected:
|
||||||
|
@ -178,12 +178,13 @@ public:
|
|||||||
* query
|
* query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,11 +138,13 @@ public:
|
|||||||
* query
|
* query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
|
*
|
||||||
* @return 0 on success
|
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,7 +171,23 @@ public:
|
|||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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
|
// Function to generate dump filters
|
||||||
@ -244,6 +260,23 @@ protected:
|
|||||||
*/
|
*/
|
||||||
SqlDB * db;
|
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
|
* Dumps the pool in XML format. A filter can be also added to the
|
||||||
* query
|
* query
|
||||||
@ -257,7 +290,10 @@ protected:
|
|||||||
int dump(ostringstream& oss,
|
int dump(ostringstream& oss,
|
||||||
const string& elem_name,
|
const string& elem_name,
|
||||||
const char * table,
|
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
|
* Dumps the output of the custom sql query into an xml
|
||||||
|
@ -147,12 +147,13 @@ public:
|
|||||||
* query
|
* query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,12 +98,14 @@ public:
|
|||||||
* query
|
* query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,12 +196,14 @@ public:
|
|||||||
* pool
|
* pool
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,12 +138,14 @@ public:
|
|||||||
* to the query
|
* to the query
|
||||||
* @param oss the output stream to dump the pool contents
|
* @param oss the output stream to dump the pool contents
|
||||||
* @param where filter for the objects, defaults to all
|
* @param where filter for the objects, defaults to all
|
||||||
|
* @param limit parameters used for pagination
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -488,7 +488,8 @@ int PoolSQL::dump_cb(void * _oss, int num, char **values, char **names)
|
|||||||
int PoolSQL::dump(ostringstream& oss,
|
int PoolSQL::dump(ostringstream& oss,
|
||||||
const string& elem_name,
|
const string& elem_name,
|
||||||
const char * table,
|
const char * table,
|
||||||
const string& where)
|
const string& where,
|
||||||
|
const string& limit)
|
||||||
{
|
{
|
||||||
ostringstream cmd;
|
ostringstream cmd;
|
||||||
|
|
||||||
@ -501,6 +502,11 @@ int PoolSQL::dump(ostringstream& oss,
|
|||||||
|
|
||||||
cmd << " ORDER BY oid";
|
cmd << " ORDER BY oid";
|
||||||
|
|
||||||
|
if ( !limit.empty() )
|
||||||
|
{
|
||||||
|
cmd << " LIMIT " << limit;
|
||||||
|
}
|
||||||
|
|
||||||
return dump(oss, elem_name, cmd);
|
return dump(oss, elem_name, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,7 +704,7 @@ void PoolSQL::oid_filter(int start_id,
|
|||||||
{
|
{
|
||||||
ostringstream idfilter;
|
ostringstream idfilter;
|
||||||
|
|
||||||
if ( start_id != -1 )
|
if ( end_id >= -1 && start_id != -1 )
|
||||||
{
|
{
|
||||||
idfilter << "oid >= " << start_id;
|
idfilter << "oid >= " << start_id;
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ void RequestManagerPoolInfoFilter::dump(
|
|||||||
const string& or_clause)
|
const string& or_clause)
|
||||||
{
|
{
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
string where_string;
|
string where_string, limit_clause;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ( filter_flag < MINE )
|
if ( filter_flag < MINE )
|
||||||
@ -362,7 +362,14 @@ void RequestManagerPoolInfoFilter::dump(
|
|||||||
or_clause,
|
or_clause,
|
||||||
where_string);
|
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 )
|
if ( rc != 0 )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user