ruby-libvirt 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ #ifndef STREAM_H
2
+ #define STREAM_H
3
+
4
+ virStreamPtr stream_get(VALUE s);
5
+ void init_stream();
6
+
7
+ #endif
data/tests/test_conn.rb CHANGED
@@ -7,6 +7,16 @@ $: << File.dirname(__FILE__)
7
7
  require 'libvirt'
8
8
  require 'test_utils.rb'
9
9
 
10
+ # test setup
11
+ begin
12
+ `rm -f /etc/sysconfig/network-scripts/ifcfg-ruby-libvirt-tester`
13
+ `brctl delbr ruby-libvirt-tester >& /dev/null`
14
+ rescue
15
+ end
16
+ `rm -f #{$GUEST_DISK} ; qemu-img create -f qcow2 #{$GUEST_DISK} 5G`
17
+ `rm -f /var/lib/libvirt/images/ruby-libvirt-test.save`
18
+ `rm -rf #{$POOL_PATH}; mkdir #{$POOL_PATH} ; echo $?`
19
+
10
20
  conn = Libvirt::open("qemu:///system")
11
21
 
12
22
  cpu_xml = <<EOF
@@ -198,6 +208,466 @@ conn.domain_event_register(dom_event_callback_proc)
198
208
  expect_too_many_args(conn, "domain_event_deregister", 1)
199
209
  expect_success(conn, "no args", "domain_event_deregister")
200
210
 
