libvirt_ffi 0.7.0 → 0.8.0

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,47 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'libvirt'
6
+ require 'logger'
7
+ require 'active_support/all'
8
+ require 'async'
9
+ require 'json'
10
+
11
+ require_relative 'support/libvirt_async'
12
+ require_relative 'support/log_formatter'
13
+
14
+ require 'libvirt/xml'
15
+
16
+ Libvirt.logger = Logger.new(STDOUT, formatter: LogFormatter.new)
17
+ Libvirt.logger.level = ENV['DEBUG'] ? :debug : :info
18
+
19
+ IMPL = LibvirtAsync::Implementations.new
20
+
21
+ Async do
22
+ ASYNC_REACTOR = Async::Task.current.reactor
23
+
24
+ puts "Lib version #{Libvirt.lib_version}"
25
+ puts "Gem version #{Libvirt::VERSION}"
26
+
27
+ IMPL.start
28
+
29
+ conn = Libvirt::Connection.new('qemu+tcp://localhost:16510/system')
30
+ conn.open
31
+
32
+ puts "Connection version #{conn.version.inspect}"
33
+ puts "Connection lib_version #{conn.lib_version.inspect}"
34
+ puts "Connection hostname #{conn.hostname.inspect}"
35
+
36
+ interfaces = conn.list_all_interfaces
37
+ puts "Connection interfaces qty #{interfaces.size}"
38
+
39
+ interfaces.each.with_index do |interface, i|
40
+ puts "Interface #{i} name=#{interface.name}"
41
+ puts "Interface #{i} active?=#{interface.active?}"
42
+ puts "Interface #{i} mac=#{interface.mac}"
43
+ puts "Interface #{i} xml_desc", interface.xml_desc
44
+ puts "Interface #{i} xml", JSON.pretty_generate(Libvirt::Xml::Interface.load(interface.xml_desc).to_h)
45
+ end
46
+
47
+ end
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'libvirt'
6
+ require 'logger'
7
+ require 'active_support/all'
8
+ require 'async'
9
+ require 'json'
10
+
11
+ require_relative 'support/libvirt_async'
12
+ require_relative 'support/log_formatter'
13
+
14
+ require 'libvirt/xml'
15
+
16
+ Libvirt.logger = Logger.new(STDOUT, formatter: LogFormatter.new)
17
+ Libvirt.logger.level = ENV['DEBUG'] ? :debug : :info
18
+
19
+ IMPL = LibvirtAsync::Implementations.new
20
+
21
+ Async do
22
+ ASYNC_REACTOR = Async::Task.current.reactor
23
+
24
+ puts "Lib version #{Libvirt.lib_version}"
25
+ puts "Gem version #{Libvirt::VERSION}"
26
+
27
+ IMPL.start
28
+
29
+ conn = Libvirt::Connection.new('qemu+tcp://localhost:16510/system')
30
+ conn.open
31
+
32
+ puts "Connection version #{conn.version.inspect}"
33
+ puts "Connection lib_version #{conn.lib_version.inspect}"
34
+ puts "Connection hostname #{conn.hostname.inspect}"
35
+
36
+ networks = conn.list_all_networks
37
+ puts "Connection networks qty #{networks.size}"
38
+
39
+ networks.each.with_index do |network, i|
40
+ puts "Network #{i} uuid=#{network.uuid}"
41
+ puts "Network #{i} name=#{network.name}"
42
+ puts "Network #{i} active?=#{network.active?}"
43
+ puts "Network #{i} persistent?=#{network.persistent?}"
44
+ puts "Network #{i} auto_start=#{network.auto_start?}"
45
+ puts "Network #{i} bridge_name=#{network.bridge_name}"
46
+ puts "Network #{i} xml_desc", network.xml_desc
47
+ puts "Network #{i} xml", JSON.pretty_generate(Libvirt::Xml::Network.load(network.xml_desc).to_h)
48
+ end
49
+
50
+ networks.each.with_index do |network, i|
51
+ dhcp_leases = network.dhcp_leases
52
+ puts "Network #{i} DHCP Leases size=#{dhcp_leases.size}"
53
+
54
+ dhcp_leases.each.with_index do |dhcp, j|
55
+ puts "Network #{i} DHCP Lease #{j} name=#{dhcp.name}"
56
+ puts "Network #{i} DHCP Lease #{j} iface=#{dhcp.iface}"
57
+ puts "Network #{i} DHCP Lease #{j} expirytime=#{dhcp.expirytime}"
58
+ puts "Network #{i} DHCP Lease #{j} type=#{dhcp.type}"
59
+ puts "Network #{i} DHCP Lease #{j} mac=#{dhcp.mac}"
60
+ puts "Network #{i} DHCP Lease #{j} iaid=#{dhcp.iaid}"
61
+ puts "Network #{i} DHCP Lease #{j} ipaddr=#{dhcp.ipaddr}"
62
+ puts "Network #{i} DHCP Lease #{j} prefix=#{dhcp.prefix}"
63
+ puts "Network #{i} DHCP Lease #{j} hostname=#{dhcp.hostname}"
64
+ puts "Network #{i} DHCP Lease #{j} clientid=#{dhcp.clientid}"
65
+ end
66
+ end
67
+
68
+ puts 'register_network_event_callback'
69
+ conn.register_network_event_callback(:LIFECYCLE) do |_c, net, event, detail, opaque|
70
+ puts "NETWORK LIFECYCLE EVENT name=#{net.name}, event=#{event}, detail=#{detail}, opaque=#{opaque}"
71
+ end
72
+
73
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libvirt_ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Talakevich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-03 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -70,9 +70,14 @@ files:
70
70
  - lib/libvirt/ffi/event.rb
