Class: OsCtld::Devices::V1::ContainerManager
- Defined in:
- lib/osctld/devices/v1/container_manager.rb
Instance Attribute Summary
Attributes inherited from Manager
#configurator, #devices, #owner
Instance Method Summary collapse
- #add_to_changeset ⇒ Object protected
- #apply_devices(devices, path) ⇒ Object protected
- #assets(add) ⇒ Object
-
#check_all_available!(group: nil) ⇒ Object
Check that all devices are provided by parents, or raise an exception.
- #children ⇒ Object
- #configurator_class ⇒ Object
-
#ensure_all ⇒ Object
Ensure that all required devices are provided by parent groups.
- #parent ⇒ Object
-
#remove_missing ⇒ Object
Remove devices that aren’t provided by the parent, or have insufficient access mode.
Methods inherited from Manager
#add, #add_new, #apply, #changeset_sort_key, #check_availability!, #check_descendant_mode!, #check_descendants!, #check_unset_inherit!, #chmod, class_for, #detect, #do_add, #dump, #dup, #each, #export, #find, #get, #include?, #inherit, #inherit_promoted, #inherit_recursive, #inherited?, #init, #initialize, load, new_for, #promote, #provide, #remove, #replace, #select, #set_inherit, #sync, #uninherit_recursive, #unset_inherit, #update_inherited_mode, #used?, #used_by_descendants?
Constructor Details
This class inherits a constructor from OsCtld::Devices::Manager
Instance Method Details
#add_to_changeset ⇒ Object (protected)
56 57 58 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 56 def add_to_changeset # not used on v1 end |
#apply_devices(devices, path) ⇒ Object (protected)
62 63 64 65 66 67 68 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 62 def apply_devices(devices, path) return if CGroup.v2? devices.each do |dev| CGroup.set_param(File.join(path, 'devices.allow'), [dev.to_s]) end end |
#assets(add) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 5 def assets(add) add.cgroup_device_list( ct.abs_apply_cgroup_path('devices'), desc: 'Controls access to devices', devices: ) end |
#check_all_available!(group: nil) ⇒ Object
Check that all devices are provided by parents, or raise an exception
16 17 18 19 20 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 16 def check_all_available!(group: nil) sync do devices.each { |dev| check_availability!(dev, parent: group || ct.group) } end end |
#children ⇒ Object
44 45 46 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 44 def children [] end |
#configurator_class ⇒ Object
48 49 50 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 48 def configurator_class Devices::V1::ContainerConfigurator end |
#ensure_all ⇒ Object
Ensure that all required devices are provided by parent groups
23 24 25 26 27 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 23 def ensure_all sync do devices.each { |dev| parent.devices.provide(dev) } end end |
#parent ⇒ Object
40 41 42 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 40 def parent ct.group end |
#remove_missing ⇒ Object
Remove devices that aren’t provided by the parent, or have insufficient access mode
31 32 33 34 35 36 37 38 |
# File 'lib/osctld/devices/v1/container_manager.rb', line 31 def remove_missing sync do devices.delete_if do |dev| pdev = parent.devices.get(dev) pdev.nil? || !pdev.mode.compatible?(dev.mode) end end end |