Skip to contentSkip to conversation

conga/ricci make/defines.mk.in modules/cluster ...

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

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2008-03-14 19:58:12

Modified files:
ricci/make : defines.mk.in
ricci/modules/cluster: ClusterModule.cpp Makefile Virt.cpp
Virt.h
Added files:
ricci/test_suite/cluster: vm_list.xml

Log message:
Add a call to list available VMs and provide their status (has to work around libvirt bz437216 for now)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/make/defines.mk.in.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterModule.cpp.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Makefile.diff?cvsroot=cluster&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Virt.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Virt.h.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/test_suite/cluster/vm_list.xml.diff?cvsroot=cluster&r1=NONE&r2=1.1

ricci/make/defines.mk.in +1 -1
@@ -33,7 +33,7 @@
 					`pkg-config --cflags libxml-2.0` \
 					`pkg-config --cflags openssl`
 CFLAGS			+= -Wall -Wno-unused -fPIC -O2 -g ${INCLUDE}
-CXXFLAGS		+= -Wall -Wno-unused -fPIC -O2 -g ${INCLUDE}
+CXXFLAGS		+= -Wall -Wno-unused -fPIC -O2 -g ${INCLUDE} -fpermissive
 LDFLAGS			+= -fPIC -lpthread \
 					`pkg-config --libs libxml-2.0` \
 					`pkg-config --libs openssl`
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 +92 -8

110 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

- 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>
+