Plugin method:
* int lsm_system_fw_version_set(lsm_system *s, const char *fw_ver);
Client method:
* int lsm_system_fw_version_get(lsm_system *s, const char **fw_ver);
New capability:
* LSM_CAP_SYS_FW_VERSION_GET
Misc:
* Update license:
* Bump the year number to 2015.
* Add "Hewlett Packard Enterprise Development LP" license line.
* Add Joe Handzik to author list.
Signed-off-by: Joe Handzik <***@hpe.com>
Signed-off-by: Gris Ge <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_capabilities.h | 7 +++-
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 19 +++++++--
.../libstoragemgmt/libstoragemgmt_systems.h | 15 ++++++-
c_binding/lsm_convert.cpp | 21 +++++++++-
c_binding/lsm_datatypes.cpp | 48 +++++++++++++++++++++-
c_binding/lsm_datatypes.hpp | 6 ++-
6 files changed, 108 insertions(+), 8 deletions(-)
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h b/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
index 4d0c351..6f81450 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011-2014 Red Hat, Inc.
+ * Copyright (C) 2011-2015 Red Hat, Inc.
+ * (C) Copyright 2015 Hewlett Packard Enterprise Development LP
* 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
@@ -14,6 +15,8 @@
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*
* Author: tasleson
+ * Joe Handzik <***@hpe.com>
+ * Gris Ge <***@redhat.com>
*/
#ifndef LSM_CAPABILITIES_H
@@ -152,6 +155,8 @@ typedef enum {
LSM_CAP_EXPORT_CUSTOM_PATH = 124,
/**^ Plug-in allows user to define custome export path */
+ LSM_CAP_SYS_FW_VERSION_GET = 160,
+ /**^ Plug-in allows user to retrieve storage firmware version */
LSM_CAP_POOLS_QUICK_SEARCH = 210,
/**^ Seach occurs on array */
LSM_CAP_VOLUMES_QUICK_SEARCH = 211,
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 763c278..7dc4497 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011-2014 Red Hat, Inc.
+ * Copyright (C) 2011-2015 Red Hat, Inc.
+ * (C) Copyright 2015 Hewlett Packard Enterprise Development LP
* 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
@@ -14,6 +15,8 @@
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*
* Author: tasleson
+ * Joe Handzik <***@hpe.com>
+ * Gris Ge <***@redhat.com>
*/
#ifndef LIBSTORAGEMGMT_PLUG_INTERFACE_H
@@ -980,8 +983,6 @@ typedef int (*lsm_plug_volume_raid_create) (lsm_plugin_ptr c,
/** \struct lsm_ops_v1_2
* \brief Functions added in version 1.2
- * NOTE: This structure will change during the developement util version 1.2
- * released.
*/
struct lsm_ops_v1_2 {
lsm_plug_volume_raid_info vol_raid_info;
@@ -1249,6 +1250,18 @@ lsm_system LSM_DLL_EXPORT *lsm_system_record_alloc(const char *id,
const char *plugin_data);
/**
+ * New in version 1.3. Set firmware version.
+ * @param[in] id Id
+ * @param[in] sys System to update.
+ * @param[in] fw_ver Firmware version string.
+ * Caller will get LSM_ERR_INVALID_ARGUMENT for
+ * empty string('\0').
+ * @return LSM_ERR_OK or LSM_ERR_NO_MEMORY or LSM_ERR_INVALID_ARGUMENT.
+ */
+int LSM_DLL_EXPORT lsm_system_fw_version_set(lsm_system *sys,
+ const char *fw_ver);
+
+/**
* Retrieve plugin private data
* @param s System
* @return Optional data, NULL if none exist
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_systems.h b/c_binding/include/libstoragemgmt/libstoragemgmt_systems.h
index 5664a92..1d3f278 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_systems.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_systems.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011-2014 Red Hat, Inc.
+ * Copyright (C) 2011-2015 Red Hat, Inc.
+ * (C) Copyright 2015 Hewlett Packard Enterprise Development LP
* 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
@@ -14,6 +15,8 @@
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*
* Author: tasleson
+ * Joe Handzik <***@hpe.com>
+ * Gris Ge <***@redhat.com>
*/
#ifndef LIBSTORAGEMGMT_SYSTEMS_H
#define LIBSTORAGEMGMT_SYSTEMS_H
@@ -74,6 +77,16 @@ const char LSM_DLL_EXPORT *lsm_system_name_get(lsm_system *s);
*/
uint32_t LSM_DLL_EXPORT lsm_system_status_get(lsm_system *s);
+/**
+ * New in version 1.3. Retrieves firmware version of the specified system.
+ * Do not free returned string, free the struct 'lsm_system' instead.
+ * @param s System to retrieve firmware version for.
+ * @param[out] fw_ver Firmware version string.
+ * @return LSM_ERR_OK on success, or LSM_ERR_NO_SUPPORT, or
+ * LSM_ERR_INVALID_ARGUMENT.
+ */
+int LSM_DLL_EXPORT lsm_system_fw_version_get(lsm_system *s,
+ const char **fw_ver);
#ifdef __cplusplus
}
diff --git a/c_binding/lsm_convert.cpp b/c_binding/lsm_convert.cpp
index 68981c0..ce7c29b 100644
--- a/c_binding/lsm_convert.cpp
+++ b/c_binding/lsm_convert.cpp
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011-2014 Red Hat, Inc.
+ * Copyright (C) 2011-2015 Red Hat, Inc.
+ * (C) Copyright 2015 Hewlett Packard Enterprise Development LP
* 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
@@ -14,12 +15,17 @@
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*
* Author: tasleson
+ * Joe Handzik <***@hpe.com>
+ * Gris Ge <***@redhat.com>
*/
#include "lsm_convert.hpp"
#include "libstoragemgmt/libstoragemgmt_accessgroups.h"
#include "libstoragemgmt/libstoragemgmt_blockrange.h"
#include "libstoragemgmt/libstoragemgmt_nfsexport.h"
+#include "libstoragemgmt/libstoragemgmt_plug_interface.h"
+
+#define _STD_MAP_HAS_KEY(x, y) (x).find((y)) != (x).end()
bool is_expected_object(Value & obj, std::string class_name)
{
@@ -260,6 +266,17 @@ lsm_system *value_to_system(Value & system)
i["status"].asUint32_t(),
i["status_info"].asString().c_str(),
i["plugin_data"].asC_str());
+ if ((rc != NULL) && (_STD_MAP_HAS_KEY(i, "fw_version") == 1) &&
+ (i["fw_version"].asC_str()[0] != '\0')) {
+
+ if (lsm_system_fw_version_set(rc, i["fw_version"].asC_str()) !=
+ LSM_ERR_OK) {
+ lsm_system_record_free(rc);
+ rc= NULL;
+ throw ValueException("value_to_system: failed to update "
+ "fw_version");
+ }
+ }
} else {
throw ValueException("value_to_system: Not correct type");
}
@@ -276,6 +293,8 @@ Value system_to_value(lsm_system * system)
s["status"] = Value(system->status);
s["status_info"] = Value(system->status_info);
s["plugin_data"] = Value(system->plugin_data);
+ if (system->fw_version != NULL)
+ s["fw_version"] = Value(system->fw_version);
return Value(s);
}
return Value();
diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index 8218db3..f81f0eb 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011-2014 Red Hat, Inc.
+ * Copyright (C) 2011-2015 Red Hat, Inc.
+ * (C) Copyright 2015 Hewlett Packard Enterprise Development LP
* 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
@@ -14,6 +15,8 @@
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*
* Author: tasleson
+ * Joe Handzik <***@hpe.com>
+ * Gris Ge <***@redhat.com>
*/
#ifndef __cplusplus
@@ -37,6 +40,7 @@
#include "libstoragemgmt/libstoragemgmt_targetport.h"
#include "libstoragemgmt/libstoragemgmt_types.h"
#include "libstoragemgmt/libstoragemgmt_volumes.h"
+#include "libstoragemgmt/libstoragemgmt_plug_interface.h"
#include <string.h>
#include <stdlib.h>
@@ -724,6 +728,7 @@ lsm_system *lsm_system_record_alloc(const char *id, const char *name,
rc->name = strdup(name);
rc->status = status;
rc->status_info = strdup(status_info);
+ rc->fw_version = NULL;
if (plugin_data) {
rc->plugin_data = strdup(plugin_data);
@@ -760,6 +765,9 @@ int lsm_system_record_free(lsm_system * s)
free(s->plugin_data);
+ if (s->fw_version != NULL)
+ free((char *) s->fw_version);
+
free(s);
return LSM_ERR_OK;
}
@@ -775,6 +783,12 @@ lsm_system *lsm_system_record_copy(lsm_system * s)
if (LSM_IS_SYSTEM(s)) {
rc = lsm_system_record_alloc(s->id, s->name, s->status, s->status_info,
s->plugin_data);
+
+ if ((s->fw_version != NULL) &&
+ (lsm_system_fw_version_set(rc, s->fw_version) != LSM_ERR_OK)) {
+ lsm_system_record_free(rc);
+ rc = NULL;
+ }
}
return rc;
}
@@ -803,6 +817,38 @@ uint32_t lsm_system_status_get(lsm_system * s)
return UINT32_MAX;
}
+int lsm_system_fw_version_set(lsm_system *sys, const char *fw_ver)
+{
+ if ((sys == NULL) || (fw_ver == NULL) || (fw_ver[0] == '\0'))
+ return LSM_ERR_INVALID_ARGUMENT;
+
+ if (sys->fw_version != NULL)
+ free((char *) sys->fw_version);
+
+ sys->fw_version = strdup(fw_ver);
+ if (sys->fw_version == NULL)
+ return LSM_ERR_NO_MEMORY;
+
+ return LSM_ERR_OK;
+}
+
+int lsm_system_fw_version_get(lsm_system *s, const char **fw_ver)
+{
+ if ((s == NULL) || (fw_ver == NULL))
+ return LSM_ERR_INVALID_ARGUMENT;
+
+ if (! LSM_IS_SYSTEM(s)) {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+
+ *fw_ver = s->fw_version;
+
+ if (s->fw_version[0] != '\0' )
+ return LSM_ERR_OK;
+ else
+ return LSM_ERR_NO_SUPPORT;
+}
+
MEMBER_FUNC_GET(const char *, lsm_system_plugin_data_get, lsm_system * s,
s, LSM_IS_SYSTEM, plugin_data, NULL)
diff --git a/c_binding/lsm_datatypes.hpp b/c_binding/lsm_datatypes.hpp
index 558dce0..02472e3 100644
--- a/c_binding/lsm_datatypes.hpp
+++ b/c_binding/lsm_datatypes.hpp
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011-2014 Red Hat, Inc.
+ * Copyright (C) 2011-2015 Red Hat, Inc.
+ * (C) Copyright 2015 Hewlett Packard Enterprise Development LP
* 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
@@ -14,6 +15,8 @@
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*
* Author: tasleson
+ * Joe Handzik <***@hpe.com>
+ * Gris Ge <***@redhat.com>
*/
#ifndef LSM_DATATYPES_H
@@ -162,6 +165,7 @@ struct _lsm_system {
uint32_t status; /**< Enumerated status value */
char *status_info; /**< System status text */
char *plugin_data; /**< Reserved for the plugin to use */
+ const char *fw_version; /**< Firmware version */
};
#define LSM_CONNECT_MAGIC 0xAA7A000A
--
1.8.3.1