Module: OsCtld::DistConfig

Extended by:
OsCtl::Lib::Utils::Exception
Defined in:
lib/osctld/dist_config.rb

Defined Under Namespace

Classes: Alpine, Arch, Base, CentOS, Debian, Devuan, Fedora, Gentoo, NixOS, OpenSuse, RedHat, Slackware, Ubuntu, Unsupported, Void

Class Method Summary collapse

Class Method Details

.for(distribution) ⇒ Object



12
13
14
# File 'lib/osctld/dist_config.rb', line 12

def self.for(distribution)
  @dists[distribution]
end

.register(distribution, klass) ⇒ Object



7
8
9
10
# File 'lib/osctld/dist_config.rb', line 7

def self.register(distribution, klass)
  @dists ||= {}
  @dists[distribution] = klass
end

.run(ct, cmd, opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/osctld/dist_config.rb', line 16

def self.run(ct, cmd, opts = {})
  klass = self.for(ct.distribution.to_sym)

  # Make sure the container's dataset is mounted
  ct.mount

  d = (klass || self.for(:unsupported)).new(ct)

  begin
    d.method(cmd).call(opts)

  rescue Exception => e
    ct.log(:warn, "DistConfig.#{cmd} failed: #{e.message}")
    ct.log(:warn, denixstorify(e.backtrace).join("\n"))
  end
end