Class: DBus::Systemd::Machined::Manager
- Inherits:
-
Object
- Object
- DBus::Systemd::Machined::Manager
- Defined in:
- lib/dbus/systemd/machined/manager.rb
Constant Summary collapse
- NODE =
machined manager dbus object node path
'/org/freedesktop/machine1'.freeze
- INTERFACE =
machined manager dbus interface
'org.freedesktop.machine1.Manager'.freeze
- MACHINE_INDICES =
machine array index map as returned by ListMachines
{ name: 0, class: 1, service_id: 2, object_path: 3 }.freeze
- IMAGE_INDICES =
image array index map as returned by ListImages
{ name: 0, type: 1, read_only: 2, creation_time: 3, modification_time: 4, disk_space: 5, object_path: 6 }.freeze
Instance Attribute Summary collapse
- #service ⇒ DBus::Service readonly private
Attributes included from DBus::Systemd::Mixin::MethodMissing
Instance Method Summary collapse
-
#get_image_by_path(path) ⇒ DBus::Systemd::Machined::Image
get image dbus proxy object by dbus node path.
-
#get_machine_by_path(path) ⇒ DBus::Systemd::Machined::Machine
get machine dbus proxy object by dbus node path.
-
#image(name) ⇒ DBus::Systemd::Machined::Machine
get image proxy object by name.
-
#images ⇒ Array
get mapped array of images.
-
#initialize(bus = Systemd::Helpers.system_bus) ⇒ Manager
constructor
Create machined Manager dbus proxy object.
-
#machine(name) ⇒ DBus::Systemd::Machined::Machine
get machine dbus proxy object by machine name.
-
#machines ⇒ Array
array of machines with mapped properties.
-
#map_image(image_array) ⇒ Hash
map image array as returned by ListImages to property hash.
-
#map_machine(machine_array) ⇒ Hash
map machine property array from ListMachines to indexed property hash.
Methods included from DBus::Systemd::Mixin::Properties
Methods included from DBus::Systemd::Mixin::MethodMissing
#method_missing, #respond_to_missing?
Constructor Details
#initialize(bus = Systemd::Helpers.system_bus) ⇒ Manager
Create machined Manager dbus proxy object
69 70 71 72 73 74 |
# File 'lib/dbus/systemd/machined/manager.rb', line 69 def initialize(bus = Systemd::Helpers.system_bus) @service = bus.service(Machined::SERVICE) @object = @service.object(NODE) @object.default_iface = INTERFACE @object.introspect end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DBus::Systemd::Mixin::MethodMissing
Instance Attribute Details
#service ⇒ DBus::Service (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'lib/dbus/systemd/machined/manager.rb', line 63 def service @service end |
Instance Method Details
#get_image_by_path(path) ⇒ DBus::Systemd::Machined::Image
get image dbus proxy object by dbus node path
135 136 137 138 139 |
# File 'lib/dbus/systemd/machined/manager.rb', line 135 def get_image_by_path(path) obj = @service.object(path) .tap(&:introspect) Image.new(obj.Get(Image::INTERFACE, 'Name').first, self) end |
#get_machine_by_path(path) ⇒ DBus::Systemd::Machined::Machine
get machine dbus proxy object by dbus node path
98 99 100 101 102 |
# File 'lib/dbus/systemd/machined/manager.rb', line 98 def get_machine_by_path(path) obj = @service.object(path) .tap(&:introspect) Machine.new(obj.Get(Machine::INTERFACE, 'Name').first, self) end |
#image(name) ⇒ DBus::Systemd::Machined::Machine
get image proxy object by name
126 127 128 |
# File 'lib/dbus/systemd/machined/manager.rb', line 126 def image(name) Image.new(name, self) end |
#images ⇒ Array
get mapped array of images
117 118 119 |
# File 'lib/dbus/systemd/machined/manager.rb', line 117 def images self.ListImages.first.map { |i| map_image(i) } end |
#machine(name) ⇒ DBus::Systemd::Machined::Machine
get machine dbus proxy object by machine name
89 90 91 |
# File 'lib/dbus/systemd/machined/manager.rb', line 89 def machine(name) Machine.new(name, self) end |
#machines ⇒ Array
array of machines with mapped properties
80 81 82 |
# File 'lib/dbus/systemd/machined/manager.rb', line 80 def machines self.ListMachines.first.map { |m| map_machine(m) } end |
#map_image(image_array) ⇒ Hash
map image array as returned by ListImages to property hash
146 147 148 |
# File 'lib/dbus/systemd/machined/manager.rb', line 146 def map_image(image_array) Systemd::Helpers.map_array(image_array, IMAGE_INDICES) end |
#map_machine(machine_array) ⇒ Hash
map machine property array from ListMachines to indexed property hash
109 110 111 |
# File 'lib/dbus/systemd/machined/manager.rb', line 109 def map_machine(machine_array) Systemd::Helpers.map_array(machine_array, MACHINE_INDICES) end |