# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1221690570 25200
# Node ID 63550e063a442892ed4e6565bc8548de392d13c0
# Parent 28647b7ffb5e7021a93b4daa4fd6c4a448b44f56
(#3) Add RedirectionServiceCapabilites.
Put SHARING_MODE value and get_rs() in a header file. get_rs() will be needed for the
console related assocations.
Updates from 1 to 2:
-Remove static from get_rs() in RedirectionService.c
Updates from 2 to 3:
-Remove SHARING_MODE from RedirectionService.h
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 28647b7ffb5e -r 63550e063a44 src/Makefile.am
--- a/src/Makefile.am Mon Sep 15 10:04:53 2008 -0700
+++ b/src/Makefile.am Wed Sep 17 15:29:30 2008 -0700
@@ -20,7 +20,8 @@
Virt_AllocationCapabilities.h \
Virt_VirtualSystemSnapshotService.h \
Virt_VirtualSystemSnapshotServiceCapabilities.h \
- Virt_VSMigrationSettingData.h
+ Virt_VSMigrationSettingData.h \
+ Virt_ConsoleRedirectionService.h
XKUADD = $(top_builddir)/libxkutil/libxkutil.la
diff -r 28647b7ffb5e -r 63550e063a44 src/Virt_ConsoleRedirectionService.c
--- a/src/Virt_ConsoleRedirectionService.c Mon Sep 15 10:04:53 2008 -0700
+++ b/src/Virt_ConsoleRedirectionService.c Wed Sep 17 15:29:30 2008 -0700
@@ -36,6 +36,7 @@
#include <libcmpiutil/std_instance.h>
#include "Virt_HostSystem.h"
+#include "Virt_ConsoleRedirectionService.h"
const static CMPIBroker *_BROKER;
@@ -112,11 +113,11 @@
return s;
}
-static CMPIStatus get_console_rs(const CMPIObjectPath *reference,
- CMPIInstance **_inst,
- const CMPIBroker *broker,
- const CMPIContext *context,
- bool is_get_inst)
+CMPIStatus get_console_rs(const CMPIObjectPath *reference,
+ CMPIInstance **_inst,
+ const CMPIBroker *broker,
+ const CMPIContext *context,
+ bool is_get_inst)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
virConnectPtr conn = NULL;
diff -r 28647b7ffb5e -r 63550e063a44 src/Virt_ConsoleRedirectionService.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_ConsoleRedirectionService.h Wed Sep 17 15:29:30 2008 -0700
@@ -0,0 +1,37 @@
+/*
+ * 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
+ */
+
+CMPIStatus get_console_rs(const CMPIObjectPath *reference,
+ CMPIInstance **_inst,
+ const CMPIBroker *broker,
+ const CMPIContext *context,
+ bool is_get_inst);
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-set-style: "K&R"
+ * tab-width: 8
+ * c-basic-offset: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
+
diff -r 28647b7ffb5e -r 63550e063a44 src/Virt_ConsoleRedirectionServiceCapabilities.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_ConsoleRedirectionServiceCapabilities.c Wed Sep 17 15:29:30 2008 -0700
@@ -0,0 +1,183 @@
+/*
+ * 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 <stdlib.h>
+#include <unistd.h>
+
+#include <cmpidt.h>
+#include <cmpift.h>
+#include <cmpimacs.h>
+
+#include <libcmpiutil/libcmpiutil.h>
+#include <libcmpiutil/std_instance.h>
+
+#include "misc_util.h"
+#include "svpc_types.h"
+
+#include "Virt_ConsoleRedirectionService.h"
+
+const static CMPIBroker *_BROKER;
+
+static CMPIStatus set_inst_properties(const CMPIBroker *broker,
+ const CMPIObjectPath *ref,
+ CMPIInstance *inst)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIBoolean element_edit = false;
+ CMPIArray *array;
+ uint16_t prop_val;
+
+ CMSetProperty(inst, "InstanceID",
+ (CMPIValue *)"ConsoleRedirectionCapabilities",
+ CMPI_chars);
+
+ CMSetProperty(inst, "ElementName",
+ (CMPIValue *)"ConsoleRedirectionCapabilities",
+ CMPI_chars);
+
+ CMSetProperty(inst, "ElementNameEditSupported",
+ (CMPIValue *)&element_edit, CMPI_boolean);
+
+ array = CMNewArray(broker, 1, CMPI_uint16, &s);
+ if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array))
+ goto out;
+
+ prop_val = (uint16_t)CIM_CRS_SHARING_MODE;
+ CMSetArrayElementAt(array, 0, &prop_val, CMPI_uint16);
+
+ CMSetProperty(inst, "SharingModeSupported",
+ (CMPIValue *)&array, CMPI_uint16A);
+
+ out:
+ return s;
+}
+
+static CMPIStatus get_console_rs_caps(const CMPIBroker *broker,
+ const CMPIObjectPath *ref,
+ CMPIInstance **_inst,
+ bool is_get_inst)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
+ virConnectPtr conn = NULL;
+
+ conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ if (conn == NULL) {
+ if (is_get_inst)
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance");
+ goto out;
+ }
+
+ inst = get_typed_instance(broker,
+ pfx_from_conn(conn),
+ "ConsoleRedirectionServiceCapabilities",
+ NAMESPACE(ref));
+ if (inst == NULL) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Can not create instance for %s", CLASSNAME(ref));
+ goto out;
+ }
+
+ s = set_inst_properties(broker, ref, inst);
+
+ if (is_get_inst) {
+ s = cu_validate_ref(broker, ref, inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+ }
+
+ *_inst = inst;
+
+ out:
+ virConnectClose(conn);
+
+ return s;
+}
+
+static CMPIStatus return_rs_cap(const CMPIObjectPath *ref,
+ const CMPIResult *results,
+ bool names_only,
+ bool is_get_inst)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
+
+ s = get_console_rs_caps(_BROKER, ref, &inst, is_get_inst);
+ if ((s.rc != CMPI_RC_OK) || (inst == NULL))
+ goto out;
+
+ if (names_only)
+ cu_return_instance_name(results, inst);
+ else
+ CMReturnInstance(results, inst);
+ out:
+ return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference)
+{
+ return return_rs_cap(reference, results, true, false);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference,
+ const char **properties)
+{
+
+ return return_rs_cap(reference, results, false, false);
+}
+
+static CMPIStatus GetInstance(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference,
+ const char **properties)
+{
+ return return_rs_cap(reference, results, false, true);
+}
+
+DEFAULT_CI();
+DEFAULT_MI();
+DEFAULT_DI();
+DEFAULT_EQ();
+DEFAULT_INST_CLEANUP();
+
+STD_InstanceMIStub(,
+ Virt_ConsoleRedirectionServiceCapabilities,
+ _BROKER,
+ libvirt_cim_init());
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-set-style: "K&R"
+ * tab-width: 8
+ * c-basic-offset: 8
+ * indent-tabs-mode: nil
+ * End:
+ */