[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/ricci modules/cluster/ClusterModule.cpp ...



CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe sourceware org	2006-11-20 23:15:04

Modified files:
	ricci/modules/cluster: ClusterModule.cpp Makefile 
	ricci/ricci    : Ricci.cpp 
Added files:
	ricci/modules/cluster: Virt.cpp Virt.h 

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/ricci/modules/cluster/Virt.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Virt.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterModule.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5&r2=1.5.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.14&r2=1.14.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.18.2.2&r2=1.18.2.3

/cvs/cluster/conga/ricci/modules/cluster/Virt.cpp,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/cluster/Virt.cpp
+++ -	2006-11-20 23:15:04.985132000 +0000
@@ -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.2.1
--- conga/ricci/modules/cluster/Virt.h
+++ -	2006-11-20 23:15:05.274878000 +0000
@@ -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
--- conga/ricci/modules/cluster/ClusterModule.cpp	2006/10/05 17:38:01	1.5
+++ conga/ricci/modules/cluster/ClusterModule.cpp	2006/11/20 23:15:03	1.5.2.1
@@ -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)
 {
--- conga/ricci/modules/cluster/Makefile	2006/08/16 06:34:19	1.14
+++ conga/ricci/modules/cluster/Makefile	2006/11/20 23:15:03	1.14.2.1
@@ -21,7 +21,8 @@
 	ClusterConf.o \
 	ClusterStatus.o \
 	Clusvcadm.o \
-	Fence.o
+	Fence.o \
+	Virt.o
 
 
 INCLUDE    += 
--- conga/ricci/ricci/Ricci.cpp	2006/11/20 22:12:06	1.18.2.2
+++ conga/ricci/ricci/Ricci.cpp	2006/11/20 23:15:04	1.18.2.3
@@ -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()
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]