From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 20 Nov 2006 22:12:06 -0000 Subject: [Cluster-devel] conga luci/site/luci/Extensions/ricci_communic ... Message-ID: <20061120221206.4677.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Branch: RHEL5 Changes by: rmccabe at sourceware.org 2006-11-20 22:12:06 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&only_with_tag=RHEL5&r1=1.9.2.4&r2=1.9.2.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.18.2.1&r2=1.18.2.2 --- conga/luci/site/luci/Extensions/ricci_communicator.py 2006/11/16 19:34:53 1.9.2.4 +++ conga/luci/site/luci/Extensions/ricci_communicator.py 2006/11/20 22:12:06 1.9.2.5 @@ -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): --- conga/ricci/ricci/Ricci.cpp 2006/10/23 21:13:22 1.18.2.1 +++ conga/ricci/ricci/Ricci.cpp 2006/11/20 22:12:06 1.18.2.2 @@ -45,6 +45,7 @@ static bool dom0(); +static bool domU(); static String hostname(); static pair 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 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() {