211
+ # TESTGROUP: conn.num_of_domains
212
+ expect_too_many_args(conn, "num_of_domains", 1)
213
+ expect_success(conn, "no args", "num_of_domains")
214
+
215
+ # TESTGROUP: conn.list_domains
216
+ expect_too_many_args(conn, "list_domains", 1)
217
+ expect_success(conn, "no args", "list_domains")
218
+
219
+ # TESTGROUP: conn.num_of_defined_domains
220
+ expect_too_many_args(conn, "num_of_defined_domains", 1)
221
+ expect_success(conn, "no args", "num_of_defined_domains")
222
+
223
+ # TESTGROUP: conn.list_defined_domains
224
+ expect_too_many_args(conn, "list_defined_domains", 1)
225
+ expect_success(conn, "no args", "list_defined_domains")
226
+
227
+ # TESTGROUP: conn.create_domain_linux
228
+ expect_too_many_args(conn, "create_domain_linux", $new_dom_xml, 0, 1)
229
+ expect_too_few_args(conn, "create_domain_linux")
230
+ expect_invalid_arg_type(conn, "create_domain_linux", nil)
231
+ expect_invalid_arg_type(conn, "create_domain_linux", 1)
232
+ expect_invalid_arg_type(conn, "create_domain_linux", $new_dom_xml, "foo")
233
+ expect_fail(conn, Libvirt::Error, "invalid xml", "create_domain_linux", "hello")
234
+ newdom = expect_success(conn, "domain xml", "create_domain_linux", $new_dom_xml) {|x| x.class == Libvirt::Domain}
235
+ sleep 1
236
+
237
+ expect_fail(conn, Libvirt::Error, "already existing domain", "create_domain_linux", $new_dom_xml)
238
+
239
+ newdom.destroy
240
+
241
+ # TESTGROUP: conn.create_domain_xml
242
+ expect_too_many_args(conn, "create_domain_xml", $new_dom_xml, 0, 1)
243
+ expect_too_few_args(conn, "create_domain_xml")
244
+ expect_invalid_arg_type(conn, "create_domain_xml", nil)
245
+ expect_invalid_arg_type(conn, "create_domain_xml", 1)
246
+ expect_invalid_arg_type(conn, "create_domain_xml", $new_dom_xml, "foo")
247
+ expect_fail(conn, Libvirt::Error, "invalid xml", "create_domain_xml", "hello")
248
+ newdom = expect_success(conn, "domain xml", "create_domain_xml", $new_dom_xml) {|x| x.class == Libvirt::Domain}
249
+ sleep 1
250
+
251
+ expect_fail(conn, Libvirt::Error, "already existing domain", "create_domain_xml", $new_dom_xml)
252
+
253
+ newdom.destroy
254
+
255
+ # TESTGROUP: conn.lookup_domain_by_name
256
+ newdom = conn.create_domain_xml($new_dom_xml)
257
+ sleep 1
258
+
259
+ expect_too_many_args(conn, "lookup_domain_by_name", 1, 2)
260
+ expect_too_few_args(conn, "lookup_domain_by_name")
261
+ expect_invalid_arg_type(conn, "lookup_domain_by_name", 1)
262
+ expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_domain_by_name", "foobarbazsucker")
263
+
264
+ expect_success(conn, "name arg for running domain", "lookup_domain_by_name", "ruby-libvirt-tester") {|x| x.name == "ruby-libvirt-tester"}
265
+ newdom.destroy
266
+
267
+ newdom = conn.define_domain_xml($new_dom_xml)
268
+ expect_success(conn, "name arg for defined domain", "lookup_domain_by_name", "ruby-libvirt-tester") {|x| x.name == "ruby-libvirt-tester"}
269
+ newdom.undefine
270
+
271
+ # TESTGROUP: conn.lookup_domain_by_id
272
+ newdom = conn.create_domain_xml($new_dom_xml)
273
+ sleep 1
274
+
275
+ expect_too_many_args(conn, "lookup_domain_by_id", 1, 2)
276
+ expect_too_few_args(conn, "lookup_domain_by_id")
277
+ expect_invalid_arg_type(conn, "lookup_domain_by_id", "foo")
278
+ expect_fail(conn, Libvirt::Error, "with negative value", "lookup_domain_by_id", -1)
279
+
280
+ expect_success(conn, "id arg for running domain", "lookup_domain_by_id", newdom.id)
281
+ newdom.destroy
282
+
283
+ # TESTGROUP: conn.lookup_domain_by_uuid
284
+ newdom = conn.create_domain_xml($new_dom_xml)
285
+ sleep 1
286
+
287
+ expect_too_many_args(conn, "lookup_domain_by_uuid", 1, 2)
288
+ expect_too_few_args(conn, "lookup_domain_by_uuid")
289
+ expect_invalid_arg_type(conn, "lookup_domain_by_uuid", 1)
290
+ expect_fail(conn, Libvirt::RetrieveError, "invalid UUID", "lookup_domain_by_uuid", "abcd")
291
+
292
+ expect_success(conn, "UUID arg for running domain", "lookup_domain_by_uuid", newdom.uuid) {|x| x.uuid == $GUEST_UUID}
293
+ newdom.destroy
294
+
295
+ newdom = conn.define_domain_xml($new_dom_xml)
296
+ expect_success(conn, "UUID arg for defined domain", "lookup_domain_by_uuid", newdom.uuid) {|x| x.uuid == $GUEST_UUID}
297
+ newdom.undefine
298
+
299
+ # TESTGROUP: conn.define_domain_xml
300
+ expect_too_many_args(conn, "define_domain_xml", 1, 2)
301
+ expect_too_few_args(conn, "define_domain_xml")
302
+ expect_invalid_arg_type(conn, "define_domain_xml", 1)
303
+ expect_invalid_arg_type(conn, "define_domain_xml", nil)
304
+ expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_domain_xml", "hello")
305
+
306
+ newdom = expect_success(conn, "domain xml arg", "define_domain_xml", $new_dom_xml)
307
+ newdom.undefine
308
+
309
+ # TESTGROUP: conn.domain_xml_from_native
310
+ expect_too_many_args(conn, "domain_xml_from_native", 1, 2, 3, 4)
311
+ expect_too_few_args(conn, "domain_xml_from_native")
312
+ expect_too_few_args(conn, "domain_xml_from_native", 1)
313
+ expect_invalid_arg_type(conn, "domain_xml_from_native", 1, 2)
314
+ expect_invalid_arg_type(conn, "domain_xml_from_native", nil, 2)
315
+ expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", 2)
316
+ expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", nil)
317
+ expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", "foo", "bar")
318
+ expect_fail(conn, Libvirt::Error, "unsupported first arg", "domain_xml_from_native", "foo", "bar")
319
+
320
+ expect_success(conn, "qemu-argv and qemu_cmd_line", "domain_xml_from_native", "qemu-argv", $qemu_cmd_line)
321
+
322
+ # TESTGROUP: conn.domain_xml_to_native
323
+ expect_too_many_args(conn, "domain_xml_to_native", 1, 2, 3, 4)
324
+ expect_too_few_args(conn, "domain_xml_to_native")
325
+ expect_too_few_args(conn, "domain_xml_to_native", 1)
326
+ expect_invalid_arg_type(conn, "domain_xml_to_native", 1, 2)
327
+ expect_invalid_arg_type(conn, "domain_xml_to_native", nil, 2)
328
+ expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", 2)
329
+ expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", nil)
330
+ expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", "foo", "bar")
331
+ expect_fail(conn, Libvirt::Error, "unsupported first arg", "domain_xml_to_native", "foo", "bar")
332
+
333
+ expect_success(conn, "qemu-argv and domain XML", "domain_xml_to_native", "qemu-argv", $new_dom_xml)
334
+
335
+ # TESTGROUP: conn.num_of_interfaces
336
+ expect_too_many_args(conn, "num_of_interfaces", 1)
337
+ expect_success(conn, "no args", "num_of_interfaces")
338
+
339
+ # TESTGROUP: conn.list_interfaces
340
+ expect_too_many_args(conn, "list_interfaces", 1)
341
+ expect_success(conn, "no args", "list_interfaces")
342
+
343
+ # TESTGROUP: conn.num_of_defined_interfaces
344
+ expect_too_many_args(conn, "num_of_defined_interfaces", 1)
345
+ expect_success(conn, "no args", "num_of_defined_interfaces")
346
+
347
+ # TESTGROUP: conn.list_defined_interfaces
348
+ expect_too_many_args(conn, "list_defined_interfaces", 1)
349
+ expect_success(conn, "no args", "list_defined_interfaces")
350
+
351
+ # TESTGROUP: conn.lookup_interface_by_name
352
+ newiface = conn.define_interface_xml($new_interface_xml)
353
+
354
+ expect_too_many_args(conn, "lookup_interface_by_name", 1, 2)
355
+ expect_too_few_args(conn, "lookup_interface_by_name")
356
+ expect_invalid_arg_type(conn, "lookup_interface_by_name", 1)
357
+ expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_interface_by_name", "foobarbazsucker")
358
+
359
+ expect_success(conn, "name arg", "lookup_interface_by_name", "ruby-libvirt-tester")
360
+
361
+ newiface.destroy
362
+
363
+ expect_success(conn, "name arg", "lookup_interface_by_name", "ruby-libvirt-tester")
364
+
365
+ newiface.undefine
366
+
367
+ # TESTGROUP: conn.lookup_interface_by_mac
368
+ newiface = conn.define_interface_xml($new_interface_xml)
369
+
370
+ expect_too_many_args(conn, "lookup_interface_by_mac", 1, 2)
371
+ expect_too_few_args(conn, "lookup_interface_by_mac")
372
+ expect_invalid_arg_type(conn, "lookup_interface_by_mac", 1)
373
+ expect_fail(conn, Libvirt::RetrieveError, "non-existent mac arg", "lookup_interface_by_mac", "foobarbazsucker")
374
+
375
+ testiface = find_valid_iface(conn)
376
+ if not testiface.nil?
377
+ expect_success(conn, "name arg", "lookup_interface_by_mac", testiface.mac) {|x| x.mac == testiface.mac}
378
+ end
379
+
380
+ newiface.undefine
381
+
382
+ # TESTGROUP: conn.define_interface_xml
383
+ expect_too_many_args(conn, "define_interface_xml", 1, 2, 3)
384
+ expect_too_few_args(conn, "define_interface_xml")
385
+ expect_invalid_arg_type(conn, "define_interface_xml", 1)
386
+ expect_invalid_arg_type(conn, "define_interface_xml", nil)
387
+ expect_invalid_arg_type(conn, "define_interface_xml", "hello", 'foo')
388
+ expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_interface_xml", "hello")
389
+
390
+ expect_success(conn, "interface XML", "define_interface_xml", $new_interface_xml)
391
+ newiface.undefine
392
+
393
+ # TESTGROUP: conn.num_of_networks
394
+ expect_too_many_args(conn, "num_of_networks", 1)
395
+ expect_success(conn, "no args", "num_of_networks")
396
+
397
+ # TESTGROUP: conn.list_networks
398
+ expect_too_many_args(conn, "list_networks", 1)
399
+ expect_success(conn, "no args", "list_networks")
400
+
401
+ # TESTGROUP: conn.num_of_defined_networks
402
+ expect_too_many_args(conn, "num_of_defined_networks", 1)
403
+ expect_success(conn, "no args", "num_of_defined_networks")
404
+
405
+ # TESTGROUP: conn.list_defined_networks
406
+ expect_too_many_args(conn, "list_defined_networks", 1)
407
+ expect_success(conn, "no args", "list_defined_networks")
408
+
409
+ # TESTGROUP: conn.lookup_network_by_name
410
+ newnet = conn.create_network_xml($new_net_xml)
411
+
412
+ expect_too_many_args(conn, "lookup_network_by_name", 1, 2)
413
+ expect_too_few_args(conn, "lookup_network_by_name")
414
+ expect_invalid_arg_type(conn, "lookup_network_by_name", 1)
415
+ expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_network_by_name", "foobarbazsucker")
416
+
417
+ expect_success(conn, "name arg", "lookup_network_by_name", "ruby-libvirt-tester")
418
+ newnet.destroy
419
+
420
+ newnet = conn.define_network_xml($new_net_xml)
421
+ expect_success(conn, "name arg", "lookup_network_by_name", "ruby-libvirt-tester")
422
+ newnet.undefine
423
+
424
+ # TESTGROUP: conn.lookup_network_by_uuid
425
+ newnet = conn.create_network_xml($new_net_xml)
426
+
427
+ expect_too_many_args(conn, "lookup_network_by_uuid", 1, 2)
428
+ expect_too_few_args(conn, "lookup_network_by_uuid")
429
+ expect_invalid_arg_type(conn, "lookup_network_by_uuid", 1)
430
+ expect_fail(conn, Libvirt::RetrieveError, "non-existent uuid arg", "lookup_network_by_uuid", "foobarbazsucker")
431
+
432
+ expect_success(conn, "uuid arg", "lookup_network_by_uuid", $NETWORK_UUID)
433
+ newnet.destroy
434
+
435
+ newnet = conn.define_network_xml($new_net_xml)
436
+ expect_success(conn, "uuid arg", "lookup_network_by_uuid", $NETWORK_UUID)
437
+ newnet.undefine
438
+
439
+ # TESTGROUP: conn.create_network_xml
440
+ expect_too_many_args(conn, "create_network_xml", $new_net_xml, 0)
441
+ expect_too_few_args(conn, "create_network_xml")
442
+ expect_invalid_arg_type(conn, "create_network_xml", nil)
443
+ expect_invalid_arg_type(conn, "create_network_xml", 1)
444
+ expect_fail(conn, Libvirt::Error, "invalid xml", "create_network_xml", "hello")
445
+
446
+ newnet = expect_success(conn, "network XML", "create_network_xml", $new_net_xml)
447
+
448
+ expect_fail(conn, Libvirt::Error, "already existing network", "create_network_xml", $new_net_xml)
449
+
450
+ newnet.destroy
451
+
452
+ # TESTGROUP: conn.define_network_xml
453
+ expect_too_many_args(conn, "define_network_xml", 1, 2)
454
+ expect_too_few_args(conn, "define_network_xml")
455
+ expect_invalid_arg_type(conn, "define_network_xml", 1)
456
+ expect_invalid_arg_type(conn, "define_network_xml", nil)
457
+ expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_network_xml", "hello")
458
+
459
+ newnet = expect_success(conn, "network XML", "define_network_xml", $new_net_xml)
460
+ newnet.undefine
461
+
462
+ # TESTGROUP: conn.num_of_nodedevices
463
+ expect_too_many_args(conn, "num_of_nodedevices", 1, 2, 3)
464
+ expect_invalid_arg_type(conn, "num_of_nodedevices", 1)
465
+ expect_invalid_arg_type(conn, "num_of_nodedevices", 'foo', 'bar')
466
+ expect_success(conn, "no args", "num_of_nodedevices")
467
+
468
+ # TESTGROUP: conn.list_nodedevices
469
+ expect_too_many_args(conn, "list_nodedevices", 1, 2, 3)
470
+ expect_invalid_arg_type(conn, "list_nodedevices", 1)
471
+ expect_invalid_arg_type(conn, "list_nodedevices", 'foo', 'bar')
472
+ expect_success(conn, "no args", "list_nodedevices")
473
+
474
+ # TESTGROUP: conn.lookup_nodedevice_by_name
475
+ testnode = conn.lookup_nodedevice_by_name(conn.list_nodedevices[0])
476
+
477
+ expect_too_many_args(conn, "lookup_nodedevice_by_name", 1, 2)
478
+ expect_too_few_args(conn, "lookup_nodedevice_by_name")
479
+ expect_invalid_arg_type(conn, "lookup_nodedevice_by_name", 1)
480
+ expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_nodedevice_by_name", "foobarbazsucker")
481
+
482
+ expect_success(conn, "name arg", "lookup_nodedevice_by_name", testnode.name)
483
+
484
+ # TESTGROUP: conn.create_nodedevice_xml
485
+ expect_too_many_args(conn, "create_nodedevice_xml", 1, 2, 3)
486
+ expect_too_few_args(conn, "create_nodedevice_xml")
487
+ expect_invalid_arg_type(conn, "create_nodedevice_xml", 1)
488
+ expect_invalid_arg_type(conn, "create_nodedevice_xml", "foo", 'bar')
489
+ expect_fail(conn, Libvirt::Error, "invalid XML", "create_nodedevice_xml", "hello")
490
+
491
+ #expect_success(conn, "nodedevice XML", "create_nodedevice_xml", "<nodedevice/>")
492
+
493
+ # TESTGROUP: conn.num_of_nwfilters
494
+ expect_too_many_args(conn, "num_of_nwfilters", 1)
495
+ expect_success(conn, "no args", "num_of_nwfilters")
496
+
497
+ # TESTGROUP: conn.list_nwfilters
498
+ expect_too_many_args(conn, "list_nwfilters", 1)
499
+ expect_success(conn, "no args", "list_nwfilters")
500
+
501
+ # TESTGROUP: conn.lookup_nwfilter_by_name
502
+ newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
503
+
504
+ expect_too_many_args(conn, "lookup_nwfilter_by_name", 1, 2)
505
+ expect_too_few_args(conn, "lookup_nwfilter_by_name")
506
+ expect_invalid_arg_type(conn, "lookup_nwfilter_by_name", 1)
507
+
508
+ expect_success(conn, "name arg", "lookup_nwfilter_by_name", "ruby-libvirt-tester")
509
+
510
+ newnw.undefine
511
+
512
+ # TESTGROUP: conn.lookup_nwfilter_by_uuid
513
+ newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
514
+
515
+ expect_too_many_args(conn, "lookup_nwfilter_by_uuid", 1, 2)
516
+ expect_too_few_args(conn, "lookup_nwfilter_by_uuid")
517
+ expect_invalid_arg_type(conn, "lookup_nwfilter_by_uuid", 1)
518
+
519
+ expect_success(conn, "uuid arg", "lookup_nwfilter_by_uuid", $NWFILTER_UUID) {|x| x.uuid == $NWFILTER_UUID}
520
+
521
+ newnw.undefine
522
+
523
+ # TESTGROUP: conn.define_nwfilter_xml
524
+ expect_too_many_args(conn, "define_nwfilter_xml", 1, 2)
525
+ expect_too_few_args(conn, "define_nwfilter_xml")
526
+ expect_invalid_arg_type(conn, "define_nwfilter_xml", 1)
527
+ expect_invalid_arg_type(conn, "define_nwfilter_xml", nil)
528
+ expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_nwfilter_xml", "hello")
529
+
530
+ newnw = expect_success(conn, "nwfilter XML", "define_nwfilter_xml", $new_nwfilter_xml)
531
+
532
+ newnw.undefine
533
+
534
+ # TESTGROUP: conn.num_of_secrets
535
+ expect_too_many_args(conn, "num_of_secrets", 1)
536
+ expect_success(conn, "no args", "num_of_secrets")
537
+
538
+ # TESTGROUP: conn.list_secrets
539
+ expect_too_many_args(conn, "list_secrets", 1)
540
+ expect_success(conn, "no args", "list_secrets")
541
+
542
+ # TESTGROUP: conn.lookup_secret_by_uuid
543
+ newsecret = conn.define_secret_xml($new_secret_xml)
544
+
545
+ expect_too_many_args(conn, "lookup_secret_by_uuid", 1, 2)
546
+ expect_too_few_args(conn, "lookup_secret_by_uuid")
547
+ expect_invalid_arg_type(conn, "lookup_secret_by_uuid", 1)
548
+
549
+ expect_success(conn, "uuid arg", "lookup_secret_by_uuid", $SECRET_UUID) {|x| x.uuid == $SECRET_UUID}
550
+
551
+ newsecret.undefine
552
+
553
+ # TESTGROUP: conn.lookup_secret_by_usage
554
+ newsecret = conn.define_secret_xml($new_secret_xml)
555
+
556
+ expect_too_many_args(conn, "lookup_secret_by_usage", 1, 2, 3)
557
+ expect_too_few_args(conn, "lookup_secret_by_usage")
558
+ expect_invalid_arg_type(conn, "lookup_secret_by_usage", 'foo', 1)
559
+ expect_invalid_arg_type(conn, "lookup_secret_by_usage", 1, 2)
560
+ expect_fail(conn, Libvirt::RetrieveError, "invalid secret", "lookup_secret_by_usage", Libvirt::Secret::USAGE_TYPE_VOLUME, "foo")
561
+
562
+ expect_success(conn, "usage type and key", "lookup_secret_by_usage", Libvirt::Secret::USAGE_TYPE_VOLUME, "/var/lib/libvirt/images/mail.img")
563
+
564
+ newsecret.undefine
565
+
566
+ # TESTGROUP: conn.define_secret_xml
567
+ expect_too_many_args(conn, "define_secret_xml", 1, 2, 3)
568
+ expect_too_few_args(conn, "define_secret_xml")
569
+ expect_invalid_arg_type(conn, "define_secret_xml", 1)
570
+ expect_invalid_arg_type(conn, "define_secret_xml", nil)
571
+ expect_invalid_arg_type(conn, "define_secret_xml", "hello", 'foo')
572
+ expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_secret_xml", "hello")
573
+
574
+ expect_success(conn, "secret XML", "define_secret_xml", $new_secret_xml)
575
+
576
+ newsecret.undefine
577
+
578
+ # TESTGROUP: conn.list_storage_pools
579
+ expect_too_many_args(conn, "list_storage_pools", 1)
580
+ expect_success(conn, "no args", "list_storage_pools")
581
+
582
+ # TESTGROUP: conn.num_of_storage_pools
583
+ expect_too_many_args(conn, "num_of_storage_pools", 1)
584
+ expect_success(conn, "no args", "num_of_storage_pools")
585
+
586
+ # TESTGROUP: conn.list_defined_storage_pools
587
+ expect_too_many_args(conn, "list_defined_storage_pools", 1)
588
+ expect_success(conn, "no args", "list_defined_storage_pools")
589
+
590
+ # TESTGROUP: conn.num_of_defined_storage_pools
591
+ expect_too_many_args(conn, "num_of_defined_storage_pools", 1)
592
+ expect_success(conn, "no args", "num_of_defined_storage_pools")
593
+
594
+ # TESTGROUP: conn.lookup_storage_pool_by_name
595
+ newpool = conn.create_storage_pool_xml($new_storage_pool_xml)
596
+
597
+ expect_too_many_args(conn, "lookup_storage_pool_by_name", 1, 2)
598
+ expect_too_few_args(conn, "lookup_storage_pool_by_name")
599
+ expect_invalid_arg_type(conn, "lookup_storage_pool_by_name", 1)
600
+ expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_storage_pool_by_name", "foobarbazsucker")
601
+
602
+ expect_success(conn, "name arg", "lookup_storage_pool_by_name", "ruby-libvirt-tester")
603
+
604
+ newpool.destroy
605
+
606
+ newpool = conn.define_storage_pool_xml($new_storage_pool_xml)
607
+ expect_success(conn, "name arg", "lookup_storage_pool_by_name", "ruby-libvirt-tester")
608
+ newpool.undefine
609
+
610
+ # TESTGROUP: conn.lookup_storage_pool_by_uuid
611
+ newpool = conn.create_storage_pool_xml($new_storage_pool_xml)
612
+
613
+ expect_too_many_args(conn, "lookup_storage_pool_by_uuid", 1, 2)
614
+ expect_too_few_args(conn, "lookup_storage_pool_by_uuid")
615
+ expect_invalid_arg_type(conn, "lookup_storage_pool_by_uuid", 1)
616
+ expect_fail(conn, Libvirt::RetrieveError, "non-existent uuid arg", "lookup_storage_pool_by_uuid", "foobarbazsucker")
617
+
618
+ expect_success(conn, "uuid arg", "lookup_storage_pool_by_uuid", $POOL_UUID)
619
+
620
+ newpool.destroy
621
+
622
+ newpool = conn.define_storage_pool_xml($new_storage_pool_xml)
623
+
624
+ expect_success(conn, "uuid arg", "lookup_storage_pool_by_uuid", $POOL_UUID)
625
+
626
+ newpool.undefine
627
+
628
+ # TESTGROUP: conn.create_storage_pool_xml
629
+ expect_too_many_args(conn, "create_storage_pool_xml", $new_storage_pool_xml, 0, 1)
630
+ expect_too_few_args(conn, "create_storage_pool_xml")
631
+ expect_invalid_arg_type(conn, "create_storage_pool_xml", nil)
632
+ expect_invalid_arg_type(conn, "create_storage_pool_xml", 1)
633
+ expect_invalid_arg_type(conn, "create_storage_pool_xml", $new_storage_pool_xml, "foo")
634
+ expect_fail(conn, Libvirt::Error, "invalid xml", "create_storage_pool_xml", "hello")
635
+
636
+ expect_success(conn, "storage pool XML", "create_storage_pool_xml", $new_storage_pool_xml)
637
+
638
+ expect_fail(conn, Libvirt::Error, "already existing domain", "create_storage_pool_xml", $new_storage_pool_xml)
639
+
640
+ newpool.destroy
641
+
642
+ # TESTGROUP: conn.define_storage_pool_xml
643
+ expect_too_many_args(conn, "define_storage_pool_xml", $new_storage_pool_xml, 0, 1)
644
+ expect_too_few_args(conn, "define_storage_pool_xml")
645
+ expect_invalid_arg_type(conn, "define_storage_pool_xml", nil)
646
+ expect_invalid_arg_type(conn, "define_storage_pool_xml", 1)
647
+ expect_invalid_arg_type(conn, "define_storage_pool_xml", $new_storage_pool_xml, "foo")
648
+ expect_fail(conn, Libvirt::Error, "invalid xml", "define_storage_pool_xml", "hello")
649
+
650
+ expect_success(conn, "storage pool XML", "define_storage_pool_xml", $new_storage_pool_xml)
651
+
652
+ newpool.undefine
653
+
654
+ # TESTGROUP: conn.discover_storage_pool_sources
655
+ expect_too_many_args(conn, "discover_storage_pool_sources", 1, 2, 3, 4)
656
+ expect_too_few_args(conn, "discover_storage_pool_sources")
657
+ expect_invalid_arg_type(conn, "discover_storage_pool_sources", 1)
658
+ expect_invalid_arg_type(conn, "discover_storage_pool_sources", "foo", 1)
659
+ expect_invalid_arg_type(conn, "discover_storage_pool_sources", "foo", "bar", "baz")
660
+
661
+ expect_fail(conn, Libvirt::Error, "invalid pool type", "discover_storage_pool_sources", "foo")
662
+
663
+ expect_success(conn, "pool type", "discover_storage_pool_sources", "logical")
664
+
665
+ # TESTGROUP: conn.sys_info
666
+ expect_too_many_args(conn, "sys_info", 1, 2)
667
+ expect_invalid_arg_type(conn, "sys_info", "foo")
668
+
669
+ expect_success(conn, "system info", "sys_info")
670
+
201
671
  conn.close
202
672
 
203
673
  finish_tests