Skip to contentSkip to conversation

conga ./conga.spec.in.in ricci/modules/cluster ...

Cluster-devel [email protected] 1 participant 1 message Mar 19, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Branch: RHEL5
Changes by: rmccabe at sourceware.org 2008-03-19 14:45:34

Modified files:
. : conga.spec.in.in
ricci/modules/cluster: ClusterModule.cpp Makefile Virt.cpp
Virt.h
Added files:
ricci/test_suite/cluster: vm_list.xml

Log message:
Fix bz206570: vm list from ricci

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/conga.spec.in.in.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.45.2.71&r2=1.45.2.72
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterModule.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.4&r2=1.5.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.14.2.4&r2=1.14.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Virt.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.3&r2=1.1.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Virt.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.3&r2=1.1.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/test_suite/cluster/vm_list.xml.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1

conga.spec.in.in +1 -0
@@ -295,6 +295,7 @@
 * Wed Feb 27 2008 Ryan McCabe <[email protected]> 0.12.0-6
 - Fix bz434586 (Resource tree does not display multiple children of a parent correctly)
 - Fix bz304931 (Rich Sybase resource agent configuration support)
+- Fix bz206570 (RFE: vm list from ricci)
 
 * Tue Feb 12 2008 Ryan McCabe <[email protected]> 0.12.0-5
 - Fix bz432533 (Do not attempt to install the cmirror package when shared storage is requested)
ricci/modules/cluster/ClusterModule.cpp +38 -0
@@ -50,6 +50,7 @@
 static VarMap set_xvm_key(const VarMap& args);
 static VarMap get_xvm_key(const VarMap& args);
 static VarMap generate_xvm_key(const VarMap& args);
+static VarMap list_vm(const VarMap& args);
 
 static ApiFcnMap build_fcn_map();
 
@@ -87,6 +88,7 @@
 	api_1_0["get_xvm_key"]			= get_xvm_key;
 	api_1_0["generate_xvm_key"]		= generate_xvm_key;
 	api_1_0["virt_guest"]			= virt_guest;
+	api_1_0["list_vm"]				= list_vm;
 
 
 	ApiFcnMap api_fcn_map;
@@ -233,6 +235,42 @@
 }
 
 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;
+}
+
+VarMap
 delete_xvm_key(const VarMap& args) {
 	Virt::delete_xvm_key();
 	VarMap ret;
ricci/modules/cluster/Makefile +1 -0
@@ -27,6 +27,7 @@
 PARANOID=0
 INCLUDE += -I${top_srcdir}/common/
 CXXFLAGS += -DPARANOIA=$(PARANOID)
+LDFLAGS += -lvirt
 
 ifeq ($(PARANOID), 1)
 	LDFLAGS += ${top_srcdir}/common/paranoid/*.o
ricci/modules/cluster/Virt.cpp +87 -8

105 lines not on this page · raw message

ricci/modules/cluster/Virt.h +3 -0
@@ -20,6 +20,7 @@
 #define __CONGA_MODCLUSTER_VIRT_H
 
 #include "String.h"
+#include <map>
 
 #define XVM_KEY_PATH			"/etc/cluster/fence_xvm.key"
 #define XVM_KEY_MAX_SIZE		4096
@@ -27,9 +28,11 @@
 #define XVM_KEY_DEFAULT_SIZE	4096
 
 #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);
 		static bool delete_xvm_key(void);
 		static bool set_xvm_key(const char *key_base64);

/cvs/cluster/conga/ricci/test_suite/cluster/vm_list.xml,v --> standard output revision 1.1.2.1

- renamed from ricci/test_suite/cluster/vm_list.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="list_vm" />
+</request>
+</module>
+
+</batch>
+</ricci>
+