conga luci/site/luci/Extensions/ricci_bridge.p ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-11-20 23:10:58
Modified files:
luci/site/luci/Extensions: ricci_bridge.py ricci_communicator.py ricci/modules/cluster: ClusterModule.cpp Makefile
ricci/ricci : Ricci.cpp
Added files:
ricci/modules/cluster: Virt.cpp Virt.h ricci/test_suite/cluster: is_virtual.xml
Log message:
dmidecode needs to read /dev/mem, so it can't run as the ricci user; move it into the cluster module
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Virt.cpp.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Virt.h.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterModule.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Makefile.diff?cvsroot=cluster&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.cpp.diff?cvsroot=cluster&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/test_suite/cluster/is_virtual.xml.diff?cvsroot=cluster&r1=NONE&r2=1.1
luci/site/luci/Extensions/ricci_bridge.py +9 -0
@@ -503,6 +503,15 @@ ricci_xml = rc.batch_run(batch_str) return batchAttemptResult(ricci_xml) +def nodeIsVirtual(rc): + batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="virt_guest"/></request></module>' + + ricci_xml = rc.batch_run(batch_str, async=False) + if not ricci_xml or not ricci_xml.firstChild: + luci_log.debug_verbose('no ricci_xml in nodeIsVirtual') + return None + return ricci_xml.firstChild + def getDaemonStates(rc, dlist): batch_str = '<module name="service"><request API_version="1.0"><function_call name="query"><var mutable="false" name="search" type="list_xml">'
luci/site/luci/Extensions/ricci_communicator.py +0 -8
@@ -62,7 +62,6 @@ self.__reported_hostname = hello.firstChild.getAttribute('hostname') self.__os = hello.firstChild.getAttribute('os') self.__dom0 = hello.firstChild.getAttribute('xen_host') == 'true' - self.__domU = hello.firstChild.getAttribute('xen_guest') == 'true' pass
@@ -91,11 +90,6 @@ luci_log.debug_verbose('RC:dom0: [auth %d] reported system_name = %s for %s' \ % (self.__authed, self.__dom0, self.__hostname)) return self.__dom0 - def domU(self): - luci_log.debug_verbose('RC:domU: [auth %d] reported system_name = %s for %s' \ - % (self.__authed, self.__domU, self.__hostname)) - return self.__domU - def auth(self, password): if self.authed():
@@ -364,8 +358,6 @@ return ricci.os() def ricci_get_dom0(self, ricci): return ricci.dom0() -def ricci_get_domU(self, ricci): - return ricci.domU() def ricci_get_cluster_info(self, ricci): return ricci.cluster_info() def ricci_get_authenticated(self, ricci):
/cvs/cluster/conga/ricci/modules/cluster/Virt.cpp,v --> standard output revision 1.1
- renamed from ricci/modules/cluster/Virt.cpp +40 -0
@@ -0,0 +1,40 @@ +/* + Copyright Red Hat, Inc. 2006 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + MA 02139, USA. +*/ + +#include "Virt.h" +#include "utils.h" + +using namespace std; + +bool Virt::virt_guest(void) { + try { + String out, err; + int status; + vector<String> args; + if (utils::execute(DMIDECODE_PATH, args, out, err, status, false)) + throw command_not_found_error_msg(DMIDECODE_PATH); + if (status != 0) + throw String("dmidecode failed"); + if (out.find("Vendor: Xen") != out.npos) + return true; + if (out.find("Manufacturer: Xen") != out.npos) + return true; + } catch ( ... ) {} + return false; +}
/cvs/cluster/conga/ricci/modules/cluster/Virt.h,v --> standard output revision 1.1
- renamed from ricci/modules/cluster/Virt.h +32 -0
@@ -0,0 +1,32 @@ +/* + Copyright Red Hat, Inc. 2006 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + MA 02139, USA. +*/ + +#ifndef __RICCI_CLUSTER_VIRT_H +#define __RICCI_CLUSTER_VIRT_H + +#include "String.h" + +#define DMIDECODE_PATH "/usr/sbin/dmidecode" + +class Virt { + public: + static bool virt_guest(void); +}; + +#endif
ricci/modules/cluster/ClusterModule.cpp +13 -0
@@ -26,6 +26,7 @@ #include "ClusterStatus.h" #include "Clusvcadm.h" #include "Fence.h" +#include "Virt.h" using namespace std;
@@ -40,6 +41,7 @@ static VarMap fence_node(const VarMap& args); static VarMap start_node(const VarMap& args); static VarMap stop_node(const VarMap& args); +static VarMap virt_guest(const VarMap& args); static ApiFcnMap build_fcn_map();
@@ -68,6 +70,7 @@ api_1_0["start_node"] = start_node; api_1_0["stop_node"] = stop_node; api_1_0["fence_node"] = fence_node; + api_1_0["virt_guest"] = virt_guest; ApiFcnMap api_fcn_map;
@@ -183,6 +186,16 @@ return ret; } +VarMap +virt_guest(const VarMap& args) +{ + Variable var("virt_guest", Virt::virt_guest()); + + VarMap ret; + ret.insert(pair<String, Variable>(var.name(), var)); + return ret; +} + VarMap fence_node(const VarMap& args) {
ricci/modules/cluster/Makefile +2 -1
@@ -21,7 +21,8 @@ ClusterConf.o \ ClusterStatus.o \ Clusvcadm.o \ - Fence.o + Fence.o \ + Virt.o INCLUDE +=
ricci/ricci/Ricci.cpp +0 -24
@@ -45,7 +45,6 @@ static bool dom0(); -static bool domU(); static String hostname(); static pair<String, String> clusterinfo(); static String os_release();
@@ -89,9 +88,6 @@ header.set_attr("xen_host", dom0() ? "true" : "false"); - - header.set_attr("xen_guest", - domU() ? "true" : "false"); } }
@@ -503,26 +499,6 @@ } } -bool domU(void) { - try { - String out, err; - int status; - vector<String> args; - if (utils::execute("/usr/sbin/dmidecode", - args, out, err, status, false)) - { - throw command_not_found_error_msg("/usr/sbin/dmidecode"); - } - if (status != 0) - return false; - if (out.find("Vendor: Xen") != out.npos) - return true; - if (out.find("Manufacturer: Xen") != out.npos) - return true; - } catch ( ... ) {} - return false; -} - bool dom0() {
/cvs/cluster/conga/ricci/test_suite/cluster/is_virtual.xml,v --> standard output revision 1.1
- renamed from ricci/test_suite/cluster/is_virtual.xml +13 -0
@@ -0,0 +1,13 @@ +<?xml version="1.0" ?> +<ricci version="1.0" function="process_batch" async="false"> +<batch> + +<module name="cluster"> +<request sequence="1254" API_version="1.0"> +<function_call name="virt_guest" /> +</request> +</module> + +</batch> +</ricci> +