[PATCH 0 of 2] Add ServiceAffectsElement provider.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1221515077 25200 # Node ID 7c499018323cafaead848167d42acb0688ee5acd # Parent d6aa7cb561858b94c40ba55abafde597949b7478 Schema related changes for ServiceAffectsElement provider. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r d6aa7cb56185 -r 7c499018323c Makefile.am --- a/Makefile.am Mon Sep 29 18:08:15 2008 -0700 +++ b/Makefile.am Mon Sep 15 14:44:37 2008 -0700 @@ -44,7 +44,8 @@ schema/VirtualSystemSnapshotServiceCapabilities.mof \ schema/ConcreteComponent.mof \ schema/ConsoleRedirectionService.mof \ - schema/ConsoleRedirectionServiceCapabilities.mof + schema/ConsoleRedirectionServiceCapabilities.mof \ + schema/ServiceAffectsElement.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -99,7 +100,8 @@ schema/VirtualSystemSnapshotServiceCapabilities.registration \ schema/ConcreteComponent.registration \ schema/ConsoleRedirectionService.registration \ - schema/ConsoleRedirectionServiceCapabilities.registration + schema/ConsoleRedirectionServiceCapabilities.registration \ + schema/ServiceAffectsElement.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r d6aa7cb56185 -r 7c499018323c src/Makefile.am --- a/src/Makefile.am Mon Sep 29 18:08:15 2008 -0700 +++ b/src/Makefile.am Mon Sep 15 14:44:37 2008 -0700 @@ -68,7 +68,8 @@ libVirt_ElementAllocatedFromPool.la \ libVirt_HostedService.la \ libVirt_ElementSettingData.la \ - libVirt_ConcreteComponent.la + libVirt_ConcreteComponent.la \ + libVirt_ServiceAffectsElement.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_ComputerSystem_la_DEPENDENCIES = libVirt_VirtualSystemSnapshotService.la @@ -201,3 +202,7 @@ libVirt_ConsoleRedirectionServiceCapabilities_la_SOURCES = Virt_ConsoleRedirectionServiceCapabilities.c +libVirt_ServiceAffectsElement_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ConsoleRedirectionService.la +libVirt_ServiceAffectsElement_la_SOURCES = Virt_ServiceAffectsElement.c +libVirt_ServiceAffectsElement_la_LIBADD = -lVirt_ComputerSystem -lVirt_ConsoleRedirectionService +

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1221516893 25200 # Node ID d5fea4a670a29b95ef8b7ed46a375a172e8104a7 # Parent 7c499018323cafaead848167d42acb0688ee5acd Add ServiceAffectsElement provider. This provider exposes the association between RedirectionService to ComputerSystem. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 7c499018323c -r d5fea4a670a2 src/Virt_ServiceAffectsElement.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_ServiceAffectsElement.c Mon Sep 15 15:14:53 2008 -0700 @@ -0,0 +1,149 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Kaitlin Rupert <karupert@us.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 <stdio.h> +#include <stdlib.h> +#include <string.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_ConsoleRedirectionService.h" + +const static CMPIBroker *_BROKER; + +static CMPIStatus service_to_cs(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)) + return s; + + s = get_console_rs(ref, &instance, _BROKER, info->context, true); + if (s.rc != CMPI_RC_OK) + return s; + + s = enum_domains(_BROKER, ref, list); + + return s; +} + +static CMPIStatus cs_to_service(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + if (!match_hypervisor_prefix(ref, info)) + return s; + + s = get_domain_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + return s; + + s = get_console_rs(ref, &inst, _BROKER, info->context, false); + if (s.rc != CMPI_RC_OK) + return s; + if (!CMIsNullObject(inst)) + inst_list_add(list, inst); + + return s; +} + +LIBVIRT_CIM_DEFAULT_MAKEREF() + +static char* antecedent[] = { + "Xen_ComputerSystem", + "KVM_ComputerSystem", + "LXC_ComputerSystem", + NULL +}; + +static char* dependent[] = { + "Xen_ConsoleRedirectionService", + "KVM_ConsoleRedirectionService", + "LXC_ConsoleRedirectionService", + NULL +}; + +static char* assoc_classname[] = { + "Xen_ServiceAffectsElement", + "KVM_ServiceAffectsElement", + "LXC_ServiceAffectsElement", + NULL +}; + +static struct std_assoc _cs_to_service = { + .source_class = (char**)&antecedent, + .source_prop = "Antecedent", + + .target_class = (char**)&dependent, + .target_prop = "Dependent", + + .assoc_class = (char**)&assoc_classname, + + .handler = cs_to_service, + .make_ref = make_ref +}; + +static struct std_assoc _service_to_cs = { + .source_class = (char**)&dependent, + .source_prop = "Dependent", + + .target_class = (char**)&antecedent, + .target_prop = "Antecedent", + + .assoc_class = (char**)&assoc_classname, + + .handler = service_to_cs, + .make_ref = make_ref +}; + +static struct std_assoc *handlers[] = { + &_cs_to_service, + &_service_to_cs, + NULL +}; + +STDA_AssocMIStub(, + Virt_ServiceAffectsElement, + _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: + */
participants (1)
-
Kaitlin Rupert