mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-08 21:16:39 +09:00
Revert "Bug #1694: If a DS updates its type to system_ds, update the cluster system_ds"
This reverts commit ca4504f984.
This commit is contained in:
1 parent
a10e19fe05
commit
c523b889f1
6 files changed
+5
-165
No files matched your search
@@ -41,16 +41,6 @@ public:
|
||||
return system_ds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SYSTEM_DS attribute
|
||||
*
|
||||
* @param ds_id The new system datastore
|
||||
*/
|
||||
void set_ds_id(int ds_id)
|
||||
{
|
||||
system_ds = ds_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DATASTORE_LOCATION for the hosts of the cluster. If not
|
||||
* defined that in oned.conf is returned.
|
||||
|
||||
+1
-8
@@ -57,18 +57,11 @@ public:
|
||||
|
||||
/**
|
||||
* Return the string representation of a DatastoreType
|
||||
* @param str_type string representing the DatastoreType
|
||||
* @param str_type string representing the DatastoreTypr
|
||||
* @return the DatastoreType (defaults to IMAGE_DS)
|
||||
*/
|
||||
static DatastoreType str_to_type(string& str_type);
|
||||
|
||||
/**
|
||||
* Returns the DS type found in the string template
|
||||
* @param str_template string template
|
||||
* @return the DatastoreType (defaults to IMAGE_DS)
|
||||
*/
|
||||
static DatastoreType type_in_template(string& str_template);
|
||||
|
||||
/**
|
||||
* Function to print the Datastore object into a string in XML format
|
||||
* @param xml the resulting XML string
|
||||
|
||||
@@ -40,7 +40,7 @@ protected:
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
virtual void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
};
|
||||
|
||||
@@ -150,9 +150,6 @@ public:
|
||||
};
|
||||
|
||||
~DatastoreUpdateTemplate(){};
|
||||
|
||||
virtual void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -96,13 +96,12 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
def format_resource(cluster)
|
||||
str="%-18s: %-20s"
|
||||
str="%-15s: %-20s"
|
||||
str_h1="%-80s"
|
||||
|
||||
CLIHelper.print_header(str_h1 % "CLUSTER #{cluster['ID']} INFORMATION")
|
||||
puts str % ["ID", cluster.id.to_s]
|
||||
puts str % ["NAME", cluster.name]
|
||||
puts str % ["SYSTEM DATASTORE", cluster['SYSTEM_DS']]
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "CLUSTER TEMPLATE", false)
|
||||
|
||||
@@ -122,22 +122,6 @@ Datastore::DatastoreType Datastore::str_to_type(string& str_type)
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
Datastore::DatastoreType Datastore::type_in_template(string& str_template)
|
||||
{
|
||||
string s_ds_type;
|
||||
string error_str;
|
||||
|
||||
Template tmp_template;
|
||||
tmp_template.parse_str_or_xml(str_template, error_str);
|
||||
|
||||
tmp_template.get("TYPE", s_ds_type);
|
||||
|
||||
return Datastore::str_to_type(s_ds_type);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int Datastore::insert(SqlDB *db, string& error_str)
|
||||
{
|
||||
int rc;
|
||||
@@ -447,9 +431,9 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str)
|
||||
else
|
||||
{
|
||||
type = str_to_type(s_ds_type);
|
||||
}
|
||||
|
||||
replace_template_attribute("TYPE", type_to_str(type));
|
||||
replace_template_attribute("TYPE", type_to_str(type));
|
||||
}
|
||||
|
||||
if ( type == SYSTEM_DS )
|
||||
{
|
||||
|
||||
@@ -70,126 +70,3 @@ void RequestManagerUpdateTemplate::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void DatastoreUpdateTemplate::request_execute(
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
int rc;
|
||||
string error_str;
|
||||
|
||||
int oid = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
string tmpl = xmlrpc_c::value_string(paramList.getString(2));
|
||||
|
||||
Datastore * object;
|
||||
|
||||
if ( basic_authorization(oid, att) == false )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
object = static_cast<DatastorePool*>(pool)->get(oid,true);
|
||||
|
||||
if ( object == 0 )
|
||||
{
|
||||
failure_response(NO_EXISTS,
|
||||
get_error(object_name(auth_object),oid),
|
||||
att);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Datastore::DatastoreType prev_type = object->get_type();
|
||||
Datastore::DatastoreType new_type = Datastore::type_in_template(tmpl);
|
||||
|
||||
int cluster_id = object->get_cluster_id();
|
||||
|
||||
if ( (prev_type == Datastore::SYSTEM_DS || new_type == Datastore::SYSTEM_DS) &&
|
||||
prev_type != new_type &&
|
||||
cluster_id != ClusterPool::NONE_CLUSTER_ID )
|
||||
{
|
||||
object->unlock();
|
||||
|
||||
Cluster *cluster = Nebula::instance().get_clpool()->get(cluster_id, true);
|
||||
|
||||
if ( cluster == 0 )
|
||||
{
|
||||
failure_response(NO_EXISTS,
|
||||
get_error(object_name(PoolObjectSQL::CLUSTER),cluster_id),
|
||||
att);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( new_type == Datastore::SYSTEM_DS )
|
||||
{
|
||||
if ( cluster->get_ds_id() == DatastorePool::SYSTEM_DS_ID )
|
||||
{
|
||||
// Cluster has a new system ds
|
||||
cluster->set_ds_id(oid);
|
||||
}
|
||||
else
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "Cannot change datastore type to "
|
||||
<< Datastore::type_to_str(Datastore::SYSTEM_DS)
|
||||
<< ". Cluster " << cluster_id
|
||||
<< " already contains the System Datastore "
|
||||
<< cluster->get_ds_id() << ".";
|
||||
|
||||
failure_response(INTERNAL,
|
||||
request_error(oss.str(),error_str),
|
||||
att);
|
||||
|
||||
cluster->unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ( cluster->get_ds_id() == oid )
|
||||
{
|
||||
// This was the cluster's system DS, now it must be set to '0'
|
||||
cluster->set_ds_id( DatastorePool::SYSTEM_DS_ID );
|
||||
}
|
||||
|
||||
Nebula::instance().get_clpool()->update(cluster);
|
||||
cluster->unlock();
|
||||
|
||||
object = static_cast<DatastorePool*>(pool)->get(oid,true);
|
||||
|
||||
if ( object == 0 )
|
||||
{
|
||||
failure_response(NO_EXISTS,
|
||||
get_error(object_name(auth_object),oid),
|
||||
att);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rc = object->replace_template(tmpl, error_str);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
// TODO: rollback
|
||||
|
||||
failure_response(INTERNAL,
|
||||
request_error("Cannot update template",error_str),
|
||||
att);
|
||||
object->unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pool->update(object);
|
||||
|
||||
object->unlock();
|
||||
|
||||
success_response(oid, att);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user