dbus-systemd 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +162 -2
- data/TODO.txt +9 -0
- data/Vagrantfile +4 -3
- data/dbus-systemd.gemspec +1 -1
- data/lib/dbus/systemd.rb +11 -20
- data/lib/dbus/systemd/helpers.rb +27 -0
- data/lib/dbus/systemd/hostnamed.rb +25 -0
- data/lib/dbus/systemd/importd.rb +6 -0
- data/lib/dbus/systemd/importd/manager.rb +53 -0
- data/lib/dbus/systemd/importd/transfer.rb +19 -0
- data/lib/dbus/systemd/job.rb +2 -2
- data/lib/dbus/systemd/localed.rb +25 -0
- data/lib/dbus/systemd/logind.rb +8 -0
- data/lib/dbus/systemd/logind/manager.rb +110 -0
- data/lib/dbus/systemd/logind/seat.rb +20 -0
- data/lib/dbus/systemd/logind/session.rb +20 -0
- data/lib/dbus/systemd/logind/user.rb +20 -0
- data/lib/dbus/systemd/machined.rb +6 -0
- data/lib/dbus/systemd/machined/image.rb +20 -0
- data/lib/dbus/systemd/machined/machine.rb +20 -0
- data/lib/dbus/systemd/machined/manager.rb +80 -0
- data/lib/dbus/systemd/manager.rb +19 -20
- data/lib/dbus/systemd/mixin.rb +21 -0
- data/lib/dbus/systemd/resolved.rb +6 -0
- data/lib/dbus/systemd/resolved/link.rb +20 -0
- data/lib/dbus/systemd/resolved/manager.rb +26 -0
- data/lib/dbus/systemd/timedated.rb +21 -0
- data/lib/dbus/systemd/unit.rb +2 -2
- data/lib/dbus/systemd/unit/automount.rb +1 -1
- data/lib/dbus/systemd/version.rb +1 -1
- metadata +190 -4
- data/lib/dbus/systemd/method_missing.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6971dca0ff26c382c81cea722a06a5e4d5b45cf
|
4
|
+
data.tar.gz: 01a290eafbaa8eb1ab35fdca91733b25d46f1628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acb062c0bd2b6c33754e6b2427b8c7dd72fd15d5ae360a5d41171e5a9a4daeb9064b5f4770a805c1517fe2a0f24991c42f8cac2ff2eae66f49eb8db2f8ee1d79
|
7
|
+
data.tar.gz: f4c1b0d9ee6b0a994bd01728f474ca22b8861591b01552ea5cf54f4392e762b360bc0fca807e11dd04111bf53fe89db53747f71daabb74ffd2ee52fdaea511ff
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# DBus::Systemd
|
2
2
|
|
3
3
|
Ruby library for simplifying access to systemd dbus interfaces.
|
4
4
|
|
5
5
|
Recommended Reading
|
6
6
|
|
7
|
+
- [introduction to d-bus concepts section of sd-bus announcement blog post](http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html)
|
7
8
|
- [systemd D-Bus specification](https://www.freedesktop.org/wiki/Software/systemd/dbus/)
|
8
9
|
- [D-Bus specification](https://dbus.freedesktop.org/doc/dbus-specification.html)
|
9
|
-
|
10
|
+
|
10
11
|
## Installation
|
11
12
|
|
12
13
|
Add this line to your application's Gemfile:
|
@@ -25,7 +26,166 @@ Or install it yourself as:
|
|
25
26
|
|
26
27
|
## Usage
|
27
28
|
|
29
|
+
### DBus::Systemd::Hostnamed
|
30
|
+
|
31
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/hostnamed/).
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
irb(main):001:0> h = DBus::Systemd::Hostnamed.new
|
35
|
+
=> ...
|
36
|
+
irb(main):002:0> h.object.methods - Object.methods
|
37
|
+
=> [:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :SetHostname, :SetStaticHostname, :SetPrettyHostname, :SetIconName, :SetChassis, :SetDeployment, :SetLocation, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
38
|
+
irb(main):004:0> h.Get(DBus::Systemd::Hostnamed::INTERFACE, 'Hostname').first
|
39
|
+
=> "derp.localdomain"
|
40
|
+
irb(main):005:0> h.SetHostname('my-hostname.localdomain', false)
|
41
|
+
=> []
|
42
|
+
irb(main):006:0> h.Get(DBus::Systemd::Hostnamed::INTERFACE, 'Hostname').first
|
43
|
+
=> "my-hostname.localdomain"
|
44
|
+
```
|
45
|
+
|
46
|
+
### DBus::Systemd::Importd
|
47
|
+
|
48
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/importd/).
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
irb(main):007:0> im = DBus::Systemd::Importd::Manager.new
|
52
|
+
=> ...
|
53
|
+
irb(main):008:0> im.object.methods - Object.methods
|
54
|
+
=> [:Set, :Get, :GetAll, :ListTransfers, :Ping, :GetMachineId, :Introspect, :ImportTar, :ImportRaw, :ExportTar, :ExportRaw, :PullTar, :PullRaw, :CancelTransfer, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
55
|
+
irb(main):008:0> im.PullRaw('https://dl.fedoraproject.org/pub/fedora/linux/releases/24/CloudImages/x86_64/images/Fedora-Cloud-Base-24-1.2.x86_64.raw.xz', 'Fedora-24', 'no', false)
|
56
|
+
=> [1, "/org/freedesktop/import1/transfer/_1"]
|
57
|
+
> im.transfers
|
58
|
+
=> [{:id=>1, :operation=>"pull-raw", :remote_file=>"https://dl.fedoraproject.org/pub/fedora/linux/releases/24/CloudImages/x86_64/images/Fedora-Cloud-Base-24-1.2.x86_64.raw.xz", :machine_name=>"Fedora-24", :progress=>0.0, :object_path=>"/org/freedesktop/import1/transfer/_1"}]
|
59
|
+
```
|
60
|
+
|
61
|
+
### DBus::Systemd::Localed
|
62
|
+
|
63
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/localed/).
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
irb(main):009:0> l = DBus::Systemd::Localed.new
|
67
|
+
=> ...
|
68
|
+
irb(main):010:0> l.object.methods - Object.methods
|
69
|
+
=> [:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :SetLocale, :SetVConsoleKeyboard, :SetX11Keyboard, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
70
|
+
irb(main):011:0> l.GetAll(DBus::Systemd::Localed::INTERFACE).first
|
71
|
+
=> {"Locale"=>["LANG=en_US.UTF-8"], "X11Layout"=>"", "X11Model"=>"", "X11Variant"=>"", "X11Options"=>"", "VConsoleKeymap"=>"us", "VConsoleKeymapToggle"=>""}
|
72
|
+
```
|
73
|
+
|
74
|
+
### DBus::Systemd::Logind
|
75
|
+
|
76
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/logind/).
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
irb(main):012:0> l = DBus::Systemd::Logind::Manager.new
|
80
|
+
=> ...
|
81
|
+
irb(main):013:0> l.object.methods - Object.methods
|
82
|
+
=> [:Set, :Get, :GetAll, :ListSeats, :ListSessions, :ListUsers, :GetSession, :GetUser, :GetSeat, :Ping, :GetMachineId, :Introspect, :GetSessionByPID, :GetUserByPID, :ListInhibitors, :CreateSession, :ReleaseSession, :ActivateSession, :ActivateSessionOnSeat, :LockSession, :UnlockSession, :LockSessions, :UnlockSessions, :KillSession, :KillUser, :TerminateSession, :TerminateUser, :TerminateSeat, :SetUserLinger, :AttachDevice, :FlushDevices, :PowerOff, :Reboot, :Suspend, :Hibernate, :HybridSleep, :CanPowerOff, :CanReboot, :CanSuspend, :CanHibernate, :CanHybridSleep, :ScheduleShutdown, :CancelScheduledShutdown, :Inhibit, :CanRebootToFirmwareSetup, :SetRebootToFirmwareSetup, :SetWallMessage, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
83
|
+
irb(main):014:0> l.users
|
84
|
+
=> [{:id=>1000, :name=>"vagrant", :object_path=>"/org/freedesktop/login1/user/_1000"}]
|
85
|
+
irb(main):015:0> l.seats
|
86
|
+
=> [{:id=>"seat0", :object_path=>"/org/freedesktop/login1/seat/seat0"}]
|
87
|
+
irb(main):016:0> l.sessions
|
88
|
+
=> [{:id=>"3", :user_id=>1000, :user_name=>"vagrant", :seat_id=>"", :object_path=>"/org/freedesktop/login1/session/_33"}]
|
89
|
+
irb(main):017:0> u = l.user(1000)
|
90
|
+
=> ...
|
91
|
+
irb(main):019:0> u.GetAll(DBus::Systemd::Logind::User::INTERFACE).first
|
92
|
+
=> {"UID"=>1000, "GID"=>1000, "Name"=>"vagrant", "Timestamp"=>1475452037907590, "TimestampMonotonic"=>122159600, "RuntimePath"=>"/run/user/1000", "Service"=>"user@1000.service", "Slice"=>"user-1000.slice", "Display"=>["3", "/org/freedesktop/login1/session/_33"], "State"=>"active", "Sessions"=>[["3", "/org/freedesktop/login1/session/_33"]], "IdleHint"=>false, "IdleSinceHint"=>0, "IdleSinceHintMonotonic"=>0, "Linger"=>false}
|
93
|
+
```
|
94
|
+
|
95
|
+
### DBus::Systemd::Machined
|
96
|
+
|
97
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/machined/).
|
28
98
|
|
99
|
+
```ruby
|
100
|
+
irb(main):021:0> mm = DBus::Systemd::Machined::Manager.new
|
101
|
+
=> ...
|
102
|
+
irb(main):022:0> mm.object.methods - Object.methods
|
103
|
+
=> [:Set, :Get, :GetAll, :ListMachines, :ListImages, :GetMachine, :GetImage, :Ping, :GetMachineId, :Introspect, :GetMachineByPID, :CreateMachine, :CreateMachineWithNetwork, :RegisterMachine, :RegisterMachineWithNetwork, :TerminateMachine, :KillMachine, :GetMachineAddresses, :GetMachineOSRelease, :OpenMachinePTY, :OpenMachineLogin, :OpenMachineShell, :BindMountMachine, :CopyFromMachine, :CopyToMachine, :RemoveImage, :RenameImage, :CloneImage, :MarkImageReadOnly, :SetPoolLimit, :SetImageLimit, :MapFromMachineUser, :MapToMachineUser, :MapFromMachineGroup, :MapToMachineGroup, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
104
|
+
irb(main):024:0> mm.machines
|
105
|
+
=> [{:name=>".host", :class=>"host", :service_id=>"", :object_path=>"/org/freedesktop/machine1/machine/_2ehost"}]
|
106
|
+
irb(main):023:0> mm.images
|
107
|
+
=> [{:name=>"Fedora-23", :type=>"raw", :read_only=>false, :creation_time=>1446171608000000, :modification_time=>1446171608000000, :disk_space=>589676544, :object_path=>"/org/freedesktop/machine1/image/Fedora_2d23"}, {:name=>".raw-https:\\x2f\\x2fdl\\x2efedoraproject\\x2eorg\\x2fpub\\x2ffedora\\x2flinux\\x2freleases\\x2f24\\x2fCloudImages\\x2fx86_64\\x2fimages\\x2fFedora-Cloud-Base-24-1\\x2e2\\x2ex86_64\\x2eraw\\x2exz.\\x227fef0a4-5353f9c7441a0\\x22", :type=>"raw", :read_only=>true, :creation_time=>1465922207000000, :modification_time=>1465922207000000, :disk_space=>540872704, :object_path=>"/org/freedesktop/machine1/image/_2eraw_2dhttps_3a_5cx2f_5cx2fdl_5cx2efedoraproject_5cx2eorg_5cx2fpub_5cx2ffedora_5cx2flinux_5cx2freleases_5cx2f24_5cx2fCloudImages_5cx2fx86_5f64_5cx2fimages_5cx2fFedora_2dCloud_2dBase_2d24_2d1_5cx2e2_5cx2ex86_5f64_5cx2eraw_5cx2exz_2e_5cx227fef0a4_2d5353f9c7441a0_5cx22"}, {:name=>".raw-https:\\x2f\\x2fdl\\x2efedoraproject\\x2eorg\\x2fpub\\x2ffedora\\x2flinux\\x2freleases\\x2f23\\x2fCloud\\x2fx86_64\\x2fImages\\x2fFedora-Cloud-Base-23-20151030\\x2ex86_64\\x2eraw\\x2exz.\\x229205894-5234910faa600\\x22", :type=>"raw", :read_only=>true, :creation_time=>1446171608000000, :modification_time=>1446171608000000, :disk_space=>589676544, :object_path=>"/org/freedesktop/machine1/image/_2eraw_2dhttps_3a_5cx2f_5cx2fdl_5cx2efedoraproject_5cx2eorg_5cx2fpub_5cx2ffedora_5cx2flinux_5cx2freleases_5cx2f23_5cx2fCloud_5cx2fx86_5f64_5cx2fImages_5cx2fFedora_2dCloud_2dBase_2d23_2d20151030_5cx2ex86_5f64_5cx2eraw_5cx2exz_2e_5cx229205894_2d5234910faa600_5cx22"}, {:name=>"Fedora-24", :type=>"raw", :read_only=>false, :creation_time=>1465922207000000, :modification_time=>1465922207000000, :disk_space=>540872704, :object_path=>"/org/freedesktop/machine1/image/Fedora_2d24"}, {:name=>"test", :type=>"raw", :read_only=>false, :creation_time=>1446171608000000, :modification_time=>1446171608000000, :disk_space=>589676544, :object_path=>"/org/freedesktop/machine1/image/test"}, {:name=>".host", :type=>"directory", :read_only=>false, :creation_time=>0, :modification_time=>0, :disk_space=>18446744073709551615, :object_path=>"/org/freedesktop/machine1/image/_2ehost"}]
|
108
|
+
irb(main):025:0> mm.GetAll(DBus::Systemd::Machined::Manager::INTERFACE).first
|
109
|
+
=> {"PoolPath"=>"/var/lib/machines", "PoolUsage"=>1191448576, "PoolLimit"=>2105020416}
|
110
|
+
irb(main):026:0> mi = mm.image('Fedora-24')
|
111
|
+
=> ...
|
112
|
+
irb(main):027:0> mi.object.methods - Object.methods
|
113
|
+
=> [:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :Remove, :Rename, :Clone, :MarkReadOnly, :SetLimit, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
114
|
+
irb(main):028:0> mi.GetAll(DBus::Systemd::Machined::Image::INTERFACE).first
|
115
|
+
=> {"Name"=>"Fedora-24", "Path"=>"/var/lib/machines/Fedora-24.raw", "Type"=>"raw", "ReadOnly"=>false, "CreationTimestamp"=>1465922207000000, "ModificationTimestamp"=>1465922207000000, "Usage"=>540872704, "Limit"=>3221225472, "UsageExclusive"=>540872704, "LimitExclusive"=>3221225472}
|
116
|
+
irb(main):029:0> machine = mm.machine('.host')
|
117
|
+
=> ..
|
118
|
+
irb(main):030:0> machine.object.methods - Object.methods
|
119
|
+
=> [:Set, :Get, :GetAll, :Kill, :Ping, :GetMachineId, :Introspect, :Terminate, :GetAddresses, :GetOSRelease, :OpenPTY, :OpenLogin, :OpenShell, :BindMount, :CopyFrom, :CopyTo, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
120
|
+
irb(main):032:0> machine.GetAll(DBus::Systemd::Machined::Machine::INTERFACE).first
|
121
|
+
=> {"Name"=>".host", "Id"=>[77, 46, 68, 242, 105, 232, 78, 52, 157, 152, 76, 171, 175, 145, 140, 130], "Timestamp"=>1475451915747985, "TimestampMonotonic"=>0, "Service"=>"", "Unit"=>"-.slice", "Leader"=>1, "Class"=>"host", "RootDirectory"=>"/", "NetworkInterfaces"=>[], "State"=>"running"}
|
122
|
+
```
|
123
|
+
|
124
|
+
### DBus::Systemd::Resolved
|
125
|
+
|
126
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/resolved/).
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
irb(main):030:0> rm = DBus::Systemd::Resolved::Manager.new
|
130
|
+
=> ...
|
131
|
+
irb(main):030:0> rm.object.methods - Object.methods
|
132
|
+
=> [:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :GetLink, :ResolveHostname, :ResolveAddress, :ResolveRecord, :ResolveService, :ResetStatistics, :SetLinkDNS, :SetLinkDomains, :SetLinkLLMNR, :SetLinkMulticastDNS, :SetLinkDNSSEC, :SetLinkDNSSECNegativeTrustAnchors, :RevertLink, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
133
|
+
irb(main):030:0> rm.Get(DBus::Resolved::Manager::INTERFACE, 'DNSSECSupported').first
|
134
|
+
=> false
|
135
|
+
```
|
136
|
+
|
137
|
+
### DBus::Systemd::Timedated
|
138
|
+
|
139
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/timedated/).
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
irb(main):030:0> t = DBus::Systemd::Timedated.new
|
143
|
+
=> ...
|
144
|
+
irb(main):030:0> t.object.methods - Object.methods
|
145
|
+
=> [:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :SetTime, :SetTimezone, :SetLocalRTC, :SetNTP, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
146
|
+
irb(main):030:0> t.GetAll(DBus::Systemd::Timedated::INTERFACE).first
|
147
|
+
=> {"Timezone"=>"UTC", "LocalRTC"=>true, "CanNTP"=>true, "NTP"=>false, "NTPSynchronized"=>true, "TimeUSec"=>1475454744352557, "RTCTimeUSec"=>1475454742000000}
|
148
|
+
irb(main):030:0> t.SetTimezone('America/Los_Angeles', false)
|
149
|
+
=> []
|
150
|
+
irb(main):030:0> t.Get(DBus::Systemd::Timedated::INTERFACE, 'Timezone').first
|
151
|
+
=> "America/Los_Angeles"
|
152
|
+
```
|
153
|
+
|
154
|
+
### DBus::Systemd::Manager
|
155
|
+
|
156
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/dbus/).
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
irb(main):030:0> mgr = DBus::Systemd::Manager.new
|
160
|
+
=> ...
|
161
|
+
irb(main):030:0> mgr.object.methods - Object.methods
|
162
|
+
=> [:Set, :Get, :ListUnits, :GetAll, :GetUnit, :GetJob, :Ping, :GetMachineId, :Introspect, :GetUnitByPID, :LoadUnit, :StartUnit, :StartUnitReplace, :StopUnit, :ReloadUnit, :RestartUnit, :TryRestartUnit, :ReloadOrRestartUnit, :ReloadOrTryRestartUnit, :KillUnit, :ResetFailedUnit, :SetUnitProperties, :StartTransientUnit, :CancelJob, :ClearJobs, :ResetFailed, :ListUnitsFiltered, :ListJobs, :Subscribe, :Unsubscribe, :Dump, :CreateSnapshot, :RemoveSnapshot, :Reload, :Reexecute, :Exit, :Reboot, :PowerOff, :Halt, :KExec, :SwitchRoot, :SetEnvironment, :UnsetEnvironment, :UnsetAndSetEnvironment, :ListUnitFiles, :GetUnitFileState, :EnableUnitFiles, :DisableUnitFiles, :ReenableUnitFiles, :LinkUnitFiles, :PresetUnitFiles, :PresetUnitFilesWithMode, :MaskUnitFiles, :UnmaskUnitFiles, :SetDefaultTarget, :GetDefaultTarget, :PresetAllUnitFiles, :AddDependencyUnitFiles, :SetExitCode, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
163
|
+
irb(main):030:0> mgr.GetDefaultTarget.first
|
164
|
+
=> "multi-user.target"
|
165
|
+
irb(main):036:0> mgr.Get(DBus::Systemd::Manager::INTERFACE, 'Version').first
|
166
|
+
=> "229"
|
167
|
+
irb(main):037:0> mgr.Get(DBus::Systemd::Manager::INTERFACE, 'UnitPath').first
|
168
|
+
=> ["/etc/systemd/system", "/run/systemd/system", "/run/systemd/generator", "/usr/local/lib/systemd/system", "/usr/lib/systemd/system", "/run/systemd/generator.late"]
|
169
|
+
irb(main):038:0> mgr.Get(DBus::Systemd::Manager::INTERFACE, 'NFailedUnits').first
|
170
|
+
=> 0
|
171
|
+
```
|
172
|
+
|
173
|
+
### DBus::Systemd::Unit
|
174
|
+
|
175
|
+
For full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/dbus/).
|
176
|
+
|
177
|
+
```ruby
|
178
|
+
irb(main):005:0> sshd = DBus::Systemd::Unit.new('sshd.service')
|
179
|
+
=> ...
|
180
|
+
irb(main):006:0> sshd.object.methods - Object.methods
|
181
|
+
=> [:Set, :Get, :GetAll, :Kill, :Ping, :GetMachineId, :Introspect, :ResetFailed, :Reload, :Start, :Stop, :Restart, :TryRestart, :ReloadOrRestart, :ReloadOrTryRestart, :SetProperties, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]
|
182
|
+
irb(main):007:0> sshd.Get(DBus::Systemd::Unit::INTERFACE, 'Wants').first
|
183
|
+
=> ["sshd-keygen.target"]
|
184
|
+
irb(main):008:0> sshd.Get(DBus::Systemd::Unit::Service::INTERFACE, 'ExecStart').first
|
185
|
+
=> [["/usr/sbin/sshd", ["/usr/sbin/sshd", "$OPTIONS"], false, 1475455155565079, 3239817089, 1475455155581392, 3239833403, 5860, 1, 0]]
|
186
|
+
irb(main):010:0> sshd.Restart('replace')
|
187
|
+
=> ["/org/freedesktop/systemd1/job/3326"]
|
188
|
+
```
|
29
189
|
|
30
190
|
## Development
|
31
191
|
|
data/TODO.txt
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
~~systemd: https://www.freedesktop.org/wiki/Software/systemd/dbus/~~
|
2
|
+
~~logind: https://www.freedesktop.org/wiki/Software/systemd/logind/~~
|
3
|
+
~~machined: https://www.freedesktop.org/wiki/Software/systemd/machined/~~
|
4
|
+
~~importd: https://wiki.freedesktop.org/www/Software/systemd/importd/~~
|
5
|
+
~~hostnamed: https://www.freedesktop.org/wiki/Software/systemd/hostnamed/~~
|
6
|
+
~~localed: https://www.freedesktop.org/wiki/Software/systemd/localed/~~
|
7
|
+
~~timedated: https://www.freedesktop.org/wiki/Software/systemd/timedated/~~
|
8
|
+
networkd: ??
|
9
|
+
~~resolved: https://www.freedesktop.org/wiki/Software/systemd/resolved/~~
|
data/Vagrantfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- mode: ruby -*-
|
2
2
|
# vi: set ft=ruby :
|
3
3
|
|
4
|
-
Vagrant.configure(
|
5
|
-
config.vm.box =
|
4
|
+
Vagrant.configure('2') do |config|
|
5
|
+
config.vm.box = 'bento/fedora-24'
|
6
|
+
config.vm.box_version = '2.2.9'
|
6
7
|
config.vm.box_check_update = true
|
7
8
|
|
8
9
|
config.vm.provision "shell", inline: <<-SHELL
|
9
|
-
dnf install -y git ruby rubygem-bundler
|
10
|
+
dnf install -y git ruby rubygem-bundler systemd-container btrfs-progs
|
10
11
|
SHELL
|
11
12
|
end
|
data/dbus-systemd.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["nath.e.will@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = 'library for interfacing with systemd over dbus'
|
13
|
-
spec.description =
|
13
|
+
spec.description = IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
14
14
|
spec.homepage = "https://github.com/nathwill/ruby-dbus-systemd"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
data/lib/dbus/systemd.rb
CHANGED
@@ -1,22 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
DBus::SystemBus.instance
|
9
|
-
end
|
10
|
-
|
11
|
-
def session_bus
|
12
|
-
DBus::SessionBus.instance
|
13
|
-
end
|
14
|
-
|
15
|
-
module_function :system_bus, :session_bus
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
require_relative 'systemd/version'
|
1
|
+
require_relative 'systemd/helpers'
|
2
|
+
require_relative 'systemd/hostnamed'
|
3
|
+
require_relative 'systemd/importd'
|
4
|
+
require_relative 'systemd/job'
|
5
|
+
require_relative 'systemd/localed'
|
6
|
+
require_relative 'systemd/logind'
|
7
|
+
require_relative 'systemd/machined'
|
20
8
|
require_relative 'systemd/manager'
|
9
|
+
require_relative 'systemd/mixin'
|
10
|
+
require_relative 'systemd/resolved'
|
11
|
+
require_relative 'systemd/timedated'
|
21
12
|
require_relative 'systemd/unit'
|
22
|
-
require_relative 'systemd/
|
13
|
+
require_relative 'systemd/version'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'dbus'
|
2
|
+
|
3
|
+
module DBus
|
4
|
+
module Systemd
|
5
|
+
module Helpers
|
6
|
+
def system_bus
|
7
|
+
DBus::SystemBus.instance
|
8
|
+
end
|
9
|
+
|
10
|
+
def session_bus
|
11
|
+
DBus::SessionBus.instance
|
12
|
+
end
|
13
|
+
|
14
|
+
def map_array(array, map)
|
15
|
+
mapped = {}
|
16
|
+
|
17
|
+
array.each_with_index do |item, index|
|
18
|
+
mapped[map.key(index)] = item
|
19
|
+
end
|
20
|
+
|
21
|
+
mapped
|
22
|
+
end
|
23
|
+
|
24
|
+
module_function :system_bus, :session_bus, :map_array
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#
|
2
|
+
# See docs for full API description:
|
3
|
+
# https://www.freedesktop.org/wiki/Software/systemd/hostnamed/
|
4
|
+
#
|
5
|
+
require_relative 'helpers'
|
6
|
+
require_relative 'mixin'
|
7
|
+
|
8
|
+
module DBus
|
9
|
+
module Systemd
|
10
|
+
class Hostnamed
|
11
|
+
NODE = '/org/freedesktop/hostname1'
|
12
|
+
INTERFACE = 'org.freedesktop.hostname1'
|
13
|
+
|
14
|
+
include Mixin::MethodMissing
|
15
|
+
|
16
|
+
attr_reader :service
|
17
|
+
|
18
|
+
def initialize(bus = Helpers.system_bus)
|
19
|
+
@service = bus.service(INTERFACE)
|
20
|
+
@object = @service.object(NODE)
|
21
|
+
.tap(&:introspect)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative '../helpers'
|
2
|
+
require_relative '../mixin'
|
3
|
+
require_relative 'transfer'
|
4
|
+
|
5
|
+
module DBus
|
6
|
+
module Systemd
|
7
|
+
module Importd
|
8
|
+
INTERFACE = 'org.freedesktop.import1'
|
9
|
+
|
10
|
+
class Manager
|
11
|
+
NODE = '/org/freedesktop/import1'
|
12
|
+
INTERFACE = 'org.freedesktop.import1.Manager'
|
13
|
+
|
14
|
+
TRANSFER_INDICES = {
|
15
|
+
id: 0,
|
16
|
+
operation: 1,
|
17
|
+
remote_file: 2,
|
18
|
+
machine_name: 3,
|
19
|
+
progress: 4,
|
20
|
+
object_path: 5
|
21
|
+
}
|
22
|
+
|
23
|
+
include Systemd::Mixin::MethodMissing
|
24
|
+
|
25
|
+
attr_reader :service
|
26
|
+
|
27
|
+
def initialize(bus = Systemd::Helpers.system_bus)
|
28
|
+
@service = bus.service(Importd::INTERFACE)
|
29
|
+
@object = @service.object(NODE)
|
30
|
+
.tap(&:introspect)
|
31
|
+
end
|
32
|
+
|
33
|
+
def transfers
|
34
|
+
self.ListTransfers.first.map { |t| map_transfer(t) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def transfer(id)
|
38
|
+
Transfer.new(id, self)
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_transfer_by_path(path)
|
42
|
+
obj = @service.object(path)
|
43
|
+
.tap(&:introspect)
|
44
|
+
Transfer.new(obj.Get(Transfer::INTERFACE, 'Id').first, self)
|
45
|
+
end
|
46
|
+
|
47
|
+
def map_transfer(transfer_array)
|
48
|
+
Systemd::Helpers.map_array(transfer_array, TRANSFER_INDICES)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../mixin'
|
2
|
+
require_relative 'manager'
|
3
|
+
|
4
|
+
module DBus
|
5
|
+
module Systemd
|
6
|
+
module Importd
|
7
|
+
class Transfer
|
8
|
+
INTERFACE = 'org.freedesktop.import1.Transfer'
|
9
|
+
|
10
|
+
include Systemd::Mixin::MethodMissing
|
11
|
+
|
12
|
+
def initialize(id, manager = Manager.new)
|
13
|
+
@object = manager.service.object("#{Manager::NODE}/transfer/_#{id}")
|
14
|
+
.tap(&:introspect)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/dbus/systemd/job.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative 'method_missing'
|
2
1
|
require_relative 'manager'
|
2
|
+
require_relative 'mixin'
|
3
3
|
|
4
4
|
module DBus
|
5
5
|
module Systemd
|
6
6
|
class Job
|
7
7
|
INTERFACE = 'org.freedesktop.systemd1.Job'
|
8
8
|
|
9
|
-
include MethodMissing
|
9
|
+
include Mixin::MethodMissing
|
10
10
|
|
11
11
|
def initialize(id, manager = Manager.new)
|
12
12
|
job_path = manager.GetJob(id).first
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#
|
2
|
+
# See docs for full API description:
|
3
|
+
# https://www.freedesktop.org/wiki/Software/systemd/localed/
|
4
|
+
#
|
5
|
+
require_relative 'helpers'
|
6
|
+
require_relative 'mixin'
|
7
|
+
|
8
|
+
module DBus
|
9
|
+
module Systemd
|
10
|
+
class Localed
|
11
|
+
NODE = '/org/freedesktop/locale1'
|
12
|
+
INTERFACE = 'org.freedesktop.locale1'
|
13
|
+
|
14
|
+
include Mixin::MethodMissing
|
15
|
+
|
16
|
+
attr_reader :service
|
17
|
+
|
18
|
+
def initialize(bus = Helpers.system_bus)
|
19
|
+
@service = bus.service(INTERFACE)
|
20
|
+
@object = @service.object(NODE)
|
21
|
+
.tap(&:introspect)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require_relative '../helpers'
|
2
|
+
require_relative '../mixin'
|
3
|
+
require_relative 'session'
|
4
|
+
require_relative 'user'
|
5
|
+
require_relative 'seat'
|
6
|
+
|
7
|
+
module DBus
|
8
|
+
module Systemd
|
9
|
+
module Logind
|
10
|
+
INTERFACE = 'org.freedesktop.login1'
|
11
|
+
|
12
|
+
class Manager
|
13
|
+
NODE = '/org/freedesktop/login1'
|
14
|
+
INTERFACE = 'org.freedesktop.login1.Manager'
|
15
|
+
|
16
|
+
SESSION_INDICES = {
|
17
|
+
id: 0,
|
18
|
+
user_id: 1,
|
19
|
+
user_name: 2,
|
20
|
+
seat_id: 3,
|
21
|
+
object_path: 4
|
22
|
+
}
|
23
|
+
|
24
|
+
USER_INDICES = {
|
25
|
+
id: 0,
|
26
|
+
name: 1,
|
27
|
+
object_path: 2
|
28
|
+
}
|
29
|
+
|
30
|
+
SEAT_INDICES = {
|
31
|
+
id: 0,
|
32
|
+
object_path: 1
|
33
|
+
}
|
34
|
+
|
35
|
+
INHIBITOR_INDICES = {
|
36
|
+
what: 0,
|
37
|
+
who: 1,
|
38
|
+
why: 2,
|
39
|
+
mode: 3,
|
40
|
+
user_id: 4,
|
41
|
+
process_id: 5
|
42
|
+
}
|
43
|
+
|
44
|
+
include Systemd::Mixin::MethodMissing
|
45
|
+
|
46
|
+
attr_reader :service
|
47
|
+
|
48
|
+
def initialize(bus = Systemd::Helpers.system_bus)
|
49
|
+
@service = bus.service(Logind::INTERFACE)
|
50
|
+
@object = @service.object(NODE)
|
51
|
+
.tap(&:introspect)
|
52
|
+
end
|
53
|
+
|
54
|
+
def seats
|
55
|
+
self.ListSeats.first.map { |s| map_seat(s) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def seat(id)
|
59
|
+
Seat.new(id, self)
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_seat_by_path(path)
|
63
|
+
obj = @service.object(path)
|
64
|
+
.tap(&:introspect)
|
65
|
+
Seat.new(obj.Get(Seat::INTERFACE, 'Id').first, self)
|
66
|
+
end
|
67
|
+
|
68
|
+
def map_seat(seat_array)
|
69
|
+
Systemd::Helpers.map_array(seat_array, SEAT_INDICES)
|
70
|
+
end
|
71
|
+
|
72
|
+
def sessions
|
73
|
+
self.ListSessions.first.map { |s| map_session(s) }
|
74
|
+
end
|
75
|
+
|
76
|
+
def session(id)
|
77
|
+
Session.new(id, self)
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_session_by_path(path)
|
81
|
+
obj = @service.object(path)
|
82
|
+
.tap(&:introspect)
|
83
|
+
Session.new(obj.Get(Session::INTERFACE, 'Id').first, self)
|
84
|
+
end
|
85
|
+
|
86
|
+
def map_session(session_array)
|
87
|
+
Systemd::Helpers.map_array(session_array, SESSION_INDICES)
|
88
|
+
end
|
89
|
+
|
90
|
+
def users
|
91
|
+
self.ListUsers.first.map { |u| map_user(u) }
|
92
|
+
end
|
93
|
+
|
94
|
+
def user(id)
|
95
|
+
User.new(id, self)
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_user_by_path(path)
|
99
|
+
obj = @service.object(path)
|
100
|
+
.tap(&:introspect)
|
101
|
+
User.new(obj.Get(User::INTERFACE, 'Id').first, self)
|
102
|
+
end
|
103
|
+
|
104
|
+
def map_user(user_array)
|
105
|
+
Systemd::Helpers.map_array(user_array, USER_INDICES)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../mixin'
|
2
|
+
require_relative 'manager'
|
3
|
+
|
4
|
+
module DBus
|
5
|
+
module Systemd
|
6
|
+
module Logind
|
7
|
+
class Seat
|
8
|
+
INTERFACE = 'org.freedesktop.login1.Seat'
|
9
|
+
|
10
|
+
include Systemd::Mixin::MethodMissing
|
11
|
+
|
12
|
+
def initialize(id, manager = Manager.new)
|
13
|
+
seat_path = manager.GetSeat(id).first
|
14
|
+
@object = manager.service.object(seat_path)
|
15
|
+
.tap(&:introspect)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../mixin'
|
2
|
+
require_relative 'manager'
|
3
|
+
|
4
|
+
module DBus
|
5
|
+
module Systemd
|
6
|
+
module Logind
|
7
|
+
class Session
|
8
|
+
INTERFACE = 'org.freedesktop.login1.Session'
|
9
|
+
|
10
|
+
include Systemd::Mixin::MethodMissing
|
11
|
+
|
12
|
+
def initialize(id, manager = Manager.new)
|
13
|
+
session_path = manager.GetSession(id).first
|
14
|
+
@object = manager.service.object(session_path)
|
15
|
+
.tap(&:introspect)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../mixin'
|
2
|
+
require_relative 'manager'
|
3
|
+
|
4
|
+
module DBus
|
5
|
+
module Systemd
|
6
|
+
module Logind
|
7
|
+
class User
|
8
|
+
INTERFACE = 'org.freedesktop.login1.User'
|
9
|
+
|
10
|
+
include Systemd::Mixin::MethodMissing
|
11
|
+
|
12
|
+
def initialize(id, manager = Manager.new)
|
13
|
+
user_path = manager.GetUser(id).first
|
14
|
+
@object = manager.service.object(user_path)
|
15
|
+
.tap(&:introspect)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../mixin'
|
2
|
+
require_relative 'manager'
|
3
|
+
|
4
|
+
module DBus
|
5
|
+
module Systemd
|
6
|
+
module Machined
|
7
|
+
class Image
|
8
|
+
INTERFACE = 'org.freedesktop.machine1.Image'
|
9
|
+
|
10
|
+
include Systemd::Mixin::MethodMissing
|
11
|
+
|
12
|
+
def initialize(name, manager = Manager.new)
|
13
|
+
image_path = manager.GetImage(name).first
|
14
|
+
@object = manager.service.object(image_path)
|
15
|
+
.tap(&:introspect)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../mixin'
|
2
|
+
require_relative 'manager'
|
3
|
+
|
4
|
+
module DBus
|
5
|
+
module Systemd
|
6
|
+
module Machined
|
7
|
+
class Machine
|
8
|
+
INTERFACE = 'org.freedesktop.machine1.Machine'
|
9
|
+
|
10
|
+
include Systemd::Mixin::MethodMissing
|
11
|
+
|
12
|
+
def initialize(name, manager = Manager.new)
|
13
|
+
machine_path = manager.GetMachine(name).first
|
14
|
+
@object = manager.service.object(machine_path)
|
15
|
+
.tap(&:introspect)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require_relative '../helpers'
|
2
|
+
require_relative '../mixin'
|
3
|
+
require_relative 'machine'
|
4
|
+
require_relative 'image'
|
5
|
+
|
6
|
+
module DBus
|
7
|
+
module Systemd
|
8
|
+
module Machined
|
9
|
+
INTERFACE = 'org.freedesktop.machine1'
|
10
|
+
|
11
|
+
class Manager
|
12
|
+
NODE = '/org/freedesktop/machine1'
|
13
|
+
INTERFACE = 'org.freedesktop.machine1.Manager'
|
14
|
+
|
15
|
+
MACHINE_INDICES = {
|
16
|
+
name: 0,
|
17
|
+
class: 1,
|
18
|
+
service_id: 2,
|
19
|
+
object_path: 3
|
20
|
+
}
|
21
|
+
|
22
|
+
IMAGE_INDICES = {
|
23
|
+
name: 0,
|
24
|
+
type: 1,
|
25
|
+
read_only: 2,
|
26
|
+
creation_time: 3,
|
27
|
+
modification_time: 4,
|
28
|
+
disk_space: 5,
|
29
|
+
object_path: 6
|
30
|
+
}
|
31
|
+
|
32
|
+
include Systemd::Mixin::MethodMissing
|
33
|
+
|
34
|
+
attr_reader :service
|
35
|
+
|
36
|
+
def initialize(bus = Systemd::Helpers.system_bus)
|
37
|
+
@service = bus.service(Machined::INTERFACE)
|
38
|
+
@object = @service.object(NODE)
|
39
|
+
.tap(&:introspect)
|
40
|
+
end
|
41
|
+
|
42
|
+
def machines
|
43
|
+
self.ListMachines.first.map { |m| map_machine(m) }
|
44
|
+
end
|
45
|
+
|
46
|
+
def machine(name)
|
47
|
+
Machine.new(name, self)
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_machine_by_path(path)
|
51
|
+
obj = @service.object(path)
|
52
|
+
.tap(&:introspect)
|
53
|
+
Machine.new(obj.Get(Machine::INTERFACE, 'Name').first, self)
|
54
|
+
end
|
55
|
+
|
56
|
+
def map_machine(machine_array)
|
57
|
+
Systemd::Helpers.map_array(machine_array, MACHINE_INDICES)
|
58
|
+
end
|
59
|
+
|
60
|
+
def images
|
61
|
+
self.ListImages.first.map { |i| map_image(i) }
|
62
|
+
end
|
63
|
+
|
64
|
+
def image(name)
|
65
|
+
Image.new(name, self)
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_image_by_path(path)
|
69
|
+
obj = @service.object(path)
|
70
|
+
.tap(&:introspect)
|
71
|
+
Image.new(obj.Get(Image::INTERFACE, 'Name').first, self)
|
72
|
+
end
|
73
|
+
|
74
|
+
def map_image(image_array)
|
75
|
+
Systemd::Helpers.map_array(image_array, IMAGE_INDICES)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/dbus/systemd/manager.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
#
|
2
|
+
# See docs for full API description:
|
3
|
+
# https://www.freedesktop.org/wiki/Software/systemd/dbus/
|
4
|
+
#
|
5
|
+
require_relative 'helpers'
|
6
|
+
require_relative 'mixin'
|
3
7
|
require_relative 'unit'
|
8
|
+
require_relative 'job'
|
4
9
|
|
5
10
|
module DBus
|
6
11
|
module Systemd
|
12
|
+
INTERFACE = 'org.freedesktop.systemd1'
|
13
|
+
|
7
14
|
class Manager
|
8
|
-
|
15
|
+
NODE = '/org/freedesktop/systemd1'
|
9
16
|
INTERFACE = 'org.freedesktop.systemd1.Manager'
|
10
17
|
|
11
18
|
UNIT_INDICES = {
|
@@ -30,18 +37,18 @@ module DBus
|
|
30
37
|
unit_object_path: 5
|
31
38
|
}
|
32
39
|
|
33
|
-
include MethodMissing
|
40
|
+
include Mixin::MethodMissing
|
34
41
|
|
35
42
|
attr_reader :service
|
36
43
|
|
37
|
-
def initialize(bus = Systemd.system_bus)
|
44
|
+
def initialize(bus = Systemd::Helpers.system_bus)
|
38
45
|
@service = bus.service(Systemd::INTERFACE)
|
39
|
-
@object = @service.object(
|
46
|
+
@object = @service.object(NODE)
|
40
47
|
.tap(&:introspect)
|
41
48
|
end
|
42
49
|
|
43
50
|
def units
|
44
|
-
|
51
|
+
self.ListUnits.first.map { |u| map_unit(u) }
|
45
52
|
end
|
46
53
|
|
47
54
|
def unit(name)
|
@@ -55,13 +62,11 @@ module DBus
|
|
55
62
|
end
|
56
63
|
|
57
64
|
def map_unit(unit_array)
|
58
|
-
|
59
|
-
|
60
|
-
unit_array.each_with_index do |item, index|
|
61
|
-
mapped[UNIT_INDICES.key(index)] = item
|
62
|
-
end
|
65
|
+
Helpers.map_array(unit_array, UNIT_INDICES)
|
66
|
+
end
|
63
67
|
|
64
|
-
|
68
|
+
def jobs
|
69
|
+
self.ListJobs.first.map { |j| map_job(j) }
|
65
70
|
end
|
66
71
|
|
67
72
|
def job(id)
|
@@ -75,13 +80,7 @@ module DBus
|
|
75
80
|
end
|
76
81
|
|
77
82
|
def map_job(job_array)
|
78
|
-
|
79
|
-
|
80
|
-
job_array.each_with_index do |item, index|
|
81
|
-
mapped[JOB_INDICES.key(index)] = item
|
82
|
-
end
|
83
|
-
|
84
|
-
mapped
|
83
|
+
Helpers.map_array(job_array, JOB_INDICES)
|
85
84
|
end
|
86
85
|
end
|
87
86
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DBus
|
2
|
+
module Systemd
|
3
|
+
module Mixin
|
4
|
+
module MethodMissing
|
5
|
+
attr_reader :object
|
6
|
+
|
7
|
+
def method_missing(name, *args, &blk)
|
8
|
+
if @object.respond_to?(name)
|
9
|
+
@object.send(name, *args, &blk)
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def respond_to_missing?(*args)
|
16
|
+
@object.respond_to?(*args) || super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../mixin'
|
2
|
+
require_relative 'manager'
|
3
|
+
|
4
|
+
module DBus
|
5
|
+
module Systemd
|
6
|
+
module Resolved
|
7
|
+
class Link
|
8
|
+
INTERFACE = 'org.freedesktop.resolve1.Link'
|
9
|
+
|
10
|
+
include Systemd::Mixin::MethodMissing
|
11
|
+
|
12
|
+
def initialize(id, manager = Manager.new)
|
13
|
+
link_path = manager.GetLink(id).first
|
14
|
+
@object = manager.service.object(link_path)
|
15
|
+
.tap(&:introspect)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../helpers'
|
2
|
+
require_relative '../mixin'
|
3
|
+
require_relative 'link'
|
4
|
+
|
5
|
+
module DBus
|
6
|
+
module Systemd
|
7
|
+
module Resolved
|
8
|
+
INTERFACE = 'org.freedesktop.resolve1'
|
9
|
+
|
10
|
+
class Manager
|
11
|
+
NODE = '/org/freedesktop/resolve1'
|
12
|
+
INTERFACE = 'org.freedesktop.resolve1.Manager'
|
13
|
+
|
14
|
+
include Systemd::Mixin::MethodMissing
|
15
|
+
|
16
|
+
attr_reader :service
|
17
|
+
|
18
|
+
def initialize(bus = Systemd::Helpers.system_bus)
|
19
|
+
@service = bus.service(Resolved::INTERFACE)
|
20
|
+
@object = @service.object(NODE)
|
21
|
+
.tap(&:introspect)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'helpers'
|
2
|
+
require_relative 'mixin'
|
3
|
+
|
4
|
+
module DBus
|
5
|
+
module Systemd
|
6
|
+
class Timedated
|
7
|
+
NODE = '/org/freedesktop/timedate1'
|
8
|
+
INTERFACE = 'org.freedesktop.timedate1'
|
9
|
+
|
10
|
+
include Mixin::MethodMissing
|
11
|
+
|
12
|
+
attr_reader :service
|
13
|
+
|
14
|
+
def initialize(bus = Helpers.system_bus)
|
15
|
+
@service = bus.service(INTERFACE)
|
16
|
+
@object = @service.object(NODE)
|
17
|
+
.tap(&:introspect)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/dbus/systemd/unit.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative 'method_missing'
|
2
1
|
require_relative 'manager'
|
2
|
+
require_relative 'mixin'
|
3
3
|
|
4
4
|
module DBus
|
5
5
|
module Systemd
|
6
6
|
class Unit
|
7
7
|
INTERFACE = 'org.freedesktop.systemd1.Unit'
|
8
8
|
|
9
|
-
include MethodMissing
|
9
|
+
include Mixin::MethodMissing
|
10
10
|
|
11
11
|
def initialize(name, manager = Manager.new)
|
12
12
|
unit_path = manager.GetUnit(name).first
|
data/lib/dbus/systemd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbus-systemd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-dbus
|
@@ -66,7 +66,173 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
-
description: library for
|
69
|
+
description: "# DBus::Systemd\n\nRuby library for simplifying access to systemd dbus
|
70
|
+
interfaces.\n\nRecommended Reading\n\n - [introduction to d-bus concepts section
|
71
|
+
of sd-bus announcement blog post](http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html)\n
|
72
|
+
\ - [systemd D-Bus specification](https://www.freedesktop.org/wiki/Software/systemd/dbus/)\n
|
73
|
+
\ - [D-Bus specification](https://dbus.freedesktop.org/doc/dbus-specification.html)\n
|
74
|
+
\ \n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem
|
75
|
+
'dbus-systemd'\n```\n\nAnd then execute:\n\n $ bundle\n\nOr install it yourself
|
76
|
+
as:\n\n $ gem install dbus-systemd\n\n## Usage\n\n### DBus::Systemd::Hostnamed\n\nFor
|
77
|
+
full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/hostnamed/).\n\n```ruby\nirb(main):001:0>
|
78
|
+
h = DBus::Systemd::Hostnamed.new\n=> ...\nirb(main):002:0> h.object.methods - Object.methods\n=>
|
79
|
+
[:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :SetHostname, :SetStaticHostname,
|
80
|
+
:SetPrettyHostname, :SetIconName, :SetChassis, :SetDeployment, :SetLocation, :[],
|
81
|
+
:[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected, :default_iface,
|
82
|
+
:interfaces, :define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=,
|
83
|
+
:default_iface=]\nirb(main):004:0> h.Get(DBus::Systemd::Hostnamed::INTERFACE, 'Hostname').first\n=>
|
84
|
+
\"derp.localdomain\"\nirb(main):005:0> h.SetHostname('my-hostname.localdomain',
|
85
|
+
false)\n=> []\nirb(main):006:0> h.Get(DBus::Systemd::Hostnamed::INTERFACE, 'Hostname').first\n=>
|
86
|
+
\"my-hostname.localdomain\"\n```\n\n### DBus::Systemd::Importd\n\nFor full docs,
|
87
|
+
see [official docs](https://www.freedesktop.org/wiki/Software/systemd/importd/).\n\n```ruby\nirb(main):007:0>
|
88
|
+
im = DBus::Systemd::Importd::Manager.new\n=> ...\nirb(main):008:0> im.object.methods
|
89
|
+
- Object.methods\n=> [:Set, :Get, :GetAll, :ListTransfers, :Ping, :GetMachineId,
|
90
|
+
:Introspect, :ImportTar, :ImportRaw, :ExportTar, :ExportRaw, :PullTar, :PullRaw,
|
91
|
+
:CancelTransfer, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes,
|
92
|
+
:introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?,
|
93
|
+
:on_signal, :subnodes=, :introspected=, :default_iface=]\nirb(main):008:0> im.PullRaw('https://dl.fedoraproject.org/pub/fedora/linux/releases/24/CloudImages/x86_64/images/Fedora-Cloud-Base-24-1.2.x86_64.raw.xz',
|
94
|
+
'Fedora-24', 'no', false)\n=> [1, \"/org/freedesktop/import1/transfer/_1\"]\n> im.transfers\n=>
|
95
|
+
[{:id=>1, :operation=>\"pull-raw\", :remote_file=>\"https://dl.fedoraproject.org/pub/fedora/linux/releases/24/CloudImages/x86_64/images/Fedora-Cloud-Base-24-1.2.x86_64.raw.xz\",
|
96
|
+
:machine_name=>\"Fedora-24\", :progress=>0.0, :object_path=>\"/org/freedesktop/import1/transfer/_1\"}]\n```\n\n###
|
97
|
+
DBus::Systemd::Localed\n\nFor full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/localed/).\n\n```ruby\nirb(main):009:0>
|
98
|
+
l = DBus::Systemd::Localed.new\n=> ...\nirb(main):010:0> l.object.methods - Object.methods\n=>
|
99
|
+
[:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :SetLocale, :SetVConsoleKeyboard,
|
100
|
+
:SetX11Keyboard, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes,
|
101
|
+
:introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?,
|
102
|
+
:on_signal, :subnodes=, :introspected=, :default_iface=]\nirb(main):011:0> l.GetAll(DBus::Systemd::Localed::INTERFACE).first\n=>
|
103
|
+
{\"Locale\"=>[\"LANG=en_US.UTF-8\"], \"X11Layout\"=>\"\", \"X11Model\"=>\"\", \"X11Variant\"=>\"\",
|
104
|
+
\"X11Options\"=>\"\", \"VConsoleKeymap\"=>\"us\", \"VConsoleKeymapToggle\"=>\"\"}\n```\n\n###
|
105
|
+
DBus::Systemd::Logind\n\nFor full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/logind/).\n\n```ruby\nirb(main):012:0>
|
106
|
+
l = DBus::Systemd::Logind::Manager.new\n=> ...\nirb(main):013:0> l.object.methods
|
107
|
+
- Object.methods\n=> [:Set, :Get, :GetAll, :ListSeats, :ListSessions, :ListUsers,
|
108
|
+
:GetSession, :GetUser, :GetSeat, :Ping, :GetMachineId, :Introspect, :GetSessionByPID,
|
109
|
+
:GetUserByPID, :ListInhibitors, :CreateSession, :ReleaseSession, :ActivateSession,
|
110
|
+
:ActivateSessionOnSeat, :LockSession, :UnlockSession, :LockSessions, :UnlockSessions,
|
111
|
+
:KillSession, :KillUser, :TerminateSession, :TerminateUser, :TerminateSeat, :SetUserLinger,
|
112
|
+
:AttachDevice, :FlushDevices, :PowerOff, :Reboot, :Suspend, :Hibernate, :HybridSleep,
|
113
|
+
:CanPowerOff, :CanReboot, :CanSuspend, :CanHibernate, :CanHybridSleep, :ScheduleShutdown,
|
114
|
+
:CancelScheduledShutdown, :Inhibit, :CanRebootToFirmwareSetup, :SetRebootToFirmwareSetup,
|
115
|
+
:SetWallMessage, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes,
|
116
|
+
:introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?,
|
117
|
+
:on_signal, :subnodes=, :introspected=, :default_iface=]\nirb(main):014:0> l.users\n=>
|
118
|
+
[{:id=>1000, :name=>\"vagrant\", :object_path=>\"/org/freedesktop/login1/user/_1000\"}]\nirb(main):015:0>
|
119
|
+
l.seats\n=> [{:id=>\"seat0\", :object_path=>\"/org/freedesktop/login1/seat/seat0\"}]\nirb(main):016:0>
|
120
|
+
l.sessions\n=> [{:id=>\"3\", :user_id=>1000, :user_name=>\"vagrant\", :seat_id=>\"\",
|
121
|
+
:object_path=>\"/org/freedesktop/login1/session/_33\"}]\nirb(main):017:0> u = l.user(1000)\n=>
|
122
|
+
...\nirb(main):019:0> u.GetAll(DBus::Systemd::Logind::User::INTERFACE).first\n=>
|
123
|
+
{\"UID\"=>1000, \"GID\"=>1000, \"Name\"=>\"vagrant\", \"Timestamp\"=>1475452037907590,
|
124
|
+
\"TimestampMonotonic\"=>122159600, \"RuntimePath\"=>\"/run/user/1000\", \"Service\"=>\"user@1000.service\",
|
125
|
+
\"Slice\"=>\"user-1000.slice\", \"Display\"=>[\"3\", \"/org/freedesktop/login1/session/_33\"],
|
126
|
+
\"State\"=>\"active\", \"Sessions\"=>[[\"3\", \"/org/freedesktop/login1/session/_33\"]],
|
127
|
+
\"IdleHint\"=>false, \"IdleSinceHint\"=>0, \"IdleSinceHintMonotonic\"=>0, \"Linger\"=>false}\n```\n\n###
|
128
|
+
DBus::Systemd::Machined\n\nFor full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/machined/).\n\n```ruby\nirb(main):021:0>
|
129
|
+
mm = DBus::Systemd::Machined::Manager.new\n=> ...\nirb(main):022:0> mm.object.methods
|
130
|
+
- Object.methods\n=> [:Set, :Get, :GetAll, :ListMachines, :ListImages, :GetMachine,
|
131
|
+
:GetImage, :Ping, :GetMachineId, :Introspect, :GetMachineByPID, :CreateMachine,
|
132
|
+
:CreateMachineWithNetwork, :RegisterMachine, :RegisterMachineWithNetwork, :TerminateMachine,
|
133
|
+
:KillMachine, :GetMachineAddresses, :GetMachineOSRelease, :OpenMachinePTY, :OpenMachineLogin,
|
134
|
+
:OpenMachineShell, :BindMountMachine, :CopyFromMachine, :CopyToMachine, :RemoveImage,
|
135
|
+
:RenameImage, :CloneImage, :MarkImageReadOnly, :SetPoolLimit, :SetImageLimit, :MapFromMachineUser,
|
136
|
+
:MapToMachineUser, :MapFromMachineGroup, :MapToMachineGroup, :[], :[]=, :path, :destination,
|
137
|
+
:bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces,
|
138
|
+
:define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]\nirb(main):024:0>
|
139
|
+
mm.machines\n=> [{:name=>\".host\", :class=>\"host\", :service_id=>\"\", :object_path=>\"/org/freedesktop/machine1/machine/_2ehost\"}]\nirb(main):023:0>
|
140
|
+
mm.images\n=> [{:name=>\"Fedora-23\", :type=>\"raw\", :read_only=>false, :creation_time=>1446171608000000,
|
141
|
+
:modification_time=>1446171608000000, :disk_space=>589676544, :object_path=>\"/org/freedesktop/machine1/image/Fedora_2d23\"},
|
142
|
+
{:name=>\".raw-https:\\\\x2f\\\\x2fdl\\\\x2efedoraproject\\\\x2eorg\\\\x2fpub\\\\x2ffedora\\\\x2flinux\\\\x2freleases\\\\x2f24\\\\x2fCloudImages\\\\x2fx86_64\\\\x2fimages\\\\x2fFedora-Cloud-Base-24-1\\\\x2e2\\\\x2ex86_64\\\\x2eraw\\\\x2exz.\\\\x227fef0a4-5353f9c7441a0\\\\x22\",
|
143
|
+
:type=>\"raw\", :read_only=>true, :creation_time=>1465922207000000, :modification_time=>1465922207000000,
|
144
|
+
:disk_space=>540872704, :object_path=>\"/org/freedesktop/machine1/image/_2eraw_2dhttps_3a_5cx2f_5cx2fdl_5cx2efedoraproject_5cx2eorg_5cx2fpub_5cx2ffedora_5cx2flinux_5cx2freleases_5cx2f24_5cx2fCloudImages_5cx2fx86_5f64_5cx2fimages_5cx2fFedora_2dCloud_2dBase_2d24_2d1_5cx2e2_5cx2ex86_5f64_5cx2eraw_5cx2exz_2e_5cx227fef0a4_2d5353f9c7441a0_5cx22\"},
|
145
|
+
{:name=>\".raw-https:\\\\x2f\\\\x2fdl\\\\x2efedoraproject\\\\x2eorg\\\\x2fpub\\\\x2ffedora\\\\x2flinux\\\\x2freleases\\\\x2f23\\\\x2fCloud\\\\x2fx86_64\\\\x2fImages\\\\x2fFedora-Cloud-Base-23-20151030\\\\x2ex86_64\\\\x2eraw\\\\x2exz.\\\\x229205894-5234910faa600\\\\x22\",
|
146
|
+
:type=>\"raw\", :read_only=>true, :creation_time=>1446171608000000, :modification_time=>1446171608000000,
|
147
|
+
:disk_space=>589676544, :object_path=>\"/org/freedesktop/machine1/image/_2eraw_2dhttps_3a_5cx2f_5cx2fdl_5cx2efedoraproject_5cx2eorg_5cx2fpub_5cx2ffedora_5cx2flinux_5cx2freleases_5cx2f23_5cx2fCloud_5cx2fx86_5f64_5cx2fImages_5cx2fFedora_2dCloud_2dBase_2d23_2d20151030_5cx2ex86_5f64_5cx2eraw_5cx2exz_2e_5cx229205894_2d5234910faa600_5cx22\"},
|
148
|
+
{:name=>\"Fedora-24\", :type=>\"raw\", :read_only=>false, :creation_time=>1465922207000000,
|
149
|
+
:modification_time=>1465922207000000, :disk_space=>540872704, :object_path=>\"/org/freedesktop/machine1/image/Fedora_2d24\"},
|
150
|
+
{:name=>\"test\", :type=>\"raw\", :read_only=>false, :creation_time=>1446171608000000,
|
151
|
+
:modification_time=>1446171608000000, :disk_space=>589676544, :object_path=>\"/org/freedesktop/machine1/image/test\"},
|
152
|
+
{:name=>\".host\", :type=>\"directory\", :read_only=>false, :creation_time=>0, :modification_time=>0,
|
153
|
+
:disk_space=>18446744073709551615, :object_path=>\"/org/freedesktop/machine1/image/_2ehost\"}]\nirb(main):025:0>
|
154
|
+
mm.GetAll(DBus::Systemd::Machined::Manager::INTERFACE).first\n=> {\"PoolPath\"=>\"/var/lib/machines\",
|
155
|
+
\"PoolUsage\"=>1191448576, \"PoolLimit\"=>2105020416}\nirb(main):026:0> mi = mm.image('Fedora-24')\n=>
|
156
|
+
...\nirb(main):027:0> mi.object.methods - Object.methods\n=> [:Set, :Get, :GetAll,
|
157
|
+
:Ping, :GetMachineId, :Introspect, :Remove, :Rename, :Clone, :MarkReadOnly, :SetLimit,
|
158
|
+
:[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes, :introspected,
|
159
|
+
:default_iface, :interfaces, :define_shortcut_methods, :has_iface?, :on_signal,
|
160
|
+
:subnodes=, :introspected=, :default_iface=]\nirb(main):028:0> mi.GetAll(DBus::Systemd::Machined::Image::INTERFACE).first\n=>
|
161
|
+
{\"Name\"=>\"Fedora-24\", \"Path\"=>\"/var/lib/machines/Fedora-24.raw\", \"Type\"=>\"raw\",
|
162
|
+
\"ReadOnly\"=>false, \"CreationTimestamp\"=>1465922207000000, \"ModificationTimestamp\"=>1465922207000000,
|
163
|
+
\"Usage\"=>540872704, \"Limit\"=>3221225472, \"UsageExclusive\"=>540872704, \"LimitExclusive\"=>3221225472}\nirb(main):029:0>
|
164
|
+
machine = mm.machine('.host')\n=> ..\nirb(main):030:0> machine.object.methods -
|
165
|
+
Object.methods\n=> [:Set, :Get, :GetAll, :Kill, :Ping, :GetMachineId, :Introspect,
|
166
|
+
:Terminate, :GetAddresses, :GetOSRelease, :OpenPTY, :OpenLogin, :OpenShell, :BindMount,
|
167
|
+
:CopyFrom, :CopyTo, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes,
|
168
|
+
:introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?,
|
169
|
+
:on_signal, :subnodes=, :introspected=, :default_iface=]\nirb(main):032:0> machine.GetAll(DBus::Systemd::Machined::Machine::INTERFACE).first\n=>
|
170
|
+
{\"Name\"=>\".host\", \"Id\"=>[77, 46, 68, 242, 105, 232, 78, 52, 157, 152, 76,
|
171
|
+
171, 175, 145, 140, 130], \"Timestamp\"=>1475451915747985, \"TimestampMonotonic\"=>0,
|
172
|
+
\"Service\"=>\"\", \"Unit\"=>\"-.slice\", \"Leader\"=>1, \"Class\"=>\"host\", \"RootDirectory\"=>\"/\",
|
173
|
+
\"NetworkInterfaces\"=>[], \"State\"=>\"running\"}\n```\n\n### DBus::Systemd::Resolved\n\nFor
|
174
|
+
full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/resolved/).\n\n```ruby\nirb(main):030:0>
|
175
|
+
rm = DBus::Systemd::Resolved::Manager.new\n=> ...\nirb(main):030:0> rm.object.methods
|
176
|
+
- Object.methods\n=> [:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :GetLink,
|
177
|
+
:ResolveHostname, :ResolveAddress, :ResolveRecord, :ResolveService, :ResetStatistics,
|
178
|
+
:SetLinkDNS, :SetLinkDomains, :SetLinkLLMNR, :SetLinkMulticastDNS, :SetLinkDNSSEC,
|
179
|
+
:SetLinkDNSSECNegativeTrustAnchors, :RevertLink, :[], :[]=, :path, :destination,
|
180
|
+
:bus, :introspect, :api, :subnodes, :introspected, :default_iface, :interfaces,
|
181
|
+
:define_shortcut_methods, :has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]\nirb(main):030:0>
|
182
|
+
rm.Get(DBus::Resolved::Manager::INTERFACE, 'DNSSECSupported').first\n=> false\n```\n\n###
|
183
|
+
DBus::Systemd::Timedated\n\nFor full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/timedated/).\n\n```ruby\nirb(main):030:0>
|
184
|
+
\ t = DBus::Systemd::Timedated.new\n=> ...\nirb(main):030:0> t.object.methods -
|
185
|
+
Object.methods\n=> [:Set, :Get, :GetAll, :Ping, :GetMachineId, :Introspect, :SetTime,
|
186
|
+
:SetTimezone, :SetLocalRTC, :SetNTP, :[], :[]=, :path, :destination, :bus, :introspect,
|
187
|
+
:api, :subnodes, :introspected, :default_iface, :interfaces, :define_shortcut_methods,
|
188
|
+
:has_iface?, :on_signal, :subnodes=, :introspected=, :default_iface=]\nirb(main):030:0>
|
189
|
+
t.GetAll(DBus::Systemd::Timedated::INTERFACE).first\n=> {\"Timezone\"=>\"UTC\",
|
190
|
+
\"LocalRTC\"=>true, \"CanNTP\"=>true, \"NTP\"=>false, \"NTPSynchronized\"=>true,
|
191
|
+
\"TimeUSec\"=>1475454744352557, \"RTCTimeUSec\"=>1475454742000000}\nirb(main):030:0>
|
192
|
+
t.SetTimezone('America/Los_Angeles', false)\n=> []\nirb(main):030:0> t.Get(DBus::Systemd::Timedated::INTERFACE,
|
193
|
+
'Timezone').first\n=> \"America/Los_Angeles\"\n```\n\n### DBus::Systemd::Manager\n\nFor
|
194
|
+
full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/dbus/).\n\n```ruby\nirb(main):030:0>
|
195
|
+
mgr = DBus::Systemd::Manager.new\n=> ...\nirb(main):030:0> mgr.object.methods -
|
196
|
+
Object.methods\n=> [:Set, :Get, :ListUnits, :GetAll, :GetUnit, :GetJob, :Ping, :GetMachineId,
|
197
|
+
:Introspect, :GetUnitByPID, :LoadUnit, :StartUnit, :StartUnitReplace, :StopUnit,
|
198
|
+
:ReloadUnit, :RestartUnit, :TryRestartUnit, :ReloadOrRestartUnit, :ReloadOrTryRestartUnit,
|
199
|
+
:KillUnit, :ResetFailedUnit, :SetUnitProperties, :StartTransientUnit, :CancelJob,
|
200
|
+
:ClearJobs, :ResetFailed, :ListUnitsFiltered, :ListJobs, :Subscribe, :Unsubscribe,
|
201
|
+
:Dump, :CreateSnapshot, :RemoveSnapshot, :Reload, :Reexecute, :Exit, :Reboot, :PowerOff,
|
202
|
+
:Halt, :KExec, :SwitchRoot, :SetEnvironment, :UnsetEnvironment, :UnsetAndSetEnvironment,
|
203
|
+
:ListUnitFiles, :GetUnitFileState, :EnableUnitFiles, :DisableUnitFiles, :ReenableUnitFiles,
|
204
|
+
:LinkUnitFiles, :PresetUnitFiles, :PresetUnitFilesWithMode, :MaskUnitFiles, :UnmaskUnitFiles,
|
205
|
+
:SetDefaultTarget, :GetDefaultTarget, :PresetAllUnitFiles, :AddDependencyUnitFiles,
|
206
|
+
:SetExitCode, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes,
|
207
|
+
:introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?,
|
208
|
+
:on_signal, :subnodes=, :introspected=, :default_iface=] \nirb(main):030:0> mgr.GetDefaultTarget.first\n=>
|
209
|
+
\"multi-user.target\"\nirb(main):036:0> mgr.Get(DBus::Systemd::Manager::INTERFACE,
|
210
|
+
'Version').first\n=> \"229\"\nirb(main):037:0> mgr.Get(DBus::Systemd::Manager::INTERFACE,
|
211
|
+
'UnitPath').first\n=> [\"/etc/systemd/system\", \"/run/systemd/system\", \"/run/systemd/generator\",
|
212
|
+
\"/usr/local/lib/systemd/system\", \"/usr/lib/systemd/system\", \"/run/systemd/generator.late\"]\nirb(main):038:0>
|
213
|
+
mgr.Get(DBus::Systemd::Manager::INTERFACE, 'NFailedUnits').first\n=> 0\n```\n\n###
|
214
|
+
DBus::Systemd::Unit\n\nFor full docs, see [official docs](https://www.freedesktop.org/wiki/Software/systemd/dbus/).\n\n```ruby\nirb(main):005:0>
|
215
|
+
sshd = DBus::Systemd::Unit.new('sshd.service')\n=> ...\nirb(main):006:0> sshd.object.methods
|
216
|
+
- Object.methods\n=> [:Set, :Get, :GetAll, :Kill, :Ping, :GetMachineId, :Introspect,
|
217
|
+
:ResetFailed, :Reload, :Start, :Stop, :Restart, :TryRestart, :ReloadOrRestart, :ReloadOrTryRestart,
|
218
|
+
:SetProperties, :[], :[]=, :path, :destination, :bus, :introspect, :api, :subnodes,
|
219
|
+
:introspected, :default_iface, :interfaces, :define_shortcut_methods, :has_iface?,
|
220
|
+
:on_signal, :subnodes=, :introspected=, :default_iface=]\nirb(main):007:0> sshd.Get(DBus::Systemd::Unit::INTERFACE,
|
221
|
+
'Wants').first\n=> [\"sshd-keygen.target\"]\nirb(main):008:0> sshd.Get(DBus::Systemd::Unit::Service::INTERFACE,
|
222
|
+
'ExecStart').first\n=> [[\"/usr/sbin/sshd\", [\"/usr/sbin/sshd\", \"$OPTIONS\"],
|
223
|
+
false, 1475455155565079, 3239817089, 1475455155581392, 3239833403, 5860, 1, 0]]\nirb(main):010:0>
|
224
|
+
sshd.Restart('replace')\n=> [\"/org/freedesktop/systemd1/job/3326\"]\n```\n\n##
|
225
|
+
Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.
|
226
|
+
Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive
|
227
|
+
prompt that will allow you to experiment.\n\nTo install this gem onto your local
|
228
|
+
machine, run `bundle exec rake install`. To release a new version, update the version
|
229
|
+
number in `version.rb`, and then run `bundle exec rake release`, which will create
|
230
|
+
a git tag for the version, push git commits and tags, and push the `.gem` file to
|
231
|
+
[rubygems.org](https://rubygems.org).\n\nA Vagrantfile is provided in the VCS root
|
232
|
+
that creates a Fedora vagrant box, with which library can be tested and D-Bus interfaces
|
233
|
+
explored.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub
|
234
|
+
at https://github.com/nathwill/ruby-dbus-systemd.\n\n## License\n\nThe gem is available
|
235
|
+
as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n"
|
70
236
|
email:
|
71
237
|
- nath.e.will@gmail.com
|
72
238
|
executables: []
|
@@ -80,14 +246,34 @@ files:
|
|
80
246
|
- LICENSE.txt
|
81
247
|
- README.md
|
82
248
|
- Rakefile
|
249
|
+
- TODO.txt
|
83
250
|
- Vagrantfile
|
84
251
|
- bin/console
|
85
252
|
- bin/setup
|
86
253
|
- dbus-systemd.gemspec
|
87
254
|
- lib/dbus/systemd.rb
|
255
|
+
- lib/dbus/systemd/helpers.rb
|
256
|
+
- lib/dbus/systemd/hostnamed.rb
|
257
|
+
- lib/dbus/systemd/importd.rb
|
258
|
+
- lib/dbus/systemd/importd/manager.rb
|
259
|
+
- lib/dbus/systemd/importd/transfer.rb
|
88
260
|
- lib/dbus/systemd/job.rb
|
261
|
+
- lib/dbus/systemd/localed.rb
|
262
|
+
- lib/dbus/systemd/logind.rb
|
263
|
+
- lib/dbus/systemd/logind/manager.rb
|
264
|
+
- lib/dbus/systemd/logind/seat.rb
|
265
|
+
- lib/dbus/systemd/logind/session.rb
|
266
|
+
- lib/dbus/systemd/logind/user.rb
|
267
|
+
- lib/dbus/systemd/machined.rb
|
268
|
+
- lib/dbus/systemd/machined/image.rb
|
269
|
+
- lib/dbus/systemd/machined/machine.rb
|
270
|
+
- lib/dbus/systemd/machined/manager.rb
|
89
271
|
- lib/dbus/systemd/manager.rb
|
90
|
-
- lib/dbus/systemd/
|
272
|
+
- lib/dbus/systemd/mixin.rb
|
273
|
+
- lib/dbus/systemd/resolved.rb
|
274
|
+
- lib/dbus/systemd/resolved/link.rb
|
275
|
+
- lib/dbus/systemd/resolved/manager.rb
|
276
|
+
- lib/dbus/systemd/timedated.rb
|
91
277
|
- lib/dbus/systemd/unit.rb
|
92
278
|
- lib/dbus/systemd/unit/automount.rb
|
93
279
|
- lib/dbus/systemd/unit/device.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module DBus
|
2
|
-
module Systemd
|
3
|
-
module MethodMissing
|
4
|
-
attr_reader :object
|
5
|
-
|
6
|
-
def method_missing(name, *args, &blk)
|
7
|
-
if @object.respond_to?(name)
|
8
|
-
@object.send(name, *args, &blk)
|
9
|
-
else
|
10
|
-
super
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def respond_to_missing?(*args)
|
15
|
-
@object.respond_to?(*args) || super
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|