From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 14 Jul 2008 16:00:19 -0000 Subject: [Cluster-devel] conga ./conga.spec.in.in ricci/modules/rpm/Pac ... Message-ID: <20080714160019.31757.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 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 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 + #include + #include + #include + #include + #include + #include + + #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 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 Virt::get_vm_list(const String &hvURI) { + std::map 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(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(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 + +#define DMIDECODE_PATH "/usr/sbin/dmidecode" +#define DEFAULT_HV_URI "xen:///" + +class Virt { + public: + static std::map 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 + */ + +#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(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 vm_list = Virt::get_vm_list(hypervisor_uri); + + list ids_list; + for ( map::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(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 + +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 @@ + + + + + + + + + + + + + + + + + /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 @@ + + + + + + + + + + + + + + + +