cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga ./conga.spec.in.in ricci/modules/rpm/Pac ...
@ 2006-12-13 19:33 kupcevic
  0 siblings, 0 replies; 3+ messages in thread
From: kupcevic @ 2006-12-13 19:33 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-12-13 19:33:14

Modified files:
	.              : conga.spec.in.in 
	ricci/modules/rpm: PackageHandler.cpp 

Log message:
	Fixed bz214989 (Package download not working for Conga during cluster creation)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/conga.spec.in.in.diff?cvsroot=cluster&r1=1.60&r2=1.61
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/PackageHandler.cpp.diff?cvsroot=cluster&r1=1.10&r2=1.11

--- conga/conga.spec.in.in	2006/12/12 13:11:51	1.60
+++ conga/conga.spec.in.in	2006/12/13 19:33:14	1.61
@@ -284,7 +284,7 @@
 
 %changelog
 
-* Tue Dec 12 2006 Stanko Kupcevic <kupcevic@redhat.com> 0.9.1-2
+* Wed Dec 13 2006 Stanko Kupcevic <kupcevic@redhat.com> 0.9.1-2
 
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 XXXXXXXXXXXXXXXXXXX UPDATE NOT RELEASED YET XXXXXXXXXXXXXXXXXXX
@@ -298,6 +298,7 @@
 - Fixed bz218941 (Conga/luci - cannot add node to cluster via luci web app)
 - Fixed bz219156 (Errors in performing node-specific tasks due to ricci outage not reflected in luci display)
 - Fixed bz217703 (clustered vg creation fails)
+- Fixed bz214989 (Package download not working for Conga during cluster creation)
 
 
 
--- conga/ricci/modules/rpm/PackageHandler.cpp	2006/10/23 18:43:36	1.10
+++ conga/ricci/modules/rpm/PackageHandler.cpp	2006/12/13 19:33:14	1.11
@@ -34,7 +34,6 @@
 #define RPM_PATH       "/bin/rpm"
 #define UP2DATE_PATH   "/usr/sbin/up2date-nox"
 #define YUM_PATH       "/usr/bin/yum"
-#define UNAME_PATH     "/bin/uname"
 
 
 static bool 
