ruby-libvirt-catphish 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ #ifndef NWFILTER_H
2
+ #define NWFILTER_H
3
+
4
+ void ruby_libvirt_nwfilter_init(void);
5
+
6
+ VALUE ruby_libvirt_nwfilter_new(virNWFilterPtr n, VALUE conn);
7
+
8
+ #endif
@@ -0,0 +1,268 @@
1
+ /*
2
+ * secret.c: virSecret methods
3
+ *
4
+ * Copyright (C) 2010 Red Hat Inc.
5
+ * Copyright (C) 2013-2016 Chris Lalancette <clalancette@gmail.com>
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ */
21
+
22
+ #include <ruby.h>
23
+ #include <libvirt/libvirt.h>
24
+ #include <libvirt/virterror.h>
25
+ #include "common.h"
26
+ #include "connect.h"
27
+ #include "extconf.h"
28
+
29
+ #if HAVE_TYPE_VIRSECRETPTR
30
+ static VALUE c_secret;
31
+
32
+ static void secret_free(void *s)
33
+ {
34
+ ruby_libvirt_free_struct(Secret, s);
35
+ }
36
+
37
+ static virSecretPtr secret_get(VALUE s)
38
+ {
39
+ ruby_libvirt_get_struct(Secret, s);
40
+ }
41
+
42
+ VALUE ruby_libvirt_secret_new(virSecretPtr s, VALUE conn)
43
+ {
44
+ return ruby_libvirt_new_class(c_secret, s, conn, secret_free);
45
+ }
46
+
47
+ /*
48
+ * call-seq:
49
+ * secret.uuid -> String
50
+ *
51
+ * Call virSecretGetUUIDString[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUUIDString]
52
+ * to retrieve the UUID for this secret.
53
+ */
54
+ static VALUE libvirt_secret_uuid(VALUE s)
55
+ {
56
+ ruby_libvirt_generate_uuid(virSecretGetUUIDString,
57
+ ruby_libvirt_connect_get(s), secret_get(s));
58
+ }
59
+
60
+ /*
61
+ * call-seq:
62
+ * secret.usagetype -> Fixnum
63
+ *
64
+ * Call virSecretGetUsageType[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUsageType]
65
+ * to retrieve the usagetype for this secret.
66
+ */
67
+ static VALUE libvirt_secret_usagetype(VALUE s)
68
+ {
69
+ ruby_libvirt_generate_call_int(virSecretGetUsageType,
70
+ ruby_libvirt_connect_get(s),
71
+ secret_get(s));
72
+ }
73
+
74
+ /*
75
+ * call-seq:
76
+ * secret.usageid -> String
77
+ *
78
+ * Call virSecretGetUsageID[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUsageID]
79
+ * to retrieve the usageid for this secret.
80
+ */
81
+ static VALUE libvirt_secret_usageid(VALUE s)
82
+ {
83
+ ruby_libvirt_generate_call_string(virSecretGetUsageID,
84
+ ruby_libvirt_connect_get(s), 0,
85
+ secret_get(s));
86
+ }
87
+
88
+ /*
89
+ * call-seq:
90
+ * secret.xml_desc(flags=0) -> String
91
+ *
92
+ * Call virSecretGetXMLDesc[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetXMLDesc]
93
+ * to retrieve the XML for this secret.
94
+ */
95
+ static VALUE libvirt_secret_xml_desc(int argc, VALUE *argv, VALUE s)
96
+ {
97
+ VALUE flags = RUBY_Qnil;
98
+
99
+ rb_scan_args(argc, argv, "01", &flags);
100
+
101
+ ruby_libvirt_generate_call_string(virSecretGetXMLDesc,
102
+ ruby_libvirt_connect_get(s), 1,
103
+ secret_get(s),
104
+ ruby_libvirt_value_to_uint(flags));
105
+ }
106
+
107
+ /*
108
+ * call-seq:
109
+ * secret.set_value(value, flags=0) -> nil
110
+ *
111
+ * Call virSecretSetValue[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretSetValue]
112
+ * to set a new value in this secret. Deprecated; use secret.value= instead.
113
+ */
114
+ static VALUE libvirt_secret_set_value(int argc, VALUE *argv, VALUE s)
115
+ {
116
+ VALUE flags = RUBY_Qnil, value;
117
+
118
+ rb_scan_args(argc, argv, "11", &value, &flags);
119
+
120
+ StringValue(value);
121
+
122
+ ruby_libvirt_generate_call_nil(virSecretSetValue,
123
+ ruby_libvirt_connect_get(s),
124
+ secret_get(s),
125
+ (unsigned char *)RSTRING_PTR(value),
126
+ RSTRING_LEN(value),
127
+ ruby_libvirt_value_to_uint(flags));
128
+ }
129
+
130
+ /*
131
+ * call-seq:
132
+ * secret.value = value,flags=0
133
+ *
134
+ * Call virSecretSetValue[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretSetValue]
135
+ * to set a new value in this secret.
136
+ */
137
+ static VALUE libvirt_secret_value_equal(VALUE s, VALUE in)
138
+ {
139
+ VALUE flags, value;
140
+
141
+ if (TYPE(in) == T_STRING) {
142
+ value = in;
143
+ flags = INT2NUM(0);
144
+ }
145
+ else if (TYPE(in) == T_ARRAY) {
146
+ if (RARRAY_LEN(in) != 2) {
147
+ rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
148
+ RARRAY_LEN(in));
149
+ }
150
+ value = rb_ary_entry(in, 0);
151
+ flags = rb_ary_entry(in, 1);
152
+ }
153
+ else {
154
+ rb_raise(rb_eTypeError,
155
+ "wrong argument type (expected Number or Array)");
156
+ }
157
+
158
+ StringValue(value);
159
+
160
+ ruby_libvirt_generate_call_nil(virSecretSetValue,
161
+ ruby_libvirt_connect_get(s),
162
+ secret_get(s),
163
+ (unsigned char *)RSTRING_PTR(value),
164
+ RSTRING_LEN(value), NUM2UINT(flags));
165
+ }
166
+
167
+ /*
168
+ * call-seq:
169
+ * secret.value(flags=0) -> String
170
+ *
171
+ * Call virSecretGetValue[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetValue]
172
+ * to retrieve the value from this secret.
173
+ */
174
+ static VALUE libvirt_secret_value(int argc, VALUE *argv, VALUE s)
175
+ {
176
+ VALUE flags = RUBY_Qnil, ret;
177
+ unsigned char *val;
178
+ size_t value_size;
179
+ int exception = 0;
180
+ struct ruby_libvirt_str_new_arg args;
181
+
182
+ rb_scan_args(argc, argv, "01", &flags);
183
+
184
+ val = virSecretGetValue(secret_get(s), &value_size,
185
+ ruby_libvirt_value_to_uint(flags));
186
+
187
+ ruby_libvirt_raise_error_if(val == NULL, e_RetrieveError,
188
+ "virSecretGetValue",
189
+ ruby_libvirt_connect_get(s));
190
+
191
+ args.val = (char *)val;
192
+ args.size = value_size;
193
+ ret = rb_protect(ruby_libvirt_str_new_wrap, (VALUE)&args, &exception);
194
+ free(val);
195
+ if (exception) {
196
+ rb_jump_tag(exception);
197
+ }
198
+
199
+ return ret;
200
+ }
201
+
202
+ /*
203
+ * call-seq:
204
+ * secret.undefine -> nil
205
+ *
206
+ * Call virSecretUndefine[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretUndefine]
207
+ * to undefine this secret.
208
+ */
209
+ static VALUE libvirt_secret_undefine(VALUE s)
210
+ {
211
+ ruby_libvirt_generate_call_nil(virSecretUndefine,
212
+ ruby_libvirt_connect_get(s),
213
+ secret_get(s));
214
+ }
215
+
216
+ /*
217
+ * call-seq:
218
+ * secret.free -> nil
219
+ *
220
+ * Call virSecretFree[http://www.libvirt.org/html/libvirt-libvirt-secret.html#virSecretFree]
221
+ * to free this secret. After this call the secret object is no longer valid.
222
+ */
223
+ static VALUE libvirt_secret_free(VALUE s)
224
+ {
225
+ ruby_libvirt_generate_call_free(Secret, s);
226
+ }
227
+
228
+ #endif
229
+
230
+ /*
231
+ * Class Libvirt::Secret
232
+ */
233
+ void ruby_libvirt_secret_init(void)
234
+ {
235
+ #if HAVE_TYPE_VIRSECRETPTR
236
+ c_secret = rb_define_class_under(m_libvirt, "Secret", rb_cObject);
237
+
238
+ rb_define_attr(c_secret, "connection", 1, 0);
239
+
240
+ rb_define_const(c_secret, "USAGE_TYPE_VOLUME",
241
+ INT2NUM(VIR_SECRET_USAGE_TYPE_VOLUME));
242
+
243
+ #if HAVE_CONST_VIR_SECRET_USAGE_TYPE_CEPH
244
+ rb_define_const(c_secret, "USAGE_TYPE_CEPH",
245
+ INT2NUM(VIR_SECRET_USAGE_TYPE_CEPH));
246
+ #endif
247
+ #if HAVE_CONST_VIR_SECRET_USAGE_TYPE_ISCSI
248
+ rb_define_const(c_secret, "USAGE_TYPE_ISCSI",
249
+ INT2NUM(VIR_SECRET_USAGE_TYPE_ISCSI));
250
+ #endif
251
+ #if HAVE_CONST_VIR_SECRET_USAGE_TYPE_NONE
252
+ rb_define_const(c_secret, "USAGE_TYPE_NONE",
253
+ INT2NUM(VIR_SECRET_USAGE_TYPE_NONE));
254
+ #endif
255
+
256
+ /* Secret object methods */
257
+ rb_define_method(c_secret, "uuid", libvirt_secret_uuid, 0);
258
+ rb_define_method(c_secret, "usagetype", libvirt_secret_usagetype, 0);
259
+ rb_define_method(c_secret, "usageid", libvirt_secret_usageid, 0);
260
+ rb_define_method(c_secret, "xml_desc", libvirt_secret_xml_desc, -1);
261
+ rb_define_method(c_secret, "set_value", libvirt_secret_set_value, -1);
262
+ rb_define_method(c_secret, "value=", libvirt_secret_value_equal, 1);
263
+ rb_define_method(c_secret, "value", libvirt_secret_value, -1);
264
+ rb_define_alias(c_secret, "get_value", "value");
265
+ rb_define_method(c_secret, "undefine", libvirt_secret_undefine, 0);
266
+ rb_define_method(c_secret, "free", libvirt_secret_free, 0);
267
+ #endif
268
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef SECRET_H
2
+ #define SECRET_H
3
+
4
+ void ruby_libvirt_secret_init(void);
5
+
6
+ VALUE ruby_libvirt_secret_new(virSecretPtr s, VALUE conn);
7
+
8
+ #endif
@@ -0,0 +1,1022 @@
1
+ /*
2
+ * storage.c: virStoragePool and virStorageVolume methods
3
+ *
4
+ * Copyright (C) 2007,2010 Red Hat Inc.
5
+ * Copyright (C) 2013-2016 Chris Lalancette <clalancette@gmail.com>
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ */
21
+
22
+ #include <ruby.h>
23
+ #include <libvirt/libvirt.h>
24
+ #include <libvirt/virterror.h>
25
+ #include "common.h"
26
+ #include "connect.h"
27
+ #include "extconf.h"
28
+ #include "stream.h"
29
+
30
+ #if HAVE_TYPE_VIRSTORAGEVOLPTR
31
+ /* this has to be here (as opposed to below with the rest of the volume
32
+ * stuff) because libvirt_storage_vol_get_pool() relies on it
33
+ */
34
+ static virStorageVolPtr vol_get(VALUE v)
35
+ {
36
+ ruby_libvirt_get_struct(StorageVol, v);
37
+ }
38
+ #endif
39
+
40
+ #if HAVE_TYPE_VIRSTORAGEPOOLPTR
41
+ static VALUE c_storage_pool;
42
+ static VALUE c_storage_pool_info;
43
+
44
+ /*
45
+ * Class Libvirt::StoragePool
46
+ */
47
+
48
+ static void pool_free(void *d)
49
+ {
50
+ ruby_libvirt_free_struct(StoragePool, d);
51
+ }
52
+
53
+ static virStoragePoolPtr pool_get(VALUE p)
54
+ {
55
+ ruby_libvirt_get_struct(StoragePool, p);
56
+ }
57
+
58
+ VALUE pool_new(virStoragePoolPtr p, VALUE conn)
59
+ {
60
+ return ruby_libvirt_new_class(c_storage_pool, p, conn, pool_free);
61
+ }
62
+
63
+ /*
64
+ * call-seq:
65
+ * vol.pool -> Libvirt::StoragePool
66
+ *
67
+ * Call virStoragePoolLookupByVolume[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolLookupByVolume]
68
+ * to retrieve the storage pool for this volume.
69
+ */
70
+ static VALUE libvirt_storage_vol_pool(VALUE v)
71
+ {
72
+ virStoragePoolPtr pool;
73
+
74
+ pool = virStoragePoolLookupByVolume(vol_get(v));
75
+ ruby_libvirt_raise_error_if(pool == NULL, e_RetrieveError,
76
+ "virStoragePoolLookupByVolume",
77
+ ruby_libvirt_connect_get(v));
78
+
79
+ return pool_new(pool, ruby_libvirt_conn_attr(v));
80
+ }
81
+
82
+ /*
83
+ * call-seq:
84
+ * pool.build(flags=0) -> nil
85
+ *
86
+ * Call virStoragePoolBuild[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild]
87
+ * to build this storage pool.
88
+ */
89
+ static VALUE libvirt_storage_pool_build(int argc, VALUE *argv, VALUE p)
90
+ {
91
+ VALUE flags = RUBY_Qnil;
92
+
93
+ rb_scan_args(argc, argv, "01", &flags);
94
+
95
+ ruby_libvirt_generate_call_nil(virStoragePoolBuild,
96
+ ruby_libvirt_connect_get(p),
97
+ pool_get(p),
98
+ ruby_libvirt_value_to_uint(flags));
99
+ }
100
+
101
+ /*
102
+ * call-seq:
103
+ * pool.undefine -> nil
104
+ *
105
+ * Call virStoragePoolUndefine[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolUndefine]
106
+ * to undefine this storage pool.
107
+ */
108
+ static VALUE libvirt_storage_pool_undefine(VALUE p)
109
+ {
110
+ ruby_libvirt_generate_call_nil(virStoragePoolUndefine,
111
+ ruby_libvirt_connect_get(p),
112
+ pool_get(p));
113
+ }
114
+
115
+ /*
116
+ * call-seq:
117
+ * pool.create(flags=0) -> nil
118
+ *
119
+ * Call virStoragePoolCreate[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolCreate]
120
+ * to start this storage pool.
121
+ */
122
+ static VALUE libvirt_storage_pool_create(int argc, VALUE *argv, VALUE p)
123
+ {
124
+ VALUE flags = RUBY_Qnil;
125
+
126
+ rb_scan_args(argc, argv, "01", &flags);
127
+
128
+ ruby_libvirt_generate_call_nil(virStoragePoolCreate,
129
+ ruby_libvirt_connect_get(p),
130
+ pool_get(p),
131
+ ruby_libvirt_value_to_uint(flags));
132
+ }
133
+
134
+ /*
135
+ * call-seq:
136
+ * pool.destroy -> nil
137
+ *
138
+ * Call virStoragePoolDestroy[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy]
139
+ * to shutdown this storage pool.
140
+ */
141
+ static VALUE libvirt_storage_pool_destroy(VALUE p)
142
+ {
143
+ ruby_libvirt_generate_call_nil(virStoragePoolDestroy,
144
+ ruby_libvirt_connect_get(p),
145
+ pool_get(p));
146
+ }
147
+
148
+ /*
149
+ * call-seq:
150
+ * pool.delete(flags=0) -> nil
151
+ *
152
+ * Call virStoragePoolDelete[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDelete]
153
+ * to delete the data corresponding to this data pool. This is a destructive
154
+ * operation.
155
+ */
156
+ static VALUE libvirt_storage_pool_delete(int argc, VALUE *argv, VALUE p)
157
+ {
158
+ VALUE flags = RUBY_Qnil;
159
+
160
+ rb_scan_args(argc, argv, "01", &flags);
161
+
162
+ ruby_libvirt_generate_call_nil(virStoragePoolDelete,
163
+ ruby_libvirt_connect_get(p),
164
+ pool_get(p),
165
+ ruby_libvirt_value_to_uint(flags));
166
+ }
167
+
168
+ /*
169
+ * call-seq:
170
+ * pool.refresh(flags=0) -> nil
171
+ *
172
+ * Call virStoragePoolRefresh[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolRefresh]
173
+ * to refresh the list of volumes in this storage pool.
174
+ */
175
+ static VALUE libvirt_storage_pool_refresh(int argc, VALUE *argv, VALUE p)
176
+ {
177
+ VALUE flags = RUBY_Qnil;
178
+
179
+ rb_scan_args(argc, argv, "01", &flags);
180
+
181
+ ruby_libvirt_generate_call_nil(virStoragePoolRefresh,
182
+ ruby_libvirt_connect_get(p),
183
+ pool_get(p),
184
+ ruby_libvirt_value_to_uint(flags));
185
+ }
186
+
187
+ /*
188
+ * call-seq:
189
+ * pool.name -> String
190
+ *
191
+ * Call virStoragePoolGetName[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetName]
192
+ * to retrieve the name of this storage pool.
193
+ */
194
+ static VALUE libvirt_storage_pool_name(VALUE p)
195
+ {
196
+ ruby_libvirt_generate_call_string(virStoragePoolGetName,
197
+ ruby_libvirt_connect_get(p), 0,
198
+ pool_get(p));
199
+ }
200
+
201
+ /*
202
+ * call-seq:
203
+ * pool.uuid -> String
204
+ *
205
+ * Call virStoragePoolGetUUIDString[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetUUIDString]
206
+ * to retrieve the UUID of this storage pool.
207
+ */
208
+ static VALUE libvirt_storage_pool_uuid(VALUE p)
209
+ {
210
+ ruby_libvirt_generate_uuid(virStoragePoolGetUUIDString,
211
+ ruby_libvirt_connect_get(p), pool_get(p));
212
+ }
213
+
214
+ /*
215
+ * call-seq:
216
+ * pool.info -> Libvirt::StoragePoolInfo
217
+ *
218
+ * Call virStoragePoolGetInfo[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetInfo]
219
+ * to retrieve information about this storage pool.
220
+ */
221
+ static VALUE libvirt_storage_pool_info(VALUE p)
222
+ {
223
+ virStoragePoolInfo info;
224
+ int r;
225
+ VALUE result;
226
+
227
+ r = virStoragePoolGetInfo(pool_get(p), &info);
228
+ ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
229
+ "virStoragePoolGetInfo",
230
+ ruby_libvirt_connect_get(p));
231
+
232
+ result = rb_class_new_instance(0, NULL, c_storage_pool_info);
233
+ rb_iv_set(result, "@state", INT2NUM(info.state));
234
+ rb_iv_set(result, "@capacity", ULL2NUM(info.capacity));
235
+ rb_iv_set(result, "@allocation", ULL2NUM(info.allocation));
236
+ rb_iv_set(result, "@available", ULL2NUM(info.available));
237
+
238
+ return result;
239
+ }
240
+
241
+ /*
242
+ * call-seq:
243
+ * pool.xml_desc(flags=0) -> String
244
+ *
245
+ * Call virStoragePoolGetXMLDesc[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetXMLDesc]
246
+ * to retrieve the XML for this storage pool.
247
+ */
248
+ static VALUE libvirt_storage_pool_xml_desc(int argc, VALUE *argv, VALUE p)
249
+ {
250
+ VALUE flags = RUBY_Qnil;
251
+
252
+ rb_scan_args(argc, argv, "01", &flags);
253
+
254
+ ruby_libvirt_generate_call_string(virStoragePoolGetXMLDesc,
255
+ ruby_libvirt_connect_get(p),
256
+ 1, pool_get(p),
257
+ ruby_libvirt_value_to_uint(flags));
258
+ }
259
+
260
+ /*
261
+ * call-seq:
262
+ * pool.autostart? -> [true|false]
263
+ *
264
+ * Call virStoragePoolGetAutostart[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutostart]
265
+ * to determine whether this storage pool will autostart when libvirtd starts.
266
+ */
267
+ static VALUE libvirt_storage_pool_autostart(VALUE p)
268
+ {
269
+ int r, autostart;
270
+
271
+ r = virStoragePoolGetAutostart(pool_get(p), &autostart);
272
+ ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
273
+ "virStoragePoolGetAutostart",
274
+ ruby_libvirt_connect_get(p));
275
+
276
+ return autostart ? Qtrue : Qfalse;
277
+ }
278
+
279
+ /*
280
+ * call-seq:
281
+ * pool.autostart = [true|false]
282
+ *
283
+ * Call virStoragePoolSetAutostart[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolSetAutostart]
284
+ * to make this storage pool start when libvirtd starts.
285
+ */
286
+ static VALUE libvirt_storage_pool_autostart_equal(VALUE p, VALUE autostart)
287
+ {
288
+ if (autostart != Qtrue && autostart != Qfalse) {
289
+ rb_raise(rb_eTypeError,
290
+ "wrong argument type (expected TrueClass or FalseClass)");
291
+ }
292
+
293
+ ruby_libvirt_generate_call_nil(virStoragePoolSetAutostart,
294
+ ruby_libvirt_connect_get(p),
295
+ pool_get(p), RTEST(autostart) ? 1 : 0);
296
+ }
297
+
298
+ /*
299
+ * call-seq:
300
+ * pool.num_of_volumes -> Fixnum
301
+ *
302
+ * Call virStoragePoolNumOfVolumes[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolNumOfVolumes]
303
+ * to retrieve the number of volumes in this storage pool.
304
+ */
305
+ static VALUE libvirt_storage_pool_num_of_volumes(VALUE p)
306
+ {
307
+ int n;
308
+
309
+ n = virStoragePoolNumOfVolumes(pool_get(p));
310
+ ruby_libvirt_raise_error_if(n < 0, e_RetrieveError,
311
+ "virStoragePoolNumOfVolumes",
312
+ ruby_libvirt_connect_get(p));
313
+
314
+ return INT2NUM(n);
315
+ }
316
+
317
+ /*
318
+ * call-seq:
319
+ * pool.list_volumes -> list
320
+ *
321
+ * Call virStoragePoolListVolumes[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolListVolumes]
322
+ * to retrieve a list of volume names in this storage pools.
323
+ */
324
+ static VALUE libvirt_storage_pool_list_volumes(VALUE p)
325
+ {
326
+ int r, num;
327
+ char **names;
328
+
329
+ num = virStoragePoolNumOfVolumes(pool_get(p));
330
+ ruby_libvirt_raise_error_if(num < 0, e_RetrieveError,
331
+ "virStoragePoolNumOfVolumes",
332
+ ruby_libvirt_connect_get(p));
333
+ if (num == 0) {
334
+ return rb_ary_new2(num);
335
+ }
336
+
337
+ names = alloca(sizeof(char *) * num);
338
+ r = virStoragePoolListVolumes(pool_get(p), names, num);
339
+ ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
340
+ "virStoragePoolListVolumes",
341
+ ruby_libvirt_connect_get(p));
342
+
343
+ return ruby_libvirt_generate_list(r, names);
344
+ }
345
+
346
+ /*
347
+ * call-seq:
348
+ * pool.free -> nil
349
+ *
350
+ * Call virStoragePoolFree[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolFree]
351
+ * to free this storage pool object. After this call the storage pool object
352
+ * is no longer valid.
353
+ */
354
+ static VALUE libvirt_storage_pool_free(VALUE p)
355
+ {
356
+ ruby_libvirt_generate_call_free(StoragePool, p);
357
+ }
358
+ #endif
359
+
360
+ #if HAVE_TYPE_VIRSTORAGEVOLPTR
361
+ /*
362
+ * Libvirt::StorageVol
363
+ */
364
+ static VALUE c_storage_vol;
365
+ static VALUE c_storage_vol_info;
366
+
367
+ static void vol_free(void *d)
368
+ {
369
+ ruby_libvirt_free_struct(StorageVol, d);
370
+ }
371
+
372
+ static VALUE vol_new(virStorageVolPtr v, VALUE conn)
373
+ {
374
+ return ruby_libvirt_new_class(c_storage_vol, v, conn, vol_free);
375
+ }
376
+
377
+ /*
378
+ * call-seq:
379
+ * pool.lookup_volume_by_name(name) -> Libvirt::StorageVol
380
+ *
381
+ * Call virStorageVolLookupByName[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolLookupByName]
382
+ * to retrieve a storage volume object by name.
383
+ */
384
+ static VALUE libvirt_storage_pool_lookup_vol_by_name(VALUE p, VALUE name)
385
+ {
386
+ virStorageVolPtr vol;
387
+
388
+ vol = virStorageVolLookupByName(pool_get(p), StringValueCStr(name));
389
+ ruby_libvirt_raise_error_if(vol == NULL, e_RetrieveError,
390
+ "virStorageVolLookupByName",
391
+ ruby_libvirt_connect_get(p));
392
+
393
+ return vol_new(vol, ruby_libvirt_conn_attr(p));
394
+ }
395
+
396
+ /*
397
+ * call-seq:
398
+ * pool.lookup_volume_by_key(key) -> Libvirt::StorageVol
399
+ *
400
+ * Call virStorageVolLookupByKey[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolLookupByKey]
401
+ * to retrieve a storage volume object by key.
402
+ */
403
+ static VALUE libvirt_storage_pool_lookup_vol_by_key(VALUE p, VALUE key)
404
+ {
405
+ virStorageVolPtr vol;
406
+
407
+ /* FIXME: Why does this take a connection, not a pool? */
408
+ vol = virStorageVolLookupByKey(ruby_libvirt_connect_get(p),
409
+ StringValueCStr(key));
410
+ ruby_libvirt_raise_error_if(vol == NULL, e_RetrieveError,
411
+ "virStorageVolLookupByKey",
412
+ ruby_libvirt_connect_get(p));
413
+
414
+ return vol_new(vol, ruby_libvirt_conn_attr(p));
415
+ }
416
+
417
+ /*
418
+ * call-seq:
419
+ * pool.lookup_volume_by_path(path) -> Libvirt::StorageVol
420
+ *
421
+ * Call virStorageVolLookupByPath[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolLookupByPath]
422
+ * to retrieve a storage volume object by path.
423
+ */
424
+ static VALUE libvirt_storage_pool_lookup_vol_by_path(VALUE p, VALUE path)
425
+ {
426
+ virStorageVolPtr vol;
427
+
428
+ /* FIXME: Why does this take a connection, not a pool? */
429
+ vol = virStorageVolLookupByPath(ruby_libvirt_connect_get(p),
430
+ StringValueCStr(path));
431
+ ruby_libvirt_raise_error_if(vol == NULL, e_RetrieveError,
432
+ "virStorageVolLookupByPath",
433
+ ruby_libvirt_connect_get(p));
434
+
435
+ return vol_new(vol, ruby_libvirt_conn_attr(p));
436
+ }
437
+
438
+ #if HAVE_VIRSTORAGEPOOLLISTALLVOLUMES
439
+ /*
440
+ * call-seq:
441
+ * pool.list_all_volumes(flags=0) -> Array
442
+ *
443
+ * Call virStoragePoolListAllVolumes[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolListAllVolumes]
444
+ * to get an array of volume objects for all volumes.
445
+ */
446
+ static VALUE libvirt_storage_pool_list_all_volumes(int argc, VALUE *argv,
447
+ VALUE p)
448
+ {
449
+ ruby_libvirt_generate_call_list_all(virStorageVolPtr, argc, argv,
450
+ virStoragePoolListAllVolumes,
451
+ pool_get(p), p, vol_new,
452
+ virStorageVolFree);
453
+ }
454
+ #endif
455
+
456
+ /*
457
+ * call-seq:
458
+ * vol.name -> String
459
+ *
460
+ * Call virStorageVolGetName[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetName]
461
+ * to retrieve the name of this storage volume.
462
+ */
463
+ static VALUE libvirt_storage_vol_name(VALUE v)
464
+ {
465
+ ruby_libvirt_generate_call_string(virStorageVolGetName,
466
+ ruby_libvirt_connect_get(v), 0,
467
+ vol_get(v));
468
+ }
469
+
470
+ /*
471
+ * call-seq:
472
+ * vol.key -> String
473
+ *
474
+ * Call virStorageVolGetKey[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetKey]
475
+ * to retrieve the key for this storage volume.
476
+ */
477
+ static VALUE libvirt_storage_vol_key(VALUE v)
478
+ {
479
+ ruby_libvirt_generate_call_string(virStorageVolGetKey,
480
+ ruby_libvirt_connect_get(v), 0,
481
+ vol_get(v));
482
+ }
483
+
484
+ /*
485
+ * call-seq:
486
+ * pool.create_volume_xml(xml, flags=0) -> Libvirt::StorageVol
487
+ *
488
+ * Call virStorageVolCreateXML[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolCreateXML]
489
+ * to create a new storage volume from xml.
490
+ */
491
+ static VALUE libvirt_storage_pool_create_volume_xml(int argc, VALUE *argv,
492
+ VALUE p)
493
+ {
494
+ virStorageVolPtr vol;
495
+ VALUE xml, flags = RUBY_Qnil;
496
+
497
+ rb_scan_args(argc, argv, "11", &xml, &flags);
498
+
499
+ vol = virStorageVolCreateXML(pool_get(p), StringValueCStr(xml),
500
+ ruby_libvirt_value_to_uint(flags));
501
+ ruby_libvirt_raise_error_if(vol == NULL, e_Error, "virStorageVolCreateXML",
502
+ ruby_libvirt_connect_get(p));
503
+
504
+ return vol_new(vol, ruby_libvirt_conn_attr(p));
505
+ }
506
+
507
+ #if HAVE_VIRSTORAGEVOLCREATEXMLFROM
508
+ /*
509
+ * call-seq:
510
+ * pool.create_volume_xml_from(xml, clonevol, flags=0) -> Libvirt::StorageVol
511
+ *
512
+ * Call virStorageVolCreateXMLFrom[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolCreateXMLFrom]
513
+ * to clone a volume from an existing volume with the properties specified in
514
+ * xml.
515
+ */
516
+ static VALUE libvirt_storage_pool_create_volume_xml_from(int argc, VALUE *argv,
517
+ VALUE p)
518
+ {
519
+ virStorageVolPtr vol;
520
+ VALUE xml, flags = RUBY_Qnil, cloneval = RUBY_Qnil;
521
+
522
+ rb_scan_args(argc, argv, "21", &xml, &cloneval, &flags);
523
+
524
+ vol = virStorageVolCreateXMLFrom(pool_get(p), StringValueCStr(xml),
525
+ vol_get(cloneval),
526
+ ruby_libvirt_value_to_uint(flags));
527
+ ruby_libvirt_raise_error_if(vol == NULL, e_Error,
528
+ "virStorageVolCreateXMLFrom",
529
+ ruby_libvirt_connect_get(p));
530
+
531
+ return vol_new(vol, ruby_libvirt_conn_attr(p));
532
+ }
533
+ #endif
534
+
535
+ #if HAVE_VIRSTORAGEPOOLISACTIVE
536
+ /*
537
+ * call-seq:
538
+ * pool.active? -> [true|false]
539
+ *
540
+ * Call virStoragePoolIsActive[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolIsActive]
541
+ * to determine if this storage pool is active.
542
+ */
543
+ static VALUE libvirt_storage_pool_active_p(VALUE p)
544
+ {
545
+ ruby_libvirt_generate_call_truefalse(virStoragePoolIsActive,
546
+ ruby_libvirt_connect_get(p),
547
+ pool_get(p));
548
+ }
549
+ #endif
550
+
551
+ #if HAVE_VIRSTORAGEPOOLISPERSISTENT
552
+ /*
553
+ * call-seq:
554
+ * pool.persistent? -> [true|false]
555
+ *
556
+ * Call virStoragePoolIsPersistent[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolIsPersistent]
557
+ * to determine if this storage pool is persistent.
558
+ */
559
+ static VALUE libvirt_storage_pool_persistent_p(VALUE p)
560
+ {
561
+ ruby_libvirt_generate_call_truefalse(virStoragePoolIsPersistent,
562
+ ruby_libvirt_connect_get(p),
563
+ pool_get(p));
564
+ }
565
+ #endif
566
+
567
+ /*
568
+ * call-seq:
569
+ * vol.delete(flags=0) -> nil
570
+ *
571
+ * Call virStorageVolDelete[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolDelete]
572
+ * to delete this volume. This is a destructive operation.
573
+ */
574
+ static VALUE libvirt_storage_vol_delete(int argc, VALUE *argv, VALUE v)
575
+ {
576
+ VALUE flags = RUBY_Qnil;
577
+
578
+ rb_scan_args(argc, argv, "01", &flags);
579
+
580
+ ruby_libvirt_generate_call_nil(virStorageVolDelete,
581
+ ruby_libvirt_connect_get(v),
582
+ vol_get(v),
583
+ ruby_libvirt_value_to_uint(flags));
584
+ }
585
+
586
+ #if HAVE_VIRSTORAGEVOLWIPE
587
+ /*
588
+ * call-seq:
589
+ * vol.wipe(flags=0) -> nil
590
+ *
591
+ * Call virStorageVolWipe[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolWipe]
592
+ * to wipe the data from this storage volume. This is a destructive operation.
593
+ */
594
+ static VALUE libvirt_storage_vol_wipe(int argc, VALUE *argv, VALUE v)
595
+ {
596
+ VALUE flags = RUBY_Qnil;
597
+
598
+ rb_scan_args(argc, argv, "01", &flags);
599
+
600
+ ruby_libvirt_generate_call_nil(virStorageVolWipe,
601
+ ruby_libvirt_connect_get(v),
602
+ vol_get(v),
603
+ ruby_libvirt_value_to_uint(flags));
604
+ }
605
+ #endif
606
+
607
+ /*
608
+ * call-seq:
609
+ * vol.info -> Libvirt::StorageVolInfo
610
+ *
611
+ * Call virStorageVolGetInfo[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetInfo]
612
+ * to retrieve information about this storage volume.
613
+ */
614
+ static VALUE libvirt_storage_vol_info(VALUE v)
615
+ {
616
+ virStorageVolInfo info;
617
+ int r;
618
+ VALUE result;
619
+
620
+ r = virStorageVolGetInfo(vol_get(v), &info);
621
+ ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virStorageVolGetInfo",
622
+ ruby_libvirt_connect_get(v));
623
+
624
+ result = rb_class_new_instance(0, NULL, c_storage_vol_info);
625
+ rb_iv_set(result, "@type", INT2NUM(info.type));
626
+ rb_iv_set(result, "@capacity", ULL2NUM(info.capacity));
627
+ rb_iv_set(result, "@allocation", ULL2NUM(info.allocation));
628
+
629
+ return result;
630
+ }
631
+
632
+ /*
633
+ * call-seq:
634
+ * vol.xml_desc(flags=0) -> String
635
+ *
636
+ * Call virStorageVolGetXMLDesc[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetXMLDesc]
637
+ * to retrieve the xml for this storage volume.
638
+ */
639
+ static VALUE libvirt_storage_vol_xml_desc(int argc, VALUE *argv, VALUE v)
640
+ {
641
+ VALUE flags = RUBY_Qnil;
642
+
643
+ rb_scan_args(argc, argv, "01", &flags);
644
+
645
+ ruby_libvirt_generate_call_string(virStorageVolGetXMLDesc,
646
+ ruby_libvirt_connect_get(v),
647
+ 1, vol_get(v),
648
+ ruby_libvirt_value_to_uint(flags));
649
+ }
650
+
651
+ /*
652
+ * call-seq:
653
+ * vol.path -> String
654
+ *
655
+ * Call virStorageVolGetPath[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetPath]
656
+ * to retrieve the path for this storage volume.
657
+ */
658
+ static VALUE libvirt_storage_vol_path(VALUE v)
659
+ {
660
+ ruby_libvirt_generate_call_string(virStorageVolGetPath,
661
+ ruby_libvirt_connect_get(v), 1,
662
+ vol_get(v));
663
+ }
664
+
665
+ /*
666
+ * call-seq:
667
+ * vol.free -> nil
668
+ *
669
+ * Call virStorageVolFree[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolFree]
670
+ * to free the storage volume object. After this call the storage volume object
671
+ * is no longer valid.
672
+ */
673
+ static VALUE libvirt_storage_vol_free(VALUE v)
674
+ {
675
+ ruby_libvirt_generate_call_free(StorageVol, v);
676
+ }
677
+ #endif
678
+
679
+ #if HAVE_VIRSTORAGEVOLDOWNLOAD
680
+ /*
681
+ * call-seq:
682
+ * vol.download(stream, offset, length, flags=0) -> nil
683
+ *
684
+ * Call virStorageVolDownload[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolDownload]
685
+ * to download the content of a volume as a stream.
686
+ */
687
+ static VALUE libvirt_storage_vol_download(int argc, VALUE *argv, VALUE v)
688
+ {
689
+ VALUE st = RUBY_Qnil, offset = RUBY_Qnil, length = RUBY_Qnil, flags = RUBY_Qnil;
690
+
691
+ rb_scan_args(argc, argv, "31", &st, &offset, &length, &flags);
692
+
693
+ ruby_libvirt_generate_call_nil(virStorageVolDownload,
694
+ ruby_libvirt_connect_get(v),
695
+ vol_get(v), ruby_libvirt_stream_get(st),
696
+ NUM2ULL(offset), NUM2ULL(length),
697
+ ruby_libvirt_value_to_uint(flags));
698
+ }
699
+
700
+ /*
701
+ * call-seq:
702
+ * vol.upload(stream, offset, length, flags=0) -> nil
703
+ *
704
+ * Call virStorageVolUpload[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolUpload]
705
+ * to upload new content to a volume from a stream.
706
+ */
707
+ static VALUE libvirt_storage_vol_upload(int argc, VALUE *argv, VALUE v)
708
+ {
709
+ VALUE st = RUBY_Qnil, offset = RUBY_Qnil, length = RUBY_Qnil, flags = RUBY_Qnil;
710
+
711
+ rb_scan_args(argc, argv, "31", &st, &offset, &length, &flags);
712
+
713
+ ruby_libvirt_generate_call_nil(virStorageVolUpload,
714
+ ruby_libvirt_connect_get(v),
715
+ vol_get(v), ruby_libvirt_stream_get(st),
716
+ NUM2ULL(offset), NUM2ULL(length),
717
+ ruby_libvirt_value_to_uint(flags));
718
+ }
719
+ #endif
720
+
721
+ #if HAVE_VIRSTORAGEVOLWIPEPATTERN
722
+ /*
723
+ * call-seq:
724
+ * vol.wipe_pattern(alg, flags=0) -> nil
725
+ *
726
+ * Call virStorageVolWipePattern[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolWipePattern]
727
+ * to wipe the data from this storage volume. This is a destructive operation.
728
+ */
729
+ static VALUE libvirt_storage_vol_wipe_pattern(int argc, VALUE *argv, VALUE v)
730
+ {
731
+ VALUE alg = RUBY_Qnil, flags = RUBY_Qnil;
732
+
733
+ rb_scan_args(argc, argv, "11", &alg, &flags);
734
+
735
+ ruby_libvirt_generate_call_nil(virStorageVolWipePattern,
736
+ ruby_libvirt_connect_get(v),
737
+ vol_get(v), NUM2UINT(alg),
738
+ ruby_libvirt_value_to_uint(flags));
739
+ }
740
+ #endif
741
+
742
+ #if HAVE_VIRSTORAGEVOLRESIZE
743
+ /*
744
+ * call-seq:
745
+ * vol.resize(capacity, flags=0) -> nil
746
+ *
747
+ * Call virStorageVolResize[http://www.libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolResize]
748
+ * to resize the associated storage volume.
749
+ */
750
+ static VALUE libvirt_storage_vol_resize(int argc, VALUE *argv, VALUE v)
751
+ {
752
+ VALUE capacity = RUBY_Qnil, flags = RUBY_Qnil;
753
+
754
+ rb_scan_args(argc, argv, "11", &capacity, &flags);
755
+
756
+ ruby_libvirt_generate_call_nil(virStorageVolResize,
757
+ ruby_libvirt_connect_get(v),
758
+ vol_get(v), NUM2ULL(capacity),
759
+ ruby_libvirt_value_to_uint(flags));
760
+ }
761
+ #endif
762
+
763
+ void ruby_libvirt_storage_init(void)
764
+ {
765
+ /*
766
+ * Class Libvirt::StoragePool and Libvirt::StoragePoolInfo
767
+ */
768
+ #if HAVE_TYPE_VIRSTORAGEPOOLPTR
769
+ c_storage_pool_info = rb_define_class_under(m_libvirt, "StoragePoolInfo",
770
+ rb_cObject);
771
+ rb_define_attr(c_storage_pool_info, "state", 1, 0);
772
+ rb_define_attr(c_storage_pool_info, "capacity", 1, 0);
773
+ rb_define_attr(c_storage_pool_info, "allocation", 1, 0);
774
+ rb_define_attr(c_storage_pool_info, "available", 1, 0);
775
+
776
+ c_storage_pool = rb_define_class_under(m_libvirt, "StoragePool",
777
+ rb_cObject);
778
+
779
+ rb_define_attr(c_storage_pool, "connection", 1, 0);
780
+
781
+ /* virStoragePoolState */
782
+ rb_define_const(c_storage_pool, "INACTIVE",
783
+ INT2NUM(VIR_STORAGE_POOL_INACTIVE));
784
+ rb_define_const(c_storage_pool, "BUILDING",
785
+ INT2NUM(VIR_STORAGE_POOL_BUILDING));
786
+ rb_define_const(c_storage_pool, "RUNNING",
787
+ INT2NUM(VIR_STORAGE_POOL_RUNNING));
788
+ rb_define_const(c_storage_pool, "DEGRADED",
789
+ INT2NUM(VIR_STORAGE_POOL_DEGRADED));
790
+ #if HAVE_CONST_VIR_STORAGE_POOL_INACCESSIBLE
791
+ rb_define_const(c_storage_pool, "INACCESSIBLE",
792
+ INT2NUM(VIR_STORAGE_POOL_INACCESSIBLE));
793
+ #endif
794
+
795
+ #if HAVE_CONST_VIR_STORAGE_XML_INACTIVE
796
+ rb_define_const(c_storage_pool, "XML_INACTIVE",
797
+ INT2NUM(VIR_STORAGE_XML_INACTIVE));
798
+ #endif
799
+
800
+ /* virStoragePoolBuildFlags */
801
+ rb_define_const(c_storage_pool, "BUILD_NEW",
802
+ INT2NUM(VIR_STORAGE_POOL_BUILD_NEW));
803
+ rb_define_const(c_storage_pool, "BUILD_REPAIR",
804
+ INT2NUM(VIR_STORAGE_POOL_BUILD_REPAIR));
805
+ rb_define_const(c_storage_pool, "BUILD_RESIZE",
806
+ INT2NUM(VIR_STORAGE_POOL_BUILD_RESIZE));
807
+
808
+ /* virStoragePoolDeleteFlags */
809
+ rb_define_const(c_storage_pool, "DELETE_NORMAL",
810
+ INT2NUM(VIR_STORAGE_POOL_DELETE_NORMAL));
811
+ rb_define_const(c_storage_pool, "DELETE_ZEROED",
812
+ INT2NUM(VIR_STORAGE_POOL_DELETE_ZEROED));
813
+
814
+ #if HAVE_CONST_VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
815
+ rb_define_const(c_storage_pool, "CREATE_PREALLOC_METADATA",
816
+ INT2NUM(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA));
817
+ #endif
818
+ #if HAVE_CONST_VIR_STORAGE_VOL_CREATE_REFLINK
819
+ rb_define_const(c_storage_pool, "CREATE_REFLINK",
820
+ INT2NUM(VIR_STORAGE_VOL_CREATE_REFLINK));
821
+ #endif
822
+
823
+ #if HAVE_CONST_VIR_STORAGE_POOL_CREATE_NORMAL
824
+ rb_define_const(c_storage_pool, "CREATE_NORMAL",
825
+ INT2NUM(VIR_STORAGE_POOL_CREATE_NORMAL));
826
+ #endif
827
+ #if HAVE_CONST_VIR_STORAGE_POOL_CREATE_WITH_BUILD
828
+ rb_define_const(c_storage_pool, "CREATE_WITH_BUILD",
829
+ INT2NUM(VIR_STORAGE_POOL_CREATE_WITH_BUILD));
830
+ #endif
831
+ #if HAVE_CONST_VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE
832
+ rb_define_const(c_storage_pool, "CREATE_WITH_BUILD_OVERWRITE",
833
+ INT2NUM(VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE));
834
+ #endif
835
+ #if HAVE_CONST_VIR_STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE
836
+ rb_define_const(c_storage_pool, "CREATE_WITH_BUILD_NO_OVERWRITE",
837
+ INT2NUM(VIR_STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE));
838
+ #endif
839
+
840
+ /* Creating/destroying pools */
841
+ rb_define_method(c_storage_pool, "build", libvirt_storage_pool_build, -1);
842
+ rb_define_method(c_storage_pool, "undefine", libvirt_storage_pool_undefine,
843
+ 0);
844
+ rb_define_method(c_storage_pool, "create", libvirt_storage_pool_create, -1);
845
+ rb_define_method(c_storage_pool, "destroy", libvirt_storage_pool_destroy,
846
+ 0);
847
+ rb_define_method(c_storage_pool, "delete", libvirt_storage_pool_delete, -1);
848
+ rb_define_method(c_storage_pool, "refresh", libvirt_storage_pool_refresh,
849
+ -1);
850
+ /* StoragePool information */
851
+ rb_define_method(c_storage_pool, "name", libvirt_storage_pool_name, 0);
852
+ rb_define_method(c_storage_pool, "uuid", libvirt_storage_pool_uuid, 0);
853
+ rb_define_method(c_storage_pool, "info", libvirt_storage_pool_info, 0);
854
+ rb_define_method(c_storage_pool, "xml_desc", libvirt_storage_pool_xml_desc,
855
+ -1);
856
+ rb_define_method(c_storage_pool, "autostart",
857
+ libvirt_storage_pool_autostart, 0);
858
+ rb_define_method(c_storage_pool, "autostart?",
859
+ libvirt_storage_pool_autostart, 0);
860
+ rb_define_method(c_storage_pool, "autostart=",
861
+ libvirt_storage_pool_autostart_equal, 1);
862
+ /* List/lookup storage volumes within a pool */
863
+ rb_define_method(c_storage_pool, "num_of_volumes",
864
+ libvirt_storage_pool_num_of_volumes, 0);
865
+ rb_define_method(c_storage_pool, "list_volumes",
866
+ libvirt_storage_pool_list_volumes, 0);
867
+ /* Lookup volumes based on various attributes */
868
+ rb_define_method(c_storage_pool, "lookup_volume_by_name",
869
+ libvirt_storage_pool_lookup_vol_by_name, 1);
870
+ rb_define_method(c_storage_pool, "lookup_volume_by_key",
871
+ libvirt_storage_pool_lookup_vol_by_key, 1);
872
+ rb_define_method(c_storage_pool, "lookup_volume_by_path",
873
+ libvirt_storage_pool_lookup_vol_by_path, 1);
874
+ rb_define_method(c_storage_pool, "free", libvirt_storage_pool_free, 0);
875
+ rb_define_method(c_storage_pool, "create_volume_xml",
876
+ libvirt_storage_pool_create_volume_xml, -1);
877
+ rb_define_alias(c_storage_pool, "create_vol_xml", "create_volume_xml");
878
+ #if HAVE_VIRSTORAGEVOLCREATEXMLFROM
879
+ rb_define_method(c_storage_pool, "create_volume_xml_from",
880
+ libvirt_storage_pool_create_volume_xml_from, -1);
881
+ rb_define_alias(c_storage_pool, "create_vol_xml_from",
882
+ "create_volume_xml_from");
883
+ #endif
884
+ #if HAVE_VIRSTORAGEPOOLISACTIVE
885
+ rb_define_method(c_storage_pool, "active?", libvirt_storage_pool_active_p,
886
+ 0);
887
+ #endif
888
+ #if HAVE_VIRSTORAGEPOOLISPERSISTENT
889
+ rb_define_method(c_storage_pool, "persistent?",
890
+ libvirt_storage_pool_persistent_p, 0);
891
+ #endif
892
+
893
+ #if HAVE_VIRSTORAGEPOOLLISTALLVOLUMES
894
+ rb_define_method(c_storage_pool, "list_all_volumes",
895
+ libvirt_storage_pool_list_all_volumes, -1);
896
+ #endif
897
+
898
+ #if HAVE_CONST_VIR_STORAGE_POOL_BUILD_NO_OVERWRITE
899
+ rb_define_const(c_storage_pool, "BUILD_NO_OVERWRITE",
900
+ INT2NUM(VIR_STORAGE_POOL_BUILD_NO_OVERWRITE));
901
+ #endif
902
+
903
+ #if HAVE_CONST_VIR_STORAGE_POOL_BUILD_OVERWRITE
904
+ rb_define_const(c_storage_pool, "BUILD_OVERWRITE",
905
+ INT2NUM(VIR_STORAGE_POOL_BUILD_OVERWRITE));
906
+ #endif
907
+
908
+ #endif
909
+
910
+ #if HAVE_TYPE_VIRSTORAGEVOLPTR
911
+ /*
912
+ * Class Libvirt::StorageVol and Libvirt::StorageVolInfo
913
+ */
914
+ c_storage_vol_info = rb_define_class_under(m_libvirt, "StorageVolInfo",
915
+ rb_cObject);
916
+ rb_define_attr(c_storage_vol_info, "type", 1, 0);
917
+ rb_define_attr(c_storage_vol_info, "capacity", 1, 0);
918
+ rb_define_attr(c_storage_vol_info, "allocation", 1, 0);
919
+
920
+ c_storage_vol = rb_define_class_under(m_libvirt, "StorageVol",
921
+ rb_cObject);
922
+
923
+ #if HAVE_CONST_VIR_STORAGE_XML_INACTIVE
924
+ rb_define_const(c_storage_vol, "XML_INACTIVE",
925
+ INT2NUM(VIR_STORAGE_XML_INACTIVE));
926
+ #endif
927
+
928
+ /* virStorageVolType */
929
+ rb_define_const(c_storage_vol, "FILE", INT2NUM(VIR_STORAGE_VOL_FILE));
930
+ rb_define_const(c_storage_vol, "BLOCK", INT2NUM(VIR_STORAGE_VOL_BLOCK));
931
+ #if HAVE_CONST_VIR_STORAGE_VOL_DIR
932
+ rb_define_const(c_storage_vol, "DIR", INT2NUM(VIR_STORAGE_VOL_DIR));
933
+ #endif
934
+ #if HAVE_CONST_VIR_STORAGE_VOL_NETWORK
935
+ rb_define_const(c_storage_vol, "NETWORK", INT2NUM(VIR_STORAGE_VOL_NETWORK));
936
+ #endif
937
+ #if HAVE_CONST_VIR_STORAGE_VOL_NETDIR
938
+ rb_define_const(c_storage_vol, "NETDIR", INT2NUM(VIR_STORAGE_VOL_NETDIR));
939
+ #endif
940
+
941
+ /* virStorageVolDeleteFlags */
942
+ rb_define_const(c_storage_vol, "DELETE_NORMAL",
943
+ INT2NUM(VIR_STORAGE_VOL_DELETE_NORMAL));
944
+ rb_define_const(c_storage_vol, "DELETE_ZEROED",
945
+ INT2NUM(VIR_STORAGE_VOL_DELETE_ZEROED));
946
+ #if HAVE_CONST_VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS
947
+ rb_define_const(c_storage_vol, "DELETE_WITH_SNAPSHOTS",
948
+ INT2NUM(VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS));
949
+ #endif
950
+
951
+ rb_define_method(c_storage_vol, "pool", libvirt_storage_vol_pool, 0);
952
+ rb_define_method(c_storage_vol, "name", libvirt_storage_vol_name, 0);
953
+ rb_define_method(c_storage_vol, "key", libvirt_storage_vol_key, 0);
954
+ rb_define_method(c_storage_vol, "delete", libvirt_storage_vol_delete, -1);
955
+ #if HAVE_VIRSTORAGEVOLWIPE
956
+ rb_define_method(c_storage_vol, "wipe", libvirt_storage_vol_wipe, -1);
957
+ #endif
958
+ #if HAVE_VIRSTORAGEVOLWIPEPATTERN
959
+ rb_define_method(c_storage_vol, "wipe_pattern",
960
+ libvirt_storage_vol_wipe_pattern, -1);
961
+ #endif
962
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_ZERO
963
+ rb_define_const(c_storage_vol, "WIPE_ALG_ZERO",
964
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_ZERO));
965
+ #endif
966
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_NNSA
967
+ rb_define_const(c_storage_vol, "WIPE_ALG_NNSA",
968
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_NNSA));
969
+ #endif
970
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_DOD
971
+ rb_define_const(c_storage_vol, "WIPE_ALG_DOD",
972
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_DOD));
973
+ #endif
974
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_BSI
975
+ rb_define_const(c_storage_vol, "WIPE_ALG_BSI",
976
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_BSI));
977
+ #endif
978
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_GUTMANN
979
+ rb_define_const(c_storage_vol, "WIPE_ALG_GUTMANN",
980
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_GUTMANN));
981
+ #endif
982
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_SCHNEIER
983
+ rb_define_const(c_storage_vol, "WIPE_ALG_SCHNEIER",
984
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_SCHNEIER));
985
+ #endif
986
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_PFITZNER7
987
+ rb_define_const(c_storage_vol, "WIPE_ALG_PFITZNER7",
988
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_PFITZNER7));
989
+ #endif
990
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_PFITZNER33
991
+ rb_define_const(c_storage_vol, "WIPE_ALG_PFITZNER33",
992
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_PFITZNER33));
993
+ #endif
994
+ #if HAVE_CONST_VIR_STORAGE_VOL_WIPE_ALG_RANDOM
995
+ rb_define_const(c_storage_vol, "WIPE_ALG_RANDOM",
996
+ INT2NUM(VIR_STORAGE_VOL_WIPE_ALG_RANDOM));
997
+ #endif
998
+
999
+ rb_define_method(c_storage_vol, "info", libvirt_storage_vol_info, 0);
1000
+ rb_define_method(c_storage_vol, "xml_desc", libvirt_storage_vol_xml_desc,
1001
+ -1);
1002
+ rb_define_method(c_storage_vol, "path", libvirt_storage_vol_path, 0);
1003
+ rb_define_method(c_storage_vol, "free", libvirt_storage_vol_free, 0);
1004
+
1005
+ #if HAVE_VIRSTORAGEVOLDOWNLOAD
1006
+ rb_define_method(c_storage_vol, "download", libvirt_storage_vol_download,
1007
+ -1);
1008
+ rb_define_method(c_storage_vol, "upload", libvirt_storage_vol_upload, -1);
1009
+ #endif
1010
+
1011
+ #if HAVE_VIRSTORAGEVOLRESIZE
1012
+ rb_define_const(c_storage_vol, "RESIZE_ALLOCATE",
1013
+ INT2NUM(VIR_STORAGE_VOL_RESIZE_ALLOCATE));
1014
+ rb_define_const(c_storage_vol, "RESIZE_DELTA",
1015
+ INT2NUM(VIR_STORAGE_VOL_RESIZE_DELTA));
1016
+ rb_define_const(c_storage_vol, "RESIZE_SHRINK",
1017
+ INT2NUM(VIR_STORAGE_VOL_RESIZE_SHRINK));
1018
+ rb_define_method(c_storage_vol, "resize", libvirt_storage_vol_resize, -1);
1019
+ #endif
1020
+
1021
+ #endif
1022
+ }