[PATCH 0 of 2] Added association SAPAvailableForElement (ComputerSystem <-> KVMRedirectionSAP)

This patch depends on the patch which adds the association HostedAccessPoint (HostSystem <-> KVMRedirectionSAP)

# HG changeset patch # User Richard Maciel <richardm@br.ibm.com> # Date 1229118320 7200 # Node ID 04d2277875705735e0c4c76f7235f525b29bdea8 # Parent 35c891ed2c4cbf11005859c6d784d19a47c7e8f5 Added association SAPAvailableForElement (ComputerSystem <-> KVMRedirectionSAP) * Created SAPAvailableForElement.{mof,registration} files * Changed Makefile.am to properly handle mof and registration files Signed-off-by: Richard Maciel <richardm@br.ibm.com> diff -r 35c891ed2c4c -r 04d227787570 Makefile.am --- a/Makefile.am Tue Dec 02 18:07:02 2008 -0200 +++ b/Makefile.am Fri Dec 12 19:45:20 2008 -0200 @@ -53,7 +53,8 @@ schema/GraphicsPool.mof \ schema/InputPool.mof \ schema/HostedAccessPoint.mof \ - schema/ServiceAccessBySAP.mof + schema/ServiceAccessBySAP.mof \ + schema/SAPAvailableForElement.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -75,7 +76,8 @@ schema/RegisteredProfile.mof \ schema/ComputerSystem.mof \ schema/ElementConformsToProfile.mof \ - schema/HostedAccessPoint.mof + schema/HostedAccessPoint.mof \ + schema/SAPAvailableForElement.mof REGS = \ schema/ComputerSystem.registration \ @@ -125,7 +127,8 @@ schema/GraphicsPool.registration \ schema/InputPool.registration \ schema/HostedAccessPoint.registration \ - schema/ServiceAccessBySAP.registration + schema/ServiceAccessBySAP.registration \ + schema/SAPAvailableForElement.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ @@ -138,7 +141,8 @@ schema/HostedService.registration \ schema/HostedDependency.registration \ schema/ElementConformsToProfile.registration \ - schema/HostedAccessPoint.registration + schema/HostedAccessPoint.registration \ + schema/SAPAvailableForElement.registration pkgdata_DATA = $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) pkgdata_SCRIPTS = provider-register.sh diff -r 35c891ed2c4c -r 04d227787570 schema/SAPAvailableForElement.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/SAPAvailableForElement.mof Fri Dec 12 19:45:20 2008 -0200 @@ -0,0 +1,22 @@ +// Copyright IBM Corp. 2007 + +[Association, + Provider("cmpi::Virt_SAPAvailableForElement") +] +class Xen_SAPAvailableForElement : CIM_SAPAvailableForElement +{ +}; + +[Association, + Provider("cmpi::Virt_SAPAvailableForElement") +] +class KVM_SAPAvailableForElement : CIM_SAPAvailableForElement +{ +}; + +[Association, + Provider("cmpi::Virt_SAPAvailableForElement") +] +class LXC_SAPAvailableForElement : CIM_SAPAvailableForElement +{ +}; diff -r 35c891ed2c4c -r 04d227787570 schema/SAPAvailableForElement.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/SAPAvailableForElement.registration Fri Dec 12 19:45:20 2008 -0200 @@ -0,0 +1,8 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_SAPAvailableForElement root/virt Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +KVM_SAPAvailableForElement root/virt Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +LXC_SAPAvailableForElement root/virt Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +Xen_SAPAvailableForElement root/cimv2 Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +KVM_SAPAvailableForElement root/cimv2 Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +LXC_SAPAvailableForElement root/cimv2 Virt_SAPAvailableForElement Virt_SAPAvailableForElement association

INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -75,7 +76,8 @@ schema/RegisteredProfile.mof \ schema/ComputerSystem.mof \ schema/ElementConformsToProfile.mof \ - schema/HostedAccessPoint.mof + schema/HostedAccessPoint.mof \ + schema/SAPAvailableForElement.mof
SAPAvailableForElement does not need to be added to the CIMV2 mof list.
INTEROP_REGS = \ schema/RegisteredProfile.registration \ @@ -138,7 +141,8 @@ schema/HostedService.registration \ schema/HostedDependency.registration \ schema/ElementConformsToProfile.registration \ - schema/HostedAccessPoint.registration + schema/HostedAccessPoint.registration \ + schema/SAPAvailableForElement.registration
Same goes for the CIMV2 registration list.
diff -r 35c891ed2c4c -r 04d227787570 schema/SAPAvailableForElement.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/SAPAvailableForElement.registration Fri Dec 12 19:45:20 2008 -0200 @@ -0,0 +1,8 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_SAPAvailableForElement root/virt Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +KVM_SAPAvailableForElement root/virt Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +LXC_SAPAvailableForElement root/virt Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +Xen_SAPAvailableForElement root/cimv2 Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +KVM_SAPAvailableForElement root/cimv2 Virt_SAPAvailableForElement Virt_SAPAvailableForElement association +LXC_SAPAvailableForElement root/cimv2 Virt_SAPAvailableForElement Virt_SAPAvailableForElement association
This provider doesn't need to be to be registered to the cimv2 namespace. SAPAvailableForElement doesn't associate any cimv2 classes. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Richard Maciel <richardm@br.ibm.com> # Date 1229119081 7200 # Node ID d0a4eae208b634a9814ec68384b2cea267604718 # Parent 04d2277875705735e0c4c76f7235f525b29bdea8 Added association SAPAvailableForElement (ComputerSystem <-> KVMRedirectionSAP) * Added entries in the Makefile.am file to handle Virt_SAPAvailableForElement.c compilation * Created Virt_SAPAvailableForElement.c file Signed-off-by: Richard Maciel <richardm@br.ibm.com> diff -r 04d227787570 -r d0a4eae208b6 src/Makefile.am --- a/src/Makefile.am Fri Dec 12 19:45:20 2008 -0200 +++ b/src/Makefile.am Fri Dec 12 19:58:01 2008 -0200 @@ -74,7 +74,8 @@ libVirt_ConcreteComponent.la \ libVirt_ServiceAffectsElement.la \ libVirt_HostedAccessPoint.la \ - libVirt_ServiceAccessBySAP.la + libVirt_ServiceAccessBySAP.la \ + libVirt_SAPAvailableForElement.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_ComputerSystem_la_DEPENDENCIES = libVirt_VirtualSystemSnapshotService.la @@ -226,3 +227,7 @@ libVirt_HostedAccessPoint_la_SOURCES = Virt_HostedAccessPoint.c libVirt_HostedAccessPoint_la_LIBADD = -lVirt_HostSystem -lVirt_KVMRedirectionSAP +libVirt_SAPAvailableForElement_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_KVMRedirectionSAP.la +libVirt_SAPAvailableForElement_la_SOURCES = Virt_SAPAvailableForElement.c +libVirt_SAPAvailableForElement_la_LIBADD = -lVirt_ComputerSystem -lVirt_KVMRedirectionSAP + diff -r 04d227787570 -r d0a4eae208b6 src/Virt_SAPAvailableForElement.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_SAPAvailableForElement.c Fri Dec 12 19:58:01 2008 -0200 @@ -0,0 +1,158 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Richard Maciel <richardm@br.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <stdbool.h> + +#include "cmpidt.h" +#include "cmpift.h" +#include "cmpimacs.h" + +#include <libcmpiutil/libcmpiutil.h> +#include <libcmpiutil/std_association.h> +#include "misc_util.h" + +#include "Virt_ComputerSystem.h" +#include "Virt_KVMRedirectionSAP.h" + +static const CMPIBroker *_BROKER; + +static CMPIStatus sapavail_to_host(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *instance = NULL; + const char *dom_name; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = get_console_sap_by_ref(_BROKER, ref, &instance); + if (s.rc != CMPI_RC_OK) + goto out; + + s.rc = cu_get_str_path(ref, "SystemName", &dom_name); + if (s.rc != CMPI_RC_OK) + goto out; + + s = get_domain_by_name(_BROKER, ref, dom_name, &instance); + + if (s.rc == CMPI_RC_OK) + inst_list_add(list, instance); + + out: + return s; +} + + +static CMPIStatus host_to_sapavail(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *instance = NULL; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = get_domain_by_ref(_BROKER, ref, &instance); + if (s.rc != CMPI_RC_OK) + goto out; + + s = enum_console_sap(_BROKER, ref, list); + + out: + return s; +} + +LIBVIRT_CIM_DEFAULT_MAKEREF() + +static char* managedelem[] = { + "Xen_ComputerSystem", + "KVM_ComputerSystem", + "LXC_ComputerSystem", + "Linux_ComputerSystem", + NULL +}; + +static char* availablesap[] = { + "Xen_KVMRedirectionSAP", + "KVM_KVMRedirectionSAP", + "LXC_KVMRedirectionSAP", + NULL +}; + +static char* assoc_classname[] = { + "Xen_SAPAvailableForElement", + "KVM_SAPAvailableForElement", + "LXC_SAPAvailableForElement", + NULL +}; + +static struct std_assoc _host_to_sapavail = { + .source_class = (char **)&managedelem, + .source_prop = "ManagedElement", + + .target_class = (char **)&availablesap, + .target_prop = "AvailableSAP", + + .assoc_class = (char **)&assoc_classname, + + .handler = host_to_sapavail, + .make_ref = make_ref +}; + +static struct std_assoc _sapavail_to_host = { + .source_class = (char **)&availablesap, + .source_prop = "AvailableSAP", + + .target_class = (char **)&managedelem, + .target_prop = "ManagedElement", + + .assoc_class = (char **)&assoc_classname, + + .handler = sapavail_to_host, + .make_ref = make_ref +}; + +static struct std_assoc *handlers[] = { + &_host_to_sapavail, + &_sapavail_to_host, + NULL +}; + +STDA_AssocMIStub(, + Virt_SAPAvailableForElement, + _BROKER, + libvirt_cim_init(), + handlers); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */

+static CMPIStatus host_to_sapavail(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *instance = NULL; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = get_domain_by_ref(_BROKER, ref, &instance); + if (s.rc != CMPI_RC_OK) + goto out; + + s = enum_console_sap(_BROKER, ref, list);
This is returning all of the SAPs on the system. You want to return just those SAPs that correspond to the guest reference that is passed in. The output on my system: wbemcli ain -ac KVM_SAPAvailableForElement 'http://localhost/root/virt:KVM_ComputerSystem.CreationClassName="KVM_ComputerSystem",Name="test2"' elm3b41/root/virt:KVM_KVMRedirectionSAP.CreationClassName="KVM_KVMRedirectionSAP",Name="-1:-1",SystemCreationClassName="KVM_ComputerSystem",SystemName="test" elm3b41/root/virt:KVM_KVMRedirectionSAP.CreationClassName="KVM_KVMRedirectionSAP",Name="-1:-1",SystemCreationClassName="KVM_ComputerSystem",SystemName="test2"
+ + out: + return s; +} + +LIBVIRT_CIM_DEFAULT_MAKEREF() + +static char* managedelem[] = { + "Xen_ComputerSystem", + "KVM_ComputerSystem", + "LXC_ComputerSystem", + "Linux_ComputerSystem",
Linux_ComputerSystem isn't needed in this list. It's only needed if you're associating the host class. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Kaitlin Rupert
-
Richard Maciel