From c523b889f14fc11e2dae97a387e6bfefe405a4e8 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 24 Dec 2012 12:27:53 +0100 Subject: [PATCH] Revert "Bug #1694: If a DS updates its type to system_ds, update the cluster system_ds" This reverts commit ca4504f984d65ed9500dbd08ac530d6b2ae7ed99. --- include/Cluster.h | 10 -- include/Datastore.h | 9 +- include/RequestManagerUpdateTemplate.h | 5 +- src/cli/one_helper/onecluster_helper.rb | 3 +- src/datastore/Datastore.cc | 20 +--- src/rm/RequestManagerUpdateTemplate.cc | 123 ------------------------ 6 files changed, 5 insertions(+), 165 deletions(-) diff --git a/include/Cluster.h b/include/Cluster.h index eeada0ef3c..9f47652c07 100644 --- a/include/Cluster.h +++ b/include/Cluster.h @@ -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. diff --git a/include/Datastore.h b/include/Datastore.h index 6db87fd919..a4b8d4243d 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -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 diff --git a/include/RequestManagerUpdateTemplate.h b/include/RequestManagerUpdateTemplate.h index 07a19e93d3..511f149ce7 100644 --- a/include/RequestManagerUpdateTemplate.h +++ b/include/RequestManagerUpdateTemplate.h @@ -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); }; /* ------------------------------------------------------------------------- */ diff --git a/src/cli/one_helper/onecluster_helper.rb b/src/cli/one_helper/onecluster_helper.rb index 2edb601224..2cd5716f2d 100644 --- a/src/cli/one_helper/onecluster_helper.rb +++ b/src/cli/one_helper/onecluster_helper.rb @@ -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) diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index 1fe0bf2ae6..6e93122920 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -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 ) { diff --git a/src/rm/RequestManagerUpdateTemplate.cc b/src/rm/RequestManagerUpdateTemplate.cc index 6bcfde31a5..1c8988ccbb 100644 --- a/src/rm/RequestManagerUpdateTemplate.cc +++ b/src/rm/RequestManagerUpdateTemplate.cc @@ -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(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(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; -} - -