# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1195059870 28800
# Node ID c802d7801234023e14b60f3c2703ec2de063859b
# Parent aad2a74321d54e26b5b2c89dc8df0e95bd1860f8
Adding ElementSettingData association.
This only handles the case defined in section "7.3.4.2 Single-Configuration
Implementation Approach" of the VSP. Will update to handle the case(s) defined in
the Resource Allocation Profile.
The handler name is a bit ugly. I suspect this name will change when I add the RASD
pieces.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r aad2a74321d5 -r c802d7801234 src/Virt_ElementSettingData.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_ElementSettingData.c Wed Nov 14 09:04:30 2007 -0800
@@ -0,0 +1,182 @@
+/*
+ * Copyright IBM Corp. 2007
+ *
+ * Authors:
+ * Kaitlin Rupert <karupert(a)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.h"
+#include "std_association.h"
+#include "misc_util.h"
+
+#include "Virt_VSSD.h"
+
+const static CMPIBroker *_BROKER;
+
+static CMPIStatus get_dom_name_from_ref(const CMPIObjectPath *ref,
+ char **dom_name)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ char *id;
+
+ id = cu_get_str_path(ref, "InstanceID");
+ if (id == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Missing InstanceID");
+ goto out;
+ }
+
+ *dom_name = strdup(strchr(id, ':') + 1);
+ if (*dom_name == NULL)
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Error retrieving domain name.");
+
+ free(id);
+
+out:
+ return s;
+}
+
+static CMPIStatus vssd_to_sd(const CMPIObjectPath *ref,
+ struct std_assoc_info *info,
+ struct inst_list *list)
+{
+ CMPIStatus s;
+ CMPIInstance *inst;
+ virConnectPtr conn = NULL;
+ virDomainPtr dom = NULL;
+ char *host = NULL;
+
+ ASSOC_MATCH(info->provider_name, CLASSNAME(ref));
+
+ s = get_dom_name_from_ref(ref, &host);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ conn = lv_connect(_BROKER, &s);
+ if (conn == NULL)
+ goto out;
+
+ dom = virDomainLookupByName(conn, host);
+ if (dom == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "No such system `%s'", host);
+ goto out;
+ }
+
+ inst = get_vssd_instance(dom, _BROKER, ref);
+ if (inst == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Error getting VSSD for `%s'", host);
+ goto out;
+ }
+
+ inst_list_add(list, inst);
+
+ out:
+ virDomainFree(dom);
+ virConnectClose(conn);
+
+ return s;
+}
+
+static CMPIInstance *make_ref(const CMPIObjectPath *ref,
+ const CMPIInstance *inst,
+ struct std_assoc_info *info,
+ struct std_assoc *assoc)
+{
+ CMPIInstance *refinst = NULL;
+ char *base;
+
+ base = class_base_name(assoc->assoc_class);
+ if (base == NULL)
+ goto out;
+
+ refinst = get_typed_instance(_BROKER,
+ base,
+ NAMESPACE(ref));
+
+ if (refinst != NULL) {
+ CMPIObjectPath *instop;
+
+ instop = CMGetObjectPath(inst, NULL);
+
+ set_reference(assoc, refinst, ref, instop);
+
+ /* Set additional properties with values
+ * defined in the "Virtual System Profile."
+ */
+ set_reference(assoc, refinst, ref, instop);
+ unsigned int lValue = 1;
+ CMSetProperty(refinst, "IsDefault",
+ (CMPIValue *)&lValue, CMPI_uint16);
+
+ CMSetProperty(refinst, "IsNext",
+ (CMPIValue *)&lValue, CMPI_uint16);
+
+ CMSetProperty(refinst, "IsMinimum",
+ (CMPIValue *)&lValue, CMPI_uint16);
+
+ CMSetProperty(refinst, "IsMaximum",
+ (CMPIValue *)&lValue, CMPI_uint16);
+ }
+
+out:
+ return refinst;
+}
+
+static struct std_assoc vssd_to_sd_fd_bkwd = {
+ .source_class = "CIM_VirtualSystemSettingData",
+ .source_prop = "ManagedElement",
+
+ .target_class = "CIM_ManagedElement",
+ .target_prop = "SettingData",
+
+ .assoc_class = "CIM_ElementSettingData",
+
+ .handler = vssd_to_sd,
+ .make_ref = make_ref
+};
+
+static struct std_assoc *handlers[] = {
+ &vssd_to_sd_fd_bkwd,
+ NULL
+};
+
+STDA_AssocMIStub(, Xen_ElementSettingDataProvider, _BROKER, CMNoHook, handlers);
+STDA_AssocMIStub(, KVM_ElementSettingDataProvider, _BROKER, CMNoHook, handlers);
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-set-style: "K&R"
+ * tab-width: 8
+ * c-basic-offset: 8
+ * indent-tabs-mode: nil
+ * End:
+ */