From 6ff8972279f678f4fc8e1fd08e8f1047490d914b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 2 Oct 2012 18:54:06 +0200 Subject: [PATCH] Feature #1523: New xmlrpc method one.system.version added to RequestManager --- include/RequestManagerSystem.h | 67 ++++++++++++++++++++++++++++++++++ src/rm/RequestManager.cc | 10 +++++ src/rm/RequestManagerSystem.cc | 39 ++++++++++++++++++++ src/rm/SConstruct | 3 +- 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 include/RequestManagerSystem.h create mode 100644 src/rm/RequestManagerSystem.cc diff --git a/include/RequestManagerSystem.h b/include/RequestManagerSystem.h new file mode 100644 index 0000000000..f774a7759a --- /dev/null +++ b/include/RequestManagerSystem.h @@ -0,0 +1,67 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +#ifndef REQUEST_MANAGER_SYSTEM_H +#define REQUEST_MANAGER_SYSTEM_H + +#include "Request.h" + +using namespace std; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class RequestManagerSystem: public Request +{ +protected: + RequestManagerSystem( const string& method_name, + const string& help, + const string& params) + :Request(method_name,params,help) + {}; + + ~RequestManagerSystem(){}; + + /* -------------------------------------------------------------------- */ + + virtual void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att) = 0; +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class SystemVersion : public RequestManagerSystem +{ +public: + SystemVersion(): + RequestManagerSystem("SystemVersion", + "Returns the OpenNebula version", + "A:s") + {}; + + ~SystemVersion(){}; + + void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att); +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +#endif diff --git a/src/rm/RequestManager.cc b/src/rm/RequestManager.cc index 4c2135785b..341d44d159 100644 --- a/src/rm/RequestManager.cc +++ b/src/rm/RequestManager.cc @@ -37,6 +37,8 @@ #include "RequestManagerCluster.h" #include "RequestManagerGroup.h" +#include "RequestManagerSystem.h" + #include #include #include @@ -362,6 +364,9 @@ void RequestManager::register_xml_methods() xmlrpc_c::methodPtr cluster_addvnet(new ClusterAddVNet()); xmlrpc_c::methodPtr cluster_delvnet(new ClusterDelVNet()); + // System Methods + xmlrpc_c::methodPtr system_version(new SystemVersion()); + /* VM related methods */ RequestManagerRegistry.addMethod("one.vm.deploy", vm_deploy); RequestManagerRegistry.addMethod("one.vm.action", vm_action); @@ -490,6 +495,11 @@ void RequestManager::register_xml_methods() RequestManagerRegistry.addMethod("one.document.clone", doc_clone); RequestManagerRegistry.addMethod("one.documentpool.info",docpool_info); + + /* System related methods */ + RequestManagerRegistry.addMethod("one.system.version", system_version); + + }; /* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerSystem.cc b/src/rm/RequestManagerSystem.cc new file mode 100644 index 0000000000..84d9486e5e --- /dev/null +++ b/src/rm/RequestManagerSystem.cc @@ -0,0 +1,39 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +#include "RequestManagerSystem.h" +#include "Nebula.h" + +using namespace std; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +void SystemVersion::request_execute(xmlrpc_c::paramList const& paramList, + RequestAttributes& att) +{ + // TODO: request_execute will not be executed if the session string + // is not authenticated in Request::execute. + // Should we make the version call accessible even + // if no user is provided? + + success_response(Nebula::instance().db_version(), att); + + return; +} + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ diff --git a/src/rm/SConstruct b/src/rm/SConstruct index 6260123704..4420593001 100644 --- a/src/rm/SConstruct +++ b/src/rm/SConstruct @@ -40,7 +40,8 @@ source_files=[ 'RequestManagerAcl.cc', 'RequestManagerChmod.cc', 'RequestManagerCluster.cc', - 'RequestManagerClone.cc' + 'RequestManagerClone.cc', + 'RequestManagerSystem.cc' ] # Build library