mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
feature #407: All resources now uses the base classes and index
This commit is contained in:
parent
0fcf98db16
commit
fadbe3a4d7
@ -37,8 +37,7 @@ class PoolObjectSQL : public ObjectSQL, public ObjectXML
|
||||
{
|
||||
public:
|
||||
|
||||
//TODO remove Defaults for Constructor Attributes
|
||||
PoolObjectSQL(int id=-1, const string& _name ="", int _uid=0,const char *_table = 0)
|
||||
PoolObjectSQL(int id, const string& _name, int _uid,const char *_table)
|
||||
:ObjectSQL(),ObjectXML(),oid(id),name(_name),uid(_uid),
|
||||
valid(true),table(_table)
|
||||
{
|
||||
|
@ -47,8 +47,7 @@ public:
|
||||
* counter). If null the OID counter is not updated.
|
||||
* @param with_uid the Pool objects have an owner id (uid)
|
||||
*/
|
||||
//TODO REmove defaults
|
||||
PoolSQL(SqlDB * _db, const char * table, bool with_uid=false);
|
||||
PoolSQL(SqlDB * _db, const char * table, bool with_uid);
|
||||
|
||||
virtual ~PoolSQL();
|
||||
|
||||
|
@ -43,15 +43,6 @@ public:
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
|
||||
/**
|
||||
* Get the User unique identifier UID, that matches the OID of the object
|
||||
* @return UID User identifier
|
||||
*/
|
||||
int get_uid() const
|
||||
{
|
||||
return oid;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the user is enabled
|
||||
* @return true if the user is enabled
|
||||
@ -61,15 +52,6 @@ public:
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns user username
|
||||
* @return username User's hostname
|
||||
*/
|
||||
const string& get_username() const
|
||||
{
|
||||
return username;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns user password
|
||||
* @return username User's hostname
|
||||
@ -98,11 +80,11 @@ public:
|
||||
/**
|
||||
* Sets user username
|
||||
*/
|
||||
void set_username(string _username)
|
||||
/* void set_username(string _username)
|
||||
{
|
||||
username = _username;
|
||||
};
|
||||
|
||||
*/
|
||||
/**
|
||||
* Sets user password
|
||||
*/
|
||||
@ -138,11 +120,6 @@ private:
|
||||
// User Attributes
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* User's username
|
||||
*/
|
||||
string username;
|
||||
|
||||
/**
|
||||
* User's password
|
||||
*/
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
|
||||
if ( rc == 0)
|
||||
{
|
||||
known_users.erase(user->get_username());
|
||||
known_users.erase(user->get_name());
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -183,16 +183,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the name of the VM
|
||||
* @return the VM name
|
||||
*/
|
||||
const string& get_name() const
|
||||
{
|
||||
return name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the deployment ID
|
||||
* @return the VMM driver specific ID
|
||||
@ -687,7 +677,6 @@ public:
|
||||
return uid;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Timers
|
||||
// ------------------------------------------------------------------------
|
||||
@ -753,7 +742,6 @@ public:
|
||||
*/
|
||||
int generate_context(string &files);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Image repository related functions
|
||||
// ------------------------------------------------------------------------
|
||||
@ -802,11 +790,6 @@ private:
|
||||
// Virtual Machine Description
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Name of the VM
|
||||
*/
|
||||
string name;
|
||||
|
||||
/**
|
||||
* The Virtual Machine template, holds the VM attributes.
|
||||
*/
|
||||
|
@ -32,10 +32,10 @@
|
||||
|
||||
const char * TestObjectSQL::table = "test_pool";
|
||||
|
||||
const char * TestObjectSQL::db_names = "(oid,number,text)";
|
||||
const char * TestObjectSQL::db_names = "(oid,number,name)";
|
||||
|
||||
const char * TestObjectSQL::db_bootstrap = "CREATE TABLE test_pool ("
|
||||
"oid INTEGER, number INTEGER, text TEXT, PRIMARY KEY(oid))";
|
||||
"oid INTEGER, number INTEGER, name TEXT, PRIMARY KEY(oid))";
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -30,7 +30,7 @@ class TestObjectSQL : public PoolObjectSQL
|
||||
{
|
||||
public:
|
||||
//OBJECT ATTRIBUTES
|
||||
TestObjectSQL(int n=-1, string t="default"):number(n),text(t){};
|
||||
TestObjectSQL(int n=-1, string t="default"):PoolObjectSQL(-1,"",0,0),number(n),text(t){};
|
||||
|
||||
~TestObjectSQL(){};
|
||||
|
||||
@ -88,7 +88,7 @@ class TestPool : public PoolSQL
|
||||
{
|
||||
|
||||
public:
|
||||
TestPool(SqlDB *db):PoolSQL(db,"test_pool"){};
|
||||
TestPool(SqlDB *db):PoolSQL(db,"test_pool",false){};
|
||||
~TestPool(){};
|
||||
|
||||
TestObjectSQL * get(
|
||||
|
@ -141,7 +141,7 @@ public:
|
||||
|
||||
vector<int> results;
|
||||
const char * table = "test_pool";
|
||||
string where = "text = '" + stB + "'";
|
||||
string where = "name = '" + stB + "'";
|
||||
int ret;
|
||||
|
||||
ret = pool->search(results, table, where);
|
||||
@ -205,4 +205,4 @@ public:
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
return OneUnitTest::main(argc, argv, PoolTest::suite());
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ void RequestManager::VirtualMachineAllocate::execute(
|
||||
goto error_user_get;
|
||||
}
|
||||
|
||||
user_name = user->get_username();
|
||||
user_name = user->get_name();
|
||||
|
||||
user->unlock();
|
||||
|
||||
|
@ -110,7 +110,7 @@ void RequestManager::ImageAllocate::execute(
|
||||
goto error_user_get;
|
||||
}
|
||||
|
||||
user_name = user->get_username();
|
||||
user_name = user->get_name();
|
||||
|
||||
user->unlock();
|
||||
|
||||
|
@ -109,7 +109,7 @@ void RequestManager::VirtualNetworkAllocate::execute(
|
||||
goto error_user_get;
|
||||
}
|
||||
|
||||
user_name = user->get_username();
|
||||
user_name = user->get_name();
|
||||
|
||||
user->unlock();
|
||||
|
||||
|
@ -35,8 +35,7 @@ User::User(
|
||||
string _username,
|
||||
string _password,
|
||||
bool _enabled):
|
||||
PoolObjectSQL(id, table),
|
||||
username (_username),
|
||||
PoolObjectSQL(id, _username, 0, table),
|
||||
password (_password),
|
||||
enabled (_enabled)
|
||||
{};
|
||||
@ -105,7 +104,7 @@ int User::insert_replace(SqlDB *db, bool replace)
|
||||
|
||||
// Update the User
|
||||
|
||||
sql_username = db->escape_str(username.c_str());
|
||||
sql_username = db->escape_str(name.c_str());
|
||||
|
||||
if ( sql_username == 0 )
|
||||
{
|
||||
@ -172,7 +171,7 @@ string& User::to_xml(string& xml) const
|
||||
oss <<
|
||||
"<USER>"
|
||||
"<ID>" << oid <<"</ID>" <<
|
||||
"<NAME>" << username <<"</NAME>" <<
|
||||
"<NAME>" << name <<"</NAME>" <<
|
||||
"<PASSWORD>" << password <<"</PASSWORD>" <<
|
||||
"<ENABLED>" << enabled_int <<"</ENABLED>" <<
|
||||
"</USER>";
|
||||
@ -194,7 +193,7 @@ int User::from_xml(const string& xml)
|
||||
update_from_str(xml);
|
||||
|
||||
rc += xpath(oid, "/USER/ID", -1);
|
||||
rc += xpath(username, "/USER/NAME", "not_found");
|
||||
rc += xpath(name, "/USER/NAME", "not_found");
|
||||
rc += xpath(password, "/USER/PASSWORD", "not_found");
|
||||
rc += xpath(int_enabled, "/USER/ENABLED", 0);
|
||||
|
||||
|
@ -45,7 +45,7 @@ int UserPool::init_cb(void *nil, int num, char **values, char **names)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
UserPool::UserPool(SqlDB * db):PoolSQL(db,User::table)
|
||||
UserPool::UserPool(SqlDB * db):PoolSQL(db,User::table,false)
|
||||
{
|
||||
ostringstream sql;
|
||||
|
||||
|
@ -100,7 +100,7 @@ protected:
|
||||
{
|
||||
CPPUNIT_ASSERT( obj != 0 );
|
||||
|
||||
string name = ((User*)obj)->get_username();
|
||||
string name = ((User*)obj)->get_name();
|
||||
CPPUNIT_ASSERT( name == usernames[index] );
|
||||
CPPUNIT_ASSERT( ((User*)obj)->get_password() == passwords[index] );
|
||||
};
|
||||
@ -150,7 +150,7 @@ public:
|
||||
CPPUNIT_ASSERT(user != 0);
|
||||
|
||||
CPPUNIT_ASSERT( user->get_uid() == 0 );
|
||||
CPPUNIT_ASSERT( user->get_username() == "one_user_test" );
|
||||
CPPUNIT_ASSERT( user->get_name() == "one_user_test" );
|
||||
CPPUNIT_ASSERT( user->get_password() == User::sha1_digest("password") );
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,9 @@
|
||||
VirtualMachine::VirtualMachine(int id,
|
||||
string _user_name,
|
||||
VirtualMachineTemplate * _vm_template):
|
||||
PoolObjectSQL(id,table),
|
||||
uid(-1),
|
||||
PoolObjectSQL(id,"",-1,table),
|
||||
user_name(_user_name),
|
||||
last_poll(0),
|
||||
name(""),
|
||||
state(INIT),
|
||||
lcm_state(LCM_INIT),
|
||||
stime(time(0)),
|
||||
|
@ -27,7 +27,7 @@
|
||||
VirtualMachinePool::VirtualMachinePool(SqlDB * db,
|
||||
vector<const Attribute *> hook_mads,
|
||||
const string& hook_location)
|
||||
: PoolSQL(db,VirtualMachine::table)
|
||||
: PoolSQL(db,VirtualMachine::table,true)
|
||||
{
|
||||
const VectorAttribute * vattr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user