1libstoragemgmt.h(0p) libStorageMgmt libstoragemgmt.h(0p)
2
3
4
6 libstoragemgmt.h - Storage Management Library.
7
8
10 #include <libstoragemgmt/libstoragemgmt.h>
11
12
14 LibStorageMgmt is a vendor neutral library that provides an API and
15 tools for managing SAN/NAS/DAS storage. This is a community open source
16 project (LGPL 2.1+ license), providing, but not limited to, the follow‐
17 ing features:
18
19 * List storage pools, volumes, access groups, or file systems.
20
21 * Create and delete volumes, access groups, file systems, or NFS
22 exports.
23
24 * Grant and remove access to volumes, access groups, or initiators.
25
26 * Replicate volumes with snapshots, clones, and copies.
27
28 * Create and delete access groups and edit members of a group.
29
30 * List Linux local SCSI/ATA/NVMe disks.
31
32 * Control IDENT/FAULT LED of local disk via SES(SCSI Enclosure Ser‐
33 vice).
34
35 Full documentation can be found at: http://libstorage.github.io/lib‐
36 storagemgmt-doc/
37
38 The libstoragemgmt provides two type of functions:
39
40 * Plugin level function.
41
42 Plugin functions require libstoragemgmt daemon(lsmd) running and
43 a runtime plugin connection created by lsm_connect_password().
44 Please check section CONNECTION for detail.
45
46
47 * Library level functions.
48
49 Library level functions are functions require no daemon or
50 plugin connection. Functions regarding local disk are all li‐
51 brary level function. Please check section LOCAL DISK for de‐
52 tail.
53
54 All the functions mentioned in this manpage have their own man‐
55 page for detail information.
56
57
59 To use libstoragemgmt in your project:
60
61
62 Add these lines to configure.ac
63
64 PKG_CHECK_MODULES(
65 [LSM], [libstoragemgmt >= 1.3.0],,
66 AC_MSG_ERROR([libstoragemgmt 1.3.0 or newer not found.]))
67
68
69 And similar lines below into your `Makefile.am` file:
70
71 foo_CFLAGS = $(LSM_CFLAGS)
72 foo_LDADD = $(LSM_LIBS)
73
74
75
77 #include <stdio.h>
78 #include <libstoragemgmt/libstoragemgmt.h>
79
80 void error(char *msg, int rc, lsm_error *e)
81 {
82 if( rc ) {
83 printf("%s: error: %d0, msg, rc);
84
85 if( e && lsm_error_message_get(e) ) {
86 printf("Msg: %s0, lsm_error_message_get(e));
87 lsm_error_free(e);
88 }
89 }
90 }
91
92 void list_pools(lsm_connect *c)
93 {
94 lsm_pool **pools = NULL;
95 int rc = 0;
96 uint32_t count = 0;
97
98 rc = lsm_pool_list(c, NULL, NULL, &pools, &count, LSM_FLAG_RSVD);
99 if( LSM_ERR_OK == rc ) {
100 uint32_t i;
101 for( i = 0; i < count; ++i) {
102 printf("pool name: %s freespace: %"PRIu64"0,
103 lsm_pool_name_get(pools[i]),
104 lsm_pool_free_space_get(pools[i]));
105 }
106
107 lsm_pool_record_array_free(pools, count);
108 } else {
109 error("Volume list", rc, lsm_error_last_get(c));
110 }
111 }
112
113 int main()
114 {
115 lsm_connect *c = NULL;
116 lsm_error *e = NULL;
117 int rc = 0;
118
119 const char *uri = "sim://";
120
121 rc = lsm_connect_password(uri, NULL, &c, 30000, &e, LSM_FLAG_RSVD);
122
123 if( LSM_ERR_OK == rc ) {
124 printf("We connected...0);
125
126 list_pools(c);
127
128 rc = lsm_connect_close(c, LSM_FLAG_RSVD);
129 if( LSM_ERR_OK != rc ) {
130 error("Close", rc, lsm_error_last_get(c));
131 } else {
132 printf("We closed0);
133 }
134 } else {
135 error("Connect", rc, e);
136 }
137
138 return rc;
139 }
140
141
143 Explain daemon, plugin, and URI here.
144
145
147 TODO(Gris Ge): Example terminology here.
148
149 Functions:
150
151 lsm_system_list()
152 Query all systems.
153
154
155 lsm_system_record_copy()
156
157
158 lsm_system_record_free()
159
160
161 lsm_system_record_array_free()
162
163
164 lsm_system_id_get()
165
166
167 lsm_system_name_get()
168
169
170 lsm_system_read_cache_pct_get()
171
172
173 lsm_system_status_get()
174
175
176 lsm_system_fw_version_get()
177
178
179 lsm_system_mode_get()
180
181
182
184 TODO
185
186
188 TODO
189
190
192 TODO
193
194
196 TODO
197
198
200 TODO(Gris Ge): Put a simple example on lsm_error string and error num‐
201 ber here.
202
203
205 Please report bugs to <libstoragemgmt-devel@lists.fedorahosted.org> Or
206 https://github.com/libstorage/libstoragemgmt/issues
207
209 Tony Asleson <tasleson@redhat.com>
210 Gris Ge <fge@redhat.com>
211
212
213
214libstoragemgmt.h 1.9.6 September 2014 libstoragemgmt.h(0p)