conga luci/site/luci/Extensions/ricci_communic ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-11-20 22:11:22
Modified files:
luci/site/luci/Extensions: ricci_communicator.py
ricci/ricci : Ricci.cpp
Log message:
add support for determining whether we're a virtual machine to ricci
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.cpp.diff?cvsroot=cluster&r1=1.19&r2=1.20
luci/site/luci/Extensions/ricci_communicator.py +7 -0
@@ -62,6 +62,7 @@ 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
@@ -90,6 +91,10 @@ 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):
@@ -359,6 +364,8 @@ 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):
ricci/ricci/Ricci.cpp +24 -0
@@ -45,6 +45,7 @@ static bool dom0(); +static bool domU(); static String hostname(); static pair<String, String> clusterinfo(); static String os_release();
@@ -88,6 +89,9 @@ header.set_attr("xen_host", dom0() ? "true" : "false"); + + header.set_attr("xen_guest", + domU() ? "true" : "false"); } }
@@ -499,6 +503,26 @@ } } +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() {