71
71
  - lib/libvirt/ffi/helpers.rb
72
72
  - lib/libvirt/ffi/host.rb
73
+ - lib/libvirt/ffi/interface.rb
74
+ - lib/libvirt/ffi/network.rb
73
75
  - lib/libvirt/ffi/storage.rb
74
76
  - lib/libvirt/ffi/stream.rb
75
77
  - lib/libvirt/host_callback_storage.rb
78
+ - lib/libvirt/interface.rb
79
+ - lib/libvirt/network.rb
80
+ - lib/libvirt/network_dhcp_lease.rb
76
81
  - lib/libvirt/node_info.rb
77
82
  - lib/libvirt/storage_pool.rb
78
83
  - lib/libvirt/storage_pool_info.rb
@@ -86,8 +91,11 @@ files:
86
91
  - lib/libvirt/xml/domain.rb
87
92
  - lib/libvirt/xml/generic.rb
88
93
  - lib/libvirt/xml/graphics.rb
94
+ - lib/libvirt/xml/interface.rb
95
+ - lib/libvirt/xml/ip_address.rb
89
96
  - lib/libvirt/xml/max_vcpu.rb
90
97
  - lib/libvirt/xml/memory.rb
98
+ - lib/libvirt/xml/network.rb
91
99
  - lib/libvirt/xml/storage_pool.rb
92
100
  - lib/libvirt/xml/storage_volume.rb
93
101
  - lib/libvirt/xml/vcpu.rb
@@ -97,8 +105,10 @@ files:
97
105
  - test_usage/support/log_formatter.rb
98
106
  - test_usage/test_domain.rb
99
107
  - test_usage/test_event_loop.rb
108
+ - test_usage/test_interface.rb
100
109
  - test_usage/test_libvirtd_restart.rb
101
110
  - test_usage/test_metadata.rb
111
+ - test_usage/test_network.rb
102
112
  - test_usage/test_screenshot.rb
103
113
  - test_usage/test_storage.rb
104
114
  homepage: https://github.com/senid231/libvirt_ffi