[Libvirt-cim] [PATCH 08/15] vlan extension - CIM model - add association Net_VESSSDComponent

Wayne Xia xiawenc at linux.vnet.ibm.com
Wed Dec 7 09:25:41 UTC 2011


add the class Net_VirtualEthernetSwitchSystemSettingDataComponent.

Signed-off-by: Wayne Xia <xiawenc at linux.vnet.ibm.com>
---
 schema/VESSSDComponent.mof          |    8 ++
 schema/VESSSDComponent.registration |    3 +
 src/Virt_VESSSDComponent.c          |  181 +++++++++++++++++++++++++++++++++++
 3 files changed, 192 insertions(+), 0 deletions(-)
 create mode 100644 schema/VESSSDComponent.mof
 create mode 100644 schema/VESSSDComponent.registration
 create mode 100644 src/Virt_VESSSDComponent.c

diff --git a/schema/VESSSDComponent.mof b/schema/VESSSDComponent.mof
new file mode 100644
index 0000000..a96d837
--- /dev/null
+++ b/schema/VESSSDComponent.mof
@@ -0,0 +1,8 @@
+// Copyright IBM Corp. 2011
+
+[Association,
+ Provider("cmpi::Virt_VESSSDComponent")
+]
+class Net_VirtualEthernetSwitchSystemSettingDataComponent : CIM_VirtualSystemSettingDataComponent
+{
+};
diff --git a/schema/VESSSDComponent.registration b/schema/VESSSDComponent.registration
new file mode 100644
index 0000000..0416881
--- /dev/null
+++ b/schema/VESSSDComponent.registration
@@ -0,0 +1,3 @@
+# Copyright IBM Corp. 2011
+# Classname Namespace ProviderName ProviderModule ProviderTypes
+Net_VirtualEthernetSwitchSystemSettingDataComponent root/virt Virt_VESSSDComponent Virt_VESSSDComponent association
diff --git a/src/Virt_VESSSDComponent.c b/src/Virt_VESSSDComponent.c
new file mode 100644
index 0000000..34f2cbc
--- /dev/null
+++ b/src/Virt_VESSSDComponent.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright IBM Corp. 2011
+ *
+ * Authors:
+ *  Wenchao Xia <xiawenc at cn.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 "cmpidt.h"
+#include "cmpift.h"
+#include "cmpimacs.h"
+
+#include <libcmpiutil/libcmpiutil.h>
+#include <libcmpiutil/std_association.h>
+#include "misc_util.h"
+#include "device_parsing.h"
+
+#include "Virt_VESSSD.h"
+#include "Virt_EASD.h"
+#include "svpc_types.h"
+#include "misc_util.h"
+
+static const CMPIBroker *_BROKER;
+
+static CMPIStatus vesssd_to_easd(const CMPIObjectPath *ref,
+                               struct std_assoc_info *info,
+                               struct inst_list *list)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        char *name = NULL;
+
+        if (!match_hypervisor_prefix(ref, info)) {
+                CU_DEBUG("Requested a unexpectted assoc.");
+                goto out;
+        }
+
+       /* the step of creating a vesssd instance is skipped to make it fast */
+        if (!parse_instanceid(ref, NULL, &name)) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to get system name");
+                goto out;
+        }
+
+        s = enum_easds(_BROKER,
+                       name,
+                       ref,
+                       info->properties,
+                       list);
+
+        free(name);
+
+ out:
+        return s;
+}
+
+static CMPIStatus easd_to_vesssd(const CMPIObjectPath *ref,
+                               struct std_assoc_info *info,
+                               struct inst_list *list)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *inst = NULL;
+        const char *id = NULL;
+        char *host = NULL;
+        char *devid = NULL;
+        int ret;
+
+        if (!match_hypervisor_prefix(ref, info)) {
+                CU_DEBUG("Requested a unexpectted assoc.");
+                goto out;
+        }
+
+       /* the step of creating a easd instance is skipped to make it fast */
+        if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Missing InstanceID");
+                goto out;
+        }
+
+        ret = parse_fq_devid(id, &host, &devid);
+        if (!ret) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Invalid InstanceID");
+                goto out;
+        }
+
+        s = get_vesssd_by_name(_BROKER, host, ref, &inst);
+        if (s.rc != CMPI_RC_OK) {
+                goto out;
+        }
+
+        inst_list_add(list, inst);
+
+ out:
+        free(host);
+        free(devid);
+
+        return s;
+}
+
+LIBVIRT_CIM_DEFAULT_MAKEREF()
+
+static char *group_component[] = {
+        "Net_VirtualEthernetSwitchSystemSettingData",
+        NULL
+};
+
+static char *part_component[] = {
+        "Net_EthernetPortAllocationSettingData",
+        NULL
+};
+
+static char *assoc_classname[] = {
+        "Net_VirtualEthernetSwitchSystemSettingDataComponent",
+        NULL
+};
+
+static struct std_assoc forward = {
+        .source_class = (char **)&group_component,
+        .source_prop = "GroupComponent",
+
+        .target_class = (char **)&part_component,
+        .target_prop = "PartComponent",
+
+        .assoc_class = (char **)&assoc_classname,
+
+        .handler = vesssd_to_easd,
+        .make_ref = make_ref
+};
+
+static struct std_assoc backward = {
+        .source_class = (char **)&part_component,
+        .source_prop = "PartComponent",
+
+        .target_class = (char **)&group_component,
+        .target_prop = "GroupComponent",
+
+        .assoc_class = (char **)&assoc_classname,
+
+        .handler = easd_to_vesssd,
+        .make_ref = make_ref
+};
+
+static struct std_assoc *handlers[] = {
+        &forward,
+        &backward,
+        NULL
+};
+
+STDA_AssocMIStub(,
+                 Virt_VESSSDComponent,
+                 _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:
+ */
-- 
1.7.6





More information about the Libvirt-cim mailing list