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 plug‐
50 in connection. Functions regarding local disk are all library
51 level function. Please check section LOCAL DISK for detail.
52
53 All the functions mentioned in this manpage have their own man‐
54 page for detail information.
55
56
58 To use libstoragemgmt in your project:
59
60
61 Add these lines to configure.ac
62
63 PKG_CHECK_MODULES(
64 [LSM], [libstoragemgmt >= 1.3.0],,
65 AC_MSG_ERROR([libstoragemgmt 1.3.0 or newer not found.]))
66
67
68 And similar lines below into your `Makefile.am` file:
69
70 foo_CFLAGS = $(LSM_CFLAGS)
71 foo_LDADD = $(LSM_LIBS)
72
73
74
76 #include <stdio.h>
77 #include <libstoragemgmt/libstoragemgmt.h>
78
79 void error(char *msg, int rc, lsm_error *e)
80 {
81 if( rc ) {
82 printf("%s: error: %d0, msg, rc);
83
84 if( e && lsm_error_message_get(e) ) {
85 printf("Msg: %s0, lsm_error_message_get(e));
86 lsm_error_free(e);
87 }
88 }
89 }
90
91 void list_pools(lsm_connect *c)
92 {
93 lsm_pool **pools = NULL;
94 int rc = 0;
95 uint32_t count = 0;
96
97 rc = lsm_pool_list(c, NULL, NULL, &pools, &count, LSM_FLAG_RSVD);
98 if( LSM_ERR_OK == rc ) {
99 uint32_t i;
100 for( i = 0; i < count; ++i) {
101 printf("pool name: %s freespace: %"PRIu64"0,
102 lsm_pool_name_get(pools[i]),
103 lsm_pool_free_space_get(pools[i]));
104 }
105
106 lsm_pool_record_array_free(pools, count);
107 } else {
108 error("Volume list", rc, lsm_error_last_get(c));
109 }
110 }
111
112 int main()
113 {
114 lsm_connect *c = NULL;
115 lsm_error *e = NULL;
116 int rc = 0;
117
118 const char *uri = "sim://";
119
120 rc = lsm_connect_password(uri, NULL, &c, 30000, &e, LSM_FLAG_RSVD);
121
122 if( LSM_ERR_OK == rc ) {
123 printf("We connected...0);
124
125 list_pools(c);
126
127 rc = lsm_connect_close(c, LSM_FLAG_RSVD);
128 if( LSM_ERR_OK != rc ) {
129 error("Close", rc, lsm_error_last_get(c));
130 } else {
131 printf("We closed0);
132 }
133 } else {
134 error("Connect", rc, e);
135 }
136
137 return rc;
138 }
139
140
142 Explain daemon, plugin, and URI here.
143
144
146 TODO(Gris Ge): Example terminology here.
147
148 Functions:
149
150 lsm_system_list()
151 Query all systems.
152
153
154 lsm_system_record_copy()
155
156
157 lsm_system_record_free()
158
159
160 lsm_system_record_array_free()
161
162
163 lsm_system_id_get()
164
165
166 lsm_system_name_get()
167
168
169 lsm_system_read_cache_pct_get()
170
171
172 lsm_system_status_get()
173
174
175 lsm_system_fw_version_get()
176
177
178 lsm_system_mode_get()
179
180
181
183 TODO
184
185
187 TODO
188
189
191 TODO
192
193
195 TODO
196
197
199 TODO(Gris Ge): Put a simple example on lsm_error string and error num‐
200 ber here.
201
202
204 Please report bugs to <libstoragemgmt-devel@lists.fedorahosted.org> Or
205 https://github.com/libstorage/libstoragemgmt/issues
206
208 Tony Asleson <tasleson@redhat.com>
209 Gris Ge <fge@redhat.com>
210
211
212
213libstoragemgmt.h 1.6.2 September 2014 libstoragemgmt.h(0p)