@@ -60,14 +59,13 @@
 bool
 PackageInstaller::available()
 {
-  if (RHEL4 || RHEL5) {
+  if (RHEL4) {
     bool rhn_available = true;
-    // check existance of /etc/sysconfig/rhn/systemid
+    // check existence of /etc/sysconfig/rhn/systemid
     if (access("/etc/sysconfig/rhn/systemid", F_OK))
       rhn_available = false;
-    // check if there are subscribed channels
-    if (rhn_available && 
-	RHEL4) {
+    // check for subscribed channels
+    if (rhn_available) {
       String out, err;
       int status;
       vector<String> args;
@@ -78,8 +76,8 @@
 	rhn_available = false;
     }
     return rhn_available;
-  } else if (FC5 || FC6) {
-    // nothing to check for, maybe ping repository???
+  } else if (FC5 || FC6 || RHEL5) {
+    // nothing to check for, maybe ping repositories???
     return true;
   } else
     return false;
@@ -156,8 +154,8 @@
     return true;
   
   if (RHEL4) {
-    // TODO: fix up2date handling
     
+    // TODO: fix up2date handling
     throw String("RHEL4 not supported, yet");
     
     String out, err;
@@ -314,7 +312,6 @@
 {
   set_release();
   
-  
   // get installed packages
   
   String out, err;
@@ -419,19 +416,11 @@
     set.packages.push_back("dlm");
     set.packages.push_back("fence");
     
-    // find kernel type
-    String out, err;
-    int status;
-    vector<String> args;
-    args.push_back("-r");
-    if (utils::execute(UNAME_PATH, args, out, err, status, true))
-      throw command_not_found_error_msg(UNAME_PATH);
-    if (status != 0)
-      throw String("uname -r failed");
-    if (out.find("smp") != out.npos) {
+    String kernel(utils::strip(File::open("/proc/sys/kernel/osrelease")));
+    if (kernel.find("smp") != kernel.npos) {
       set.packages.push_back("cman-kernel-smp");
       set.packages.push_back("dlm-kernel-smp");
-    } else if (out.find("hugemem") != out.npos) {
+    } else if (kernel.find("hugemem") != kernel.npos) {
       set.packages.push_back("cman-kernel-hugemen");
       set.packages.push_back("dlm-kernel-hugemem");
     } else {
@@ -475,34 +464,28 @@
 PackageSet
 PackageHandler::build_cluster_storage_set()
 {
+  String kernel(utils::strip(File::open("/proc/sys/kernel/osrelease")));
+  
   PackageSet set("Clustered Storage");
   set.packages.push_back("lvm2-cluster");
-
+  
   if (RHEL4 || FC5) {
     set.packages.push_back("GFS");
-    
-    // find kernel type
-    String out, err;
-    int status;
-    vector<String> args;
-    args.push_back("-r");
-    if (utils::execute(UNAME_PATH, args, out, err, status, true))
-      throw command_not_found_error_msg(UNAME_PATH);
-    if (status != 0)
-      throw String("uname -r failed");
-    if (out.find("smp") != out.npos) {
+    if (kernel.find("smp") != kernel.npos) {
       set.packages.push_back("GFS-kernel-smp");
-    } else if (out.find("hugemem") != out.npos) {
+    } else if (kernel.find("hugemem") != kernel.npos) {
       set.packages.push_back("GFS-kernel-hugemem");
     } else {
       set.packages.push_back("GFS-kernel");
     }
   } else if (RHEL5 || FC6) {
     set.packages.push_back("gfs2-utils");
-    // GFS1 not present on FC6
     if (RHEL5) {
       set.packages.push_back("gfs-utils");
-      set.packages.push_back("kmod-gfs");
+      if (kernel.find("xen") == kernel.npos)
+	set.packages.push_back("kmod-gfs");
+      else
+	set.packages.push_back("kmod-gfs-xen");
     }
   }
   
@@ -593,7 +576,7 @@
     String name(iter->name);
     map<String, PackageSet>::iterator set_iter = h_pre.sets().find(name);
     if (set_iter == h_pre.sets().end())
-      throw String("set ") + name + " present neither locally nor in repository";
+      throw String("packages of set ") + name + " present neither locally nor in repository";
     else {
       PackageSet& p_set = set_iter->second;
       if (p_set.installed) {
@@ -651,9 +634,7 @@
       RHEL4 = true;
     else if (release.find("Bordeaux") != release.npos)
       FC5 = true;
-    else if (release.find("Fedora Core") != release.npos &&
-	     release.find("6") != release.npos)
-      // TODO: get real FC6 codename
+    else if (release.find("Zod") != release.npos)
       FC6 = true;
     else if (release.find("Tikanga") != release.npos)
       RHEL5 = true;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Cluster-devel] conga ./conga.spec.in.in ricci/modules/rpm/Pac ...
@ 2006-12-13 20:27 kupcevic
  0 siblings, 0 replies; 3+ messages in thread
From: kupcevic @ 2006-12-13 20:27 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	kupcevic at sourceware.org	2006-12-13 20:27:40

Modified files:
	.              : conga.spec.in.in 
	ricci/modules/rpm: PackageHandler.cpp 

Log message:
	Fixed bz214989 (Package download not working for Conga during cluster creation)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/conga.spec.in.in.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.45.2.14&r2=1.45.2.15
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/PackageHandler.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.9.2.1&r2=1.9.2.2

--- conga/conga.spec.in.in	2006/12/13 19:21:52	1.45.2.14
+++ conga/conga.spec.in.in	2006/12/13 20:27:40	1.45.2.15
@@ -290,6 +290,7 @@
 XXXXXXXXXXXXXXXXXXX UPDATE NOT RELEASED YET XXXXXXXXXXXXXXXXXXX
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
+- Fixed bz214989 (Package download not working for Conga during cluster creation)
 - 
 
 
--- conga/ricci/modules/rpm/PackageHandler.cpp	2006/10/23 21:13:21	1.9.2.1
+++ conga/ricci/modules/rpm/PackageHandler.cpp	2006/12/13 20:27:40	1.9.2.2
@@ -34,7 +34,6 @@
 #define RPM_PATH       "/bin/rpm"
 #define UP2DATE_PATH   "/usr/sbin/up2date-nox"
 #define YUM_PATH       "/usr/bin/yum"
-#define UNAME_PATH     "/bin/uname"
 
 
 static bool 
@@ -60,14 +59,13 @@
 bool
 PackageInstaller::available()
 {
-  if (RHEL4 || RHEL5) {
+  if (RHEL4) {
     bool rhn_available = true;
-    // check existance of /etc/sysconfig/rhn/systemid
+    // check existence of /etc/sysconfig/rhn/systemid
     if (access("/etc/sysconfig/rhn/systemid", F_OK))
       rhn_available = false;
-    // check if there are subscribed channels
-    if (rhn_available && 
-	RHEL4) {
+    // check for subscribed channels
+    if (rhn_available) {
       String out, err;
       int status;
       vector<String> args;
@@ -78,8 +76,8 @@
 	rhn_available = false;
     }
     return rhn_available;
-  } else if (FC5 || FC6) {
-    // nothing to check for, maybe ping repository???
+  } else if (FC5 || FC6 || RHEL5) {
+    // nothing to check for, maybe ping repositories???
     return true;
   } else
     return false;
@@ -156,8 +154,8 @@
     return true;
   
   if (RHEL4) {
-    // TODO: fix up2date handling
     
+    // TODO: fix up2date handling
     throw String("RHEL4 not supported, yet");
     
     String out, err;
@@ -314,7 +312,6 @@
 {
   set_release();
   
-  
   // get installed packages
   
   String out, err;
@@ -419,19 +416,11 @@
     set.packages.push_back("dlm");
     set.packages.push_back("fence");
     
-    // find kernel type
-    String out, err;
-    int status;
-    vector<String> args;
-    args.push_back("-r");
-    if (utils::execute(UNAME_PATH, args, out, err, status, true))
-      throw command_not_found_error_msg(UNAME_PATH);
-    if (status != 0)
-      throw String("uname -r failed");
-    if (out.find("smp") != out.npos) {
+    String kernel(utils::strip(File::open("/proc/sys/kernel/osrelease")));
+    if (kernel.find("smp") != kernel.npos) {
       set.packages.push_back("cman-kernel-smp");
       set.packages.push_back("dlm-kernel-smp");
-    } else if (out.find("hugemem") != out.npos) {
+    } else if (kernel.find("hugemem") != kernel.npos) {
       set.packages.push_back("cman-kernel-hugemen");
       set.packages.push_back("dlm-kernel-hugemem");
     } else {
@@ -475,34 +464,28 @@
 PackageSet
 PackageHandler::build_cluster_storage_set()
 {
+  String kernel(utils::strip(File::open("/proc/sys/kernel/osrelease")));
+  
   PackageSet set("Clustered Storage");
   set.packages.push_back("lvm2-cluster");
-
+  
   if (RHEL4 || FC5) {
     set.packages.push_back("GFS");
-    
-    // find kernel type
-    String out, err;
-    int status;
-    vector<String> args;
-    args.push_back("-r");
-    if (utils::execute(UNAME_PATH, args, out, err, status, true))
-      throw command_not_found_error_msg(UNAME_PATH);
-    if (status != 0)
-      throw String("uname -r failed");
-    if (out.find("smp") != out.npos) {
+    if (kernel.find("smp") != kernel.npos) {
       set.packages.push_back("GFS-kernel-smp");
-    } else if (out.find("hugemem") != out.npos) {
+    } else if (kernel.find("hugemem") != kernel.npos) {
       set.packages.push_back("GFS-kernel-hugemem");
     } else {
       set.packages.push_back("GFS-kernel");
     }
   } else if (RHEL5 || FC6) {
     set.packages.push_back("gfs2-utils");
-    // GFS1 not present on FC6
     if (RHEL5) {
       set.packages.push_back("gfs-utils");
-      set.packages.push_back("kmod-gfs");
+      if (kernel.find("xen") == kernel.npos)
+	set.packages.push_back("kmod-gfs");
+      else
+	set.packages.push_back("kmod-gfs-xen");
     }
   }
   
@@ -593,7 +576,7 @@
     String name(iter->name);
     map<String, PackageSet>::iterator set_iter = h_pre.sets().find(name);
     if (set_iter == h_pre.sets().end())
-      throw String("set ") + name + " present neither locally nor in repository";
+      throw String("packages of set ") + name + " present neither locally nor in repository";
     else {
       PackageSet& p_set = set_iter->second;
       if (p_set.installed) {
@@ -651,9 +634,7 @@
       RHEL4 = true;
     else if (release.find("Bordeaux") != release.npos)
       FC5 = true;
-    else if (release.find("Fedora Core") != release.npos &&
-	     release.find("6") != release.npos)
-      // TODO: get real FC6 codename
+    else if (release.find("Zod") != release.npos)
       FC6 = true;
     else if (release.find("Tikanga") != release.npos)
       RHEL5 = true;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Cluster-devel] conga ./conga.spec.in.in ricci/modules/rpm/Pac ...
@ 2008-07-14 16:00 rmccabe
  0 siblings, 0 replies; 3+ messages in thread
From: rmccabe @ 2008-07-14 16:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at sourceware.org	2008-07-14 16:00:13

Modified files:
	.              : conga.spec.in.in 
	ricci/modules/rpm: PackageHandler.cpp 
	ricci/modules/service: ServiceManager.cpp 
Added files:
	ricci/modules/virt: .cvsignore Makefile Virt.cpp Virt.h 
	                    VirtModule.cpp VirtModule.h main.cpp 
	ricci/modules/virt/d-bus: ricci-modvirt.oddjob.conf 
	                          ricci-modvirt.systembus.conf 

Log message:
	fix bz430737

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/conga.spec.in.in.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.45.2.90&r2=1.45.2.91
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/PackageHandler.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.9.2.10&r2=1.9.2.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.8&r2=1.5.2.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/virt/.cvsignore.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/virt/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/virt/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/virt/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/virt/VirtModule.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/virt/VirtModule.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/virt/main.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/virt/d-bus/ricci-modvirt.oddjob.conf.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/virt/d-bus/ricci-modvirt.systembus.conf.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1

--- conga/conga.spec.in.in	2008/07/10 20:59:36	1.45.2.90
+++ conga/conga.spec.in.in	2008/07/14 16:00:10	1.45.2.91
@@ -299,6 +299,7 @@
 - Fix bz446907 (rpm -V luci fails)
 - Fix bz450854 (luci doesn't start because of a missing dep /usr/bin/dc)
 - Fix bz206570 (RFE: vm list from ricci)
+- Fix bz430737 (Conga should install the 'cmirror' package when clustered storage is requested)
 
 * Fri Apr 18 2008 Ryan McCabe <rmccabe@redhat.com> 0.12.0-8
 - Fix bz441580 (conga should install 'sg3_utils' and start service 'scsi_reserve' when scsi fencing is used)
--- conga/ricci/modules/rpm/PackageHandler.cpp	2008/06/13 18:38:40	1.9.2.10
+++ conga/ricci/modules/rpm/PackageHandler.cpp	2008/07/14 16:00:12	1.9.2.11
@@ -506,6 +506,7 @@
 		}
 	} else if (RHEL5 || FC6) {
 		set.packages.push_back("gfs2-utils");
+		set.packages.push_back("cmirror");
 		if (RHEL5) {
 			set.packages.push_back("gfs-utils");
 			if (kernel.find("xen") == kernel.npos) {
--- conga/ricci/modules/service/ServiceManager.cpp	2008/06/13 18:38:40	1.5.2.8
+++ conga/ricci/modules/service/ServiceManager.cpp	2008/07/14 16:00:12	1.5.2.9
@@ -521,11 +521,12 @@
 		servs.push_back("gfs");
 		servs.push_back("scsi_reserve");
 	} else if (RHEL5 || FC6) {
-		descr = "Shared Storage: clvmd, gfs, gfs2";
+		descr = "Shared Storage: clvmd, cmirror, gfs, gfs2";
 		servs.push_back("clvmd");
 		servs.push_back("gfs");
 		servs.push_back("gfs2");
 		servs.push_back("scsi_reserve");
+		servs.push_back("cmirror");
 	}
 	s = ServiceSet(name, descr);
 	if (populate_set(s, servs))
/cvs/cluster/conga/ricci/modules/virt/.cvsignore,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/.cvsignore
+++ -	2008-07-14 16:00:14.665634000 +0000
@@ -0,0 +1,3 @@
+ricci-modvirt
+*.orig
+*.rej
/cvs/cluster/conga/ricci/modules/virt/Makefile,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/Makefile
+++ -	2008-07-14 16:00:14.822845000 +0000
@@ -0,0 +1,56 @@
+################################################################################
+##
+## Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
+##
+## This copyrighted material is made available to anyone wishing to use,
+## modify, copy, or redistribute it subject to the terms and conditions
+## of the GNU General Public License v.2.
+##
+################################################################################
+
+top_srcdir=../..
+UNINSTALL = ${top_srcdir}/scripts/uninstall.pl
+
+include ${top_srcdir}/make/defines.mk
+
+
+TARGET = modvirt
+
+OBJECTS = main.o \
+	VirtModule.o \
+	Virt.o
+
+PARANOID=0
+INCLUDE += -I${top_srcdir}/common/
+CXXFLAGS += -DPARANOIA=$(PARANOID)
+LDFLAGS += -lvirt
+
+ifeq ($(PARANOID), 1)
+	LDFLAGS += ${top_srcdir}/common/paranoid/*.o
+else
+	LDFLAGS += ${top_srcdir}/common/*.o
+endif
+
+all: ${TARGET}
+
+*.o: *.h
+
+install:
+	$(INSTALL_DIR) ${libexecdir}
+	$(INSTALL_BIN) ${TARGET} ${libexecdir}
+	$(INSTALL_DIR) ${sysconfdir}/oddjobd.conf.d
+	$(INSTALL_FILE) d-bus/modvirt.oddjob.conf ${sysconfdir}/oddjobd.conf.d
+	$(INSTALL_DIR) ${sysconfdir}/dbus-1/system.d
+	$(INSTALL_FILE) d-bus/modvirt.systembus.conf ${sysconfdir}/dbus-1/system.d
+
+uninstall:
+
+clean:
+	rm -f $(OBJECTS) $(TARGET)
+
+check:
+
+rebuild: clean all
+
+$(TARGET): $(OBJECTS)
+	$(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
/cvs/cluster/conga/ricci/modules/virt/Virt.cpp,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/Virt.cpp
+++ -	2008-07-14 16:00:17.108405000 +0000
@@ -0,0 +1,132 @@
+/*
+** Copyright (C) Red Hat, Inc. 2006-2008
+**
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License version 2 as
+** published by the Free Software Foundation.
+**
+** 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.
+*/
+
+extern "C" {
+	#include <unistd.h>
+	#include <stdlib.h>
+	#include <fcntl.h>
+	#include <sys/stat.h>
+	#include <string.h>
+	#include <errno.h>
+	#include <libvirt/libvirt.h>
+
+	#include "sys_util.h"
+	#include "base64.h"
+}
+
+#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: " + err);
+		if (out.find("Vendor: Xen") != out.npos)
+			return true;
+		if (out.find("Manufacturer: Xen") != out.npos)
+			return true;
+	} catch ( ... ) {}
+
+	return false;
+}
+
+map<String, String> Virt::get_vm_list(const String &hvURI) {
+	std::map<String, String> vm_list;
+	int i;
+	int ret;
+	int num_doms;
+	virConnectPtr con = NULL;
+
+	con = virConnectOpenReadOnly(hvURI.c_str());
+	if (con == NULL)
+		throw String("unable to connect to virtual machine manager");
+
+
+	num_doms = virConnectNumOfDefinedDomains(con);
+	if (num_doms < 1) {
+		virConnectClose(con);
+		throw String("Unable to get the number of defined domains");
+	}
+
+	if (num_doms > 0) {
+		char **dom = (char **) calloc(num_doms, sizeof(char *));
+		if (!dom) {
+			virConnectClose(con);
+			throw String("Out of memory");
+		}
+
+		ret = virConnectListDefinedDomains(con, dom, num_doms);
+		if (ret < 0) {
+			free(dom);
+			virConnectClose(con);
+			throw String("Unable to list defined domains");
+		}
+
+		for (i = 0 ; i < ret ; i++) {
+			if (dom[i] != NULL) {
+				vm_list.insert(
+					pair<String,String>(String(dom[i]), String("inactive")));
+				free(dom[i]);
+			}
+		}
+
+		free(dom);
+	}
+
+	num_doms = virConnectNumOfDomains(con);
+	if (num_doms < 0) {
+		virConnectClose(con);
+		throw String("Unable to get the number of defined domains");
+	}
+
+	if (num_doms > 0) {
+		int *active_doms = (int *) calloc(sizeof(int), num_doms);
+		ret = virConnectListDomains(con, active_doms, num_doms);
+		if (ret > 0) {
+			for (i = 0 ; i < ret ; i++) {
+				const char *name;
+				if (active_doms[i] == 0) {
+					/* Skip dom0 */
+					continue;
+				}
+
+				virDomainPtr vdp = virDomainLookupByID(con, active_doms[i]);
+				if (vdp == NULL)
+					continue;
+
+				name = virDomainGetName(vdp);
+				if (name != NULL) {
+					vm_list.insert(
+						pair<String,String>(String(name), String("active")));
+				}
+			}
+		}
+		free(active_doms);
+	}
+
+	virConnectClose(con);
+	return vm_list;
+}
/cvs/cluster/conga/ricci/modules/virt/Virt.h,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/Virt.h
+++ -	2008-07-14 16:00:18.151953000 +0000
@@ -0,0 +1,34 @@
+/*
+** Copyright (C) Red Hat, Inc. 2006-2008
+**
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License version 2 as
+** published by the Free Software Foundation.
+**
+** 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 __CONGA_MODCLUSTER_VIRT_H
+#define __CONGA_MODCLUSTER_VIRT_H
+
+#include "String.h"
+#include <map>
+
+#define DMIDECODE_PATH			"/usr/sbin/dmidecode"
+#define DEFAULT_HV_URI			"xen:///"
+
+class Virt {
+	public:
+		static std::map<String, String> get_vm_list(const String& hvURI);
+		static bool virt_guest(void);
+};
+
+#endif
/cvs/cluster/conga/ricci/modules/virt/VirtModule.cpp,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/VirtModule.cpp
+++ -	2008-07-14 16:00:18.295087000 +0000
@@ -0,0 +1,99 @@
+/*
+** Copyright (C) Red Hat, Inc. 2006-2008
+**
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License version 2 as
+** published by the Free Software Foundation.
+**
+** 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.
+*/
+
+/*
+ * Author: Ryan McCabe <rmccabe@redhat.com>
+ */
+
+#include "VirtModule.h"
+#include "Virt.h"
+#include "base64.h"
+
+using namespace std;
+
+static VarMap virt_guest(const VarMap& args);
+static VarMap list_vm(const VarMap& args);
+
+static ApiFcnMap build_fcn_map();
+
+VirtModule::VirtModule() :
+	Module(build_fcn_map())
+{}
+
+VirtModule::~VirtModule()
+{}
+
+ApiFcnMap
+build_fcn_map()
+{
+	FcnMap	api_1_0;
+
+	api_1_0["virt_guest"]			= virt_guest;
+	api_1_0["list_vm"]				= list_vm;
+
+	ApiFcnMap api_fcn_map;
+	api_fcn_map["1.0"] = api_1_0;
+
+	return api_fcn_map;
+}
+
+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
+list_vm(const VarMap& args)
+{
+	String hypervisor_uri = "";
+
+	try {
+		VarMap::const_iterator iter = args.find("hypervisor_uri");
+
+		if (iter != args.end())
+			hypervisor_uri = iter->second.get_string();
+	} catch (String e) {
+		throw APIerror(e);
+	}
+
+	if (!hypervisor_uri.size())
+		hypervisor_uri = String(DEFAULT_HV_URI);
+
+	std::map<String, String> vm_list = Virt::get_vm_list(hypervisor_uri);
+
+	list<XMLObject> ids_list;
+	for (	map<String,String>::iterator iter = vm_list.begin() ;
+			iter != vm_list.end();
+			iter++)
+	{
+		XMLObject id_xml("vm");
+		id_xml.set_attr("domain", String(iter->first));
+		id_xml.set_attr("status", String(iter->second));
+		ids_list.push_back(id_xml);
+	}
+
+	Variable var("vm_list", ids_list);
+	VarMap ret;
+	ret.insert(pair<String, Variable>(var.name(), var));
+	return ret;
+}
/cvs/cluster/conga/ricci/modules/virt/VirtModule.h,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/VirtModule.h
+++ -	2008-07-14 16:00:18.629108000 +0000
@@ -0,0 +1,33 @@
+/*
+** Copyright (C) Red Hat, Inc. 2006-2008
+**
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License version 2 as
+** published by the Free Software Foundation.
+**
+** 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 __CONGA_MODVIRT_VIRTMODULE_H
+#define __CONGA_MODVIRT_VIRTMODULE_H
+
+#include "Module.h"
+
+class VirtModule : public Module
+{
+	public:
+		VirtModule();
+		virtual ~VirtModule();
+
+	private:
+};
+
+#endif
/cvs/cluster/conga/ricci/modules/virt/main.cpp,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/main.cpp
+++ -	2008-07-14 16:00:18.765305000 +0000
@@ -0,0 +1,35 @@
+/*
+** Copyright (C) Red Hat, Inc. 2006-2008
+**
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License version 2 as
+** published by the Free Software Foundation.
+**
+** 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 "VirtModule.h"
+
+#include <iostream>
+
+using namespace std;
+
+int
+main(int argc, char **argv)
+{
+	try {
+		VirtModule m;
+		return stdin_out_module_driver(m, argc, argv);
+	} catch (String e) {
+		cerr << e << endl;
+		return 1;
+	}
+}
/cvs/cluster/conga/ricci/modules/virt/d-bus/ricci-modvirt.oddjob.conf,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/d-bus/ricci-modvirt.oddjob.conf
+++ -	2008-07-14 16:00:18.911408000 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<oddjobconfig>
+	<service name="com.redhat.ricci">
+	<object name="/com/redhat/ricci">
+		<interface name="com.redhat.ricci">
+			<method name="modvirt_rw">
+				<helper exec="/usr/libexec/ricci-modvirt"
+					arguments="1"
+					prepend_user_name="no"
+					argument_passing_method="stdin"
+				/>
+				<allow user="root"/>
+			</method>
+			<method name="modvirt_ro">
+				<helper exec="/usr/libexec/ricci-modvirt_ro"
+					arguments="1"
+					prepend_user_name="no"
+					argument_passing_method="stdin"
+				/>
+				<allow user="root"/>
+			</method>
+		</interface>
+	</object>
+	</service>
+</oddjobconfig>
/cvs/cluster/conga/ricci/modules/virt/d-bus/ricci-modvirt.systembus.conf,v  -->  standard output
revision 1.1.2.1
--- conga/ricci/modules/virt/d-bus/ricci-modvirt.systembus.conf
+++ -	2008-07-14 16:00:19.102216000 +0000
@@ -0,0 +1,25 @@
+<!DOCTYPE busconfig PUBLIC
+	  "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+	  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<busconfig>
+
+	<!-- Only root can own ricci service. -->
+	<policy user="root">
+		<allow own="com.redhat.ricci"/>
+	</policy>
+
+	<!-- Allow anyone to call modvirt_rw and modvirt_ro
+	     methods.  oddjobd performs actual ACL. -->
+	<policy context="default">
+		<allow send_destination="com.redhat.ricci"
+		       send_path="/com/redhat/ricci"
+		       send_interface="com.redhat.ricci"
+		       send_member="modvirt_rw"/>
+		<allow send_destination="com.redhat.ricci"
+		       send_path="/com/redhat/ricci"
+		       send_interface="com.redhat.ricci"
+		       send_member="modvirt_ro"/>
+	</policy>
+
+</busconfig>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-14 16:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-13 20:27 [Cluster-devel] conga ./conga.spec.in.in ricci/modules/rpm/Pac kupcevic
  -- strict thread matches above, loose matches on Subject: below --
2008-07-14 16:00 rmccabe
2006-12-13 19:33 kupcevic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).