Module: OsCtld::DistConfig

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

Defined Under Namespace

Modules: Distributions, Helpers, Network Classes: Configurator

Class Method Summary collapse

Class Method Details

.for(distribution) ⇒ Object



16
17
18
# File 'lib/osctld/dist_config.rb', line 16

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

.register(distribution, klass) ⇒ Object



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

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

.run(ctrc, cmd, **opts) ⇒ Object

Parameters:

  • ctrc (Container::RunConfiruration)
  • cmd (Symbol)
  • opts (Hash)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/osctld/dist_config.rb', line 23

def self.run(ctrc, cmd, **opts)
  klass = self.for(ctrc.distribution.to_sym)

  # Make sure the container's dataset is mounted
  #
  # We skip the mount if for the stop command, that way running
  # `ct stop` will not mount the container unnecessarily. Mounting also causes
  # problems when we try to work with container that has its dataset bugged,
  # e.g. when zfs mount/umount commands hang, we get stuck here for no reason.
  ctrc.mount if cmd != :stop

  d = (klass || self.for(:other)).new(ctrc)

  begin
    d.method(cmd).call(opts)
  rescue StandardError => e
    ctrc.log(:warn, "DistConfig.#{cmd} failed: #{e.message}")
    ctrc.log(:warn, denixstorify(e.backtrace).join("\n"))
  end
end