table of contents
libstoragemgmt.h(0p) | libStorageMgmt | libstoragemgmt.h(0p) |
NAME¶
libstoragemgmt.h - Storage Management Library.
SYNOPSIS¶
#include <libstoragemgmt/libstoragemgmt.h>
DESCRIPTION¶
LibStorageMgmt is a vendor neutral library that provides an API and tools for managing SAN/NAS/DAS storage. This is a community open source project (LGPL 2.1+ license), providing, but not limited to, the following features:
* List storage pools, volumes, access groups, or file systems.
* Create and delete volumes, access groups, file systems, or NFS exports.
* Grant and remove access to volumes, access groups, or initiators.
* Replicate volumes with snapshots, clones, and copies.
* Create and delete access groups and edit members of a group.
* List Linux local SCSI/ATA/NVMe disks.
* Control IDENT/FAULT LED of local disk via SES(SCSI Enclosure Service).
Full documentation can be found at: http://libstorage.github.io/libstoragemgmt-doc/
The libstoragemgmt provides two type of functions:
-
* Plugin level function. -
Plugin functions require libstoragemgmt daemon(lsmd) running and a runtime plugin connection created by lsm_connect_password(). Please check section CONNECTION for detail.
-
* Library level functions. -
Library level functions are functions require no daemon or plugin connection. Functions regarding local disk are all library level function. Please check section LOCAL DISK for detail.
All the functions mentioned in this manpage have their own manpage for detail information.
USAGE¶
To use libstoragemgmt in your project:
- Add these lines to configure.ac
-
PKG_CHECK_MODULES(
[LSM], [libstoragemgmt >= 1.3.0],,
AC_MSG_ERROR([libstoragemgmt 1.3.0 or newer not found.])) - And similar lines below into your `Makefile.am` file:
-
foo_CFLAGS = $(LSM_CFLAGS) foo_LDADD = $(LSM_LIBS)
EXAMPLE¶
#include <stdio.h> #include <libstoragemgmt/libstoragemgmt.h> void error(char *msg, int rc, lsm_error *e) {
if( rc ) {
printf("%s: error: %d0, msg, rc);
if( e && lsm_error_message_get(e) ) {
printf("Msg: %s0, lsm_error_message_get(e));
lsm_error_free(e);
}
} } void list_pools(lsm_connect *c) {
lsm_pool **pools = NULL;
int rc = 0;
uint32_t count = 0;
rc = lsm_pool_list(c, NULL, NULL, &pools, &count, LSM_FLAG_RSVD);
if( LSM_ERR_OK == rc ) {
uint32_t i;
for( i = 0; i < count; ++i) {
printf("pool name: %s freespace: %"PRIu64"0,
lsm_pool_name_get(pools[i]),
lsm_pool_free_space_get(pools[i]));
}
lsm_pool_record_array_free(pools, count);
} else {
error("Volume list", rc, lsm_error_last_get(c));
} } int main() {
lsm_connect *c = NULL;
lsm_error *e = NULL;
int rc = 0;
const char *uri = "sim://";
rc = lsm_connect_password(uri, NULL, &c, 30000, &e, LSM_FLAG_RSVD);
if( LSM_ERR_OK == rc ) {
printf("We connected...0);
list_pools(c);
rc = lsm_connect_close(c, LSM_FLAG_RSVD);
if( LSM_ERR_OK != rc ) {
error("Close", rc, lsm_error_last_get(c));
} else {
printf("We closed0);
}
} else {
error("Connect", rc, e);
}
return rc; }
CONNECTION¶
Explain daemon, plugin, and URI here.
SYSTEM¶
TODO(Gris Ge): Example terminology here.
Functions:
POOL¶
TODO
VOLUME¶
TODO
DISK¶
TODO
LOCAL DISK¶
TODO
ERROR HANDLING¶
TODO(Gris Ge): Put a simple example on lsm_error string and error number here.
BUGS¶
Please report bugs to <libstoragemgmt-devel@lists.fedorahosted.org> Or https://github.com/libstorage/libstoragemgmt/issues
AUTHOR¶
Tony Asleson <tasleson@redhat.com>
Gris Ge <fge@redhat.com>
September 2014 | libstoragemgmt.h 1.9.7 |