mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-25 23:21:29 +03:00
Merge branch 'feature-1112' of git.opennebula.org:one into feature-1112
This commit is contained in:
commit
8988ba734c
@ -123,7 +123,10 @@ private:
|
|||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
|
|
||||||
Datastore(
|
Datastore(
|
||||||
int id,
|
int uid,
|
||||||
|
int gid,
|
||||||
|
const string& uname,
|
||||||
|
const string& gname,
|
||||||
DatastoreTemplate* ds_template,
|
DatastoreTemplate* ds_template,
|
||||||
int cluster_id,
|
int cluster_id,
|
||||||
const string& cluster_name);
|
const string& cluster_name);
|
||||||
|
@ -61,6 +61,10 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Allocates a new Datastore, writing it in the pool database. No memory is
|
* Allocates a new Datastore, writing it in the pool database. No memory is
|
||||||
* allocated for the object.
|
* allocated for the object.
|
||||||
|
* @param uid the user id of the Datastore owner
|
||||||
|
* @param gid the id of the group this object is assigned to
|
||||||
|
* @param uname name of the user
|
||||||
|
* @param gname name of the group
|
||||||
* @param ds_template Datastore definition template
|
* @param ds_template Datastore definition template
|
||||||
* @param oid the id assigned to the Datastore
|
* @param oid the id assigned to the Datastore
|
||||||
* @param cluster_id the id of the cluster this Datastore will belong to
|
* @param cluster_id the id of the cluster this Datastore will belong to
|
||||||
@ -69,11 +73,16 @@ public:
|
|||||||
*
|
*
|
||||||
* @return the oid assigned to the object, -1 in case of failure
|
* @return the oid assigned to the object, -1 in case of failure
|
||||||
*/
|
*/
|
||||||
int allocate(DatastoreTemplate * ds_template,
|
int allocate(
|
||||||
int * oid,
|
int uid,
|
||||||
int cluster_id,
|
int gid,
|
||||||
const string& cluster_name,
|
const string& uname,
|
||||||
string& error_str);
|
const string& gname,
|
||||||
|
DatastoreTemplate * ds_template,
|
||||||
|
int * oid,
|
||||||
|
int cluster_id,
|
||||||
|
const string& cluster_name,
|
||||||
|
string& error_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get a Datastore from the pool, if the object is not in memory
|
* Function to get a Datastore from the pool, if the object is not in memory
|
||||||
@ -163,7 +172,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
PoolObjectSQL * create()
|
PoolObjectSQL * create()
|
||||||
{
|
{
|
||||||
return new Datastore(-1, 0, -1, "");
|
return new Datastore(-1,-1,"","", 0, -1, "");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -176,6 +176,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
static const char * SERVER_NAME;
|
static const char * SERVER_NAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the oneadmin user
|
||||||
|
*/
|
||||||
|
static string oneadmin_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier for the oneadmin user
|
||||||
|
*/
|
||||||
|
static const int ONEADMIN_ID;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Configuration Attributes for Users
|
// Configuration Attributes for Users
|
||||||
|
@ -66,6 +66,9 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
|||||||
CLIHelper.print_header(str_h1 % "DATASTORE #{datastore['ID']} INFORMATION")
|
CLIHelper.print_header(str_h1 % "DATASTORE #{datastore['ID']} INFORMATION")
|
||||||
puts str % ["ID", datastore.id.to_s]
|
puts str % ["ID", datastore.id.to_s]
|
||||||
puts str % ["NAME", datastore.name]
|
puts str % ["NAME", datastore.name]
|
||||||
|
puts str % ["USER", datastore['UNAME']]
|
||||||
|
puts str % ["GROUP", datastore['GNAME']]
|
||||||
|
|
||||||
puts str % ["TYPE", datastore['TYPE']]
|
puts str % ["TYPE", datastore['TYPE']]
|
||||||
puts str % ["BASE PATH",datastore['BASE_PATH']]
|
puts str % ["BASE PATH",datastore['BASE_PATH']]
|
||||||
puts
|
puts
|
||||||
|
@ -34,16 +34,20 @@ const char * Datastore::db_bootstrap =
|
|||||||
/* Datastore :: Constructor/Destructor */
|
/* Datastore :: Constructor/Destructor */
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
|
|
||||||
Datastore::Datastore(int id,
|
Datastore::Datastore(
|
||||||
DatastoreTemplate* ds_template,
|
int uid,
|
||||||
int cluster_id,
|
int gid,
|
||||||
const string& cluster_name):
|
const string& uname,
|
||||||
PoolObjectSQL(id,DATASTORE,"",-1,-1,"","",table),
|
const string& gname,
|
||||||
ObjectCollection("IMAGES"),
|
DatastoreTemplate* ds_template,
|
||||||
Clusterable(cluster_id, cluster_name),
|
int cluster_id,
|
||||||
type(""),
|
const string& cluster_name):
|
||||||
tm_mad(""),
|
PoolObjectSQL(-1,DATASTORE,"",uid,gid,uname,gname,table),
|
||||||
base_path("")
|
ObjectCollection("IMAGES"),
|
||||||
|
Clusterable(cluster_id, cluster_name),
|
||||||
|
type(""),
|
||||||
|
tm_mad(""),
|
||||||
|
base_path("")
|
||||||
{
|
{
|
||||||
if (ds_template != 0)
|
if (ds_template != 0)
|
||||||
{
|
{
|
||||||
@ -144,10 +148,6 @@ int Datastore::insert_replace(SqlDB *db, bool replace, string& error_str)
|
|||||||
char * sql_name;
|
char * sql_name;
|
||||||
char * sql_xml;
|
char * sql_xml;
|
||||||
|
|
||||||
// Set the owner and group to oneadmin
|
|
||||||
set_user(0, "");
|
|
||||||
set_group(GroupPool::ONEADMIN_ID, GroupPool::ONEADMIN_NAME);
|
|
||||||
|
|
||||||
// Update the Datastore
|
// Update the Datastore
|
||||||
|
|
||||||
sql_name = db->escape_str(name.c_str());
|
sql_name = db->escape_str(name.c_str());
|
||||||
@ -232,10 +232,14 @@ string& Datastore::to_xml(string& xml) const
|
|||||||
|
|
||||||
oss <<
|
oss <<
|
||||||
"<DATASTORE>" <<
|
"<DATASTORE>" <<
|
||||||
"<ID>" << oid << "</ID>" <<
|
"<ID>" << oid << "</ID>" <<
|
||||||
"<NAME>" << name << "</NAME>" <<
|
"<UID>" << uid << "</UID>" <<
|
||||||
"<TYPE>" << type << "</TYPE>" <<
|
"<GID>" << gid << "</GID>" <<
|
||||||
"<TM_MAD>" << tm_mad << "</TM_MAD>" <<
|
"<UNAME>" << uname << "</UNAME>" <<
|
||||||
|
"<GNAME>" << gname << "</GNAME>" <<
|
||||||
|
"<NAME>" << name << "</NAME>" <<
|
||||||
|
"<TYPE>" << type << "</TYPE>" <<
|
||||||
|
"<TM_MAD>" << tm_mad << "</TM_MAD>" <<
|
||||||
"<BASE_PATH>" << base_path << "</BASE_PATH>" <<
|
"<BASE_PATH>" << base_path << "</BASE_PATH>" <<
|
||||||
"<CLUSTER_ID>" << cluster_id << "</CLUSTER_ID>" <<
|
"<CLUSTER_ID>" << cluster_id << "</CLUSTER_ID>" <<
|
||||||
"<CLUSTER>" << cluster << "</CLUSTER>" <<
|
"<CLUSTER>" << cluster << "</CLUSTER>" <<
|
||||||
@ -261,6 +265,10 @@ int Datastore::from_xml(const string& xml)
|
|||||||
|
|
||||||
// Get class base attributes
|
// Get class base attributes
|
||||||
rc += xpath(oid, "/DATASTORE/ID", -1);
|
rc += xpath(oid, "/DATASTORE/ID", -1);
|
||||||
|
rc += xpath(uid, "/DATASTORE/UID", -1);
|
||||||
|
rc += xpath(gid, "/DATASTORE/GID", -1);
|
||||||
|
rc += xpath(uname, "/DATASTORE/UNAME", "not_found");
|
||||||
|
rc += xpath(gname, "/DATASTORE/GNAME", "not_found");
|
||||||
rc += xpath(name, "/DATASTORE/NAME", "not_found");
|
rc += xpath(name, "/DATASTORE/NAME", "not_found");
|
||||||
rc += xpath(type, "/DATASTORE/TYPE", "not_found");
|
rc += xpath(type, "/DATASTORE/TYPE", "not_found");
|
||||||
rc += xpath(tm_mad, "/DATASTORE/TM_MAD", "not_found");
|
rc += xpath(tm_mad, "/DATASTORE/TM_MAD", "not_found");
|
||||||
@ -269,10 +277,6 @@ int Datastore::from_xml(const string& xml)
|
|||||||
rc += xpath(cluster_id, "/DATASTORE/CLUSTER_ID", -1);
|
rc += xpath(cluster_id, "/DATASTORE/CLUSTER_ID", -1);
|
||||||
rc += xpath(cluster, "/DATASTORE/CLUSTER", "not_found");
|
rc += xpath(cluster, "/DATASTORE/CLUSTER", "not_found");
|
||||||
|
|
||||||
// Set the owner and group to oneadmin
|
|
||||||
set_user(0, "");
|
|
||||||
set_group(GroupPool::ONEADMIN_ID, GroupPool::ONEADMIN_NAME);
|
|
||||||
|
|
||||||
// Get associated classes
|
// Get associated classes
|
||||||
ObjectXML::get_nodes("/DATASTORE/IMAGES", content);
|
ObjectXML::get_nodes("/DATASTORE/IMAGES", content);
|
||||||
|
|
||||||
|
@ -67,7 +67,11 @@ DatastorePool::DatastorePool(SqlDB * db):
|
|||||||
goto error_bootstrap;
|
goto error_bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
allocate(ds_tmpl,
|
allocate(UserPool::ONEADMIN_ID,
|
||||||
|
GroupPool::ONEADMIN_ID,
|
||||||
|
UserPool::oneadmin_name,
|
||||||
|
GroupPool::ONEADMIN_NAME,
|
||||||
|
ds_tmpl,
|
||||||
&system_id,
|
&system_id,
|
||||||
ClusterPool::DEFAULT_CLUSTER_ID,
|
ClusterPool::DEFAULT_CLUSTER_ID,
|
||||||
ClusterPool::DEFAULT_CLUSTER_NAME,
|
ClusterPool::DEFAULT_CLUSTER_NAME,
|
||||||
@ -95,7 +99,11 @@ DatastorePool::DatastorePool(SqlDB * db):
|
|||||||
goto error_bootstrap;
|
goto error_bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
allocate(ds_tmpl,
|
allocate(UserPool::ONEADMIN_ID,
|
||||||
|
GroupPool::ONEADMIN_ID,
|
||||||
|
UserPool::oneadmin_name,
|
||||||
|
GroupPool::ONEADMIN_NAME,
|
||||||
|
ds_tmpl,
|
||||||
&default_id,
|
&default_id,
|
||||||
ClusterPool::DEFAULT_CLUSTER_ID,
|
ClusterPool::DEFAULT_CLUSTER_ID,
|
||||||
ClusterPool::DEFAULT_CLUSTER_NAME,
|
ClusterPool::DEFAULT_CLUSTER_NAME,
|
||||||
@ -145,18 +153,24 @@ error_bootstrap:
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int DatastorePool::allocate(DatastoreTemplate * ds_template,
|
int DatastorePool::allocate(
|
||||||
int * oid,
|
int uid,
|
||||||
int cluster_id,
|
int gid,
|
||||||
const string& cluster_name,
|
const string& uname,
|
||||||
string& error_str)
|
const string& gname,
|
||||||
|
DatastoreTemplate * ds_template,
|
||||||
|
int * oid,
|
||||||
|
int cluster_id,
|
||||||
|
const string& cluster_name,
|
||||||
|
string& error_str)
|
||||||
{
|
{
|
||||||
Datastore * ds;
|
Datastore * ds;
|
||||||
Datastore * ds_aux = 0;
|
Datastore * ds_aux = 0;
|
||||||
string name;
|
string name;
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
|
|
||||||
ds = new Datastore(-1, ds_template, cluster_id, cluster_name);
|
ds = new Datastore(uid, gid, uname, gname,
|
||||||
|
ds_template, cluster_id, cluster_name);
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Check name & duplicates
|
// Check name & duplicates
|
||||||
|
@ -467,7 +467,8 @@ int DatastoreAllocate::pool_allocate(
|
|||||||
|
|
||||||
DatastoreTemplate * ds_tmpl = static_cast<DatastoreTemplate *>(tmpl);
|
DatastoreTemplate * ds_tmpl = static_cast<DatastoreTemplate *>(tmpl);
|
||||||
|
|
||||||
return dspool->allocate(ds_tmpl, &id, cluster_id, cluster_name, error_str);
|
return dspool->allocate(att.uid, att.gid, att.uname, att.gname,
|
||||||
|
ds_tmpl, &id, cluster_id, cluster_name, error_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -40,11 +40,15 @@ const char * UserPool::DEFAULT_AUTH = "default";
|
|||||||
|
|
||||||
const char * UserPool::SERVER_NAME = "serveradmin";
|
const char * UserPool::SERVER_NAME = "serveradmin";
|
||||||
|
|
||||||
|
const int UserPool::ONEADMIN_ID = 0;
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
time_t UserPool::_session_expiration_time;
|
time_t UserPool::_session_expiration_time;
|
||||||
|
|
||||||
|
string UserPool::oneadmin_name;
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -74,8 +78,13 @@ UserPool::UserPool(SqlDB * db,
|
|||||||
|
|
||||||
_session_expiration_time = __session_expiration_time;
|
_session_expiration_time = __session_expiration_time;
|
||||||
|
|
||||||
if (get(0,false) != 0)
|
User * oneadmin_user = get(0, true);
|
||||||
|
|
||||||
|
if (oneadmin_user != 0)
|
||||||
{
|
{
|
||||||
|
oneadmin_name = oneadmin_user->get_name();
|
||||||
|
oneadmin_user->unlock();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +131,8 @@ UserPool::UserPool(SqlDB * db,
|
|||||||
goto error_token;
|
goto error_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oneadmin_name = one_name;
|
||||||
|
|
||||||
if ( one_name == SERVER_NAME )
|
if ( one_name == SERVER_NAME )
|
||||||
{
|
{
|
||||||
goto error_one_name;
|
goto error_one_name;
|
||||||
|
Loading…
Reference in New Issue
Block a user