Class: OsCtld::RunState::StartConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/run_state/start_config.rb

Overview

One-time config for osctld

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ StartConfig

Returns a new instance of StartConfig.

Parameters:

  • path (String)


10
11
12
13
# File 'lib/osctld/run_state/start_config.rb', line 10

def initialize(path)
  @path = path
  open_config
end

Instance Attribute Details

#cfgObject (readonly, protected)

Returns the value of attribute cfg.



29
30
31
# File 'lib/osctld/run_state/start_config.rb', line 29

def cfg
  @cfg
end

#pathString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/osctld/run_state/start_config.rb', line 7

def path
  @path
end

Instance Method Details

#activate_lxcfs?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/osctld/run_state/start_config.rb', line 19

def activate_lxcfs?
  cfg['activate_lxcfs'] ? true : false
end

#closeObject



23
24
25
26
# File 'lib/osctld/run_state/start_config.rb', line 23

def close
  File.unlink(path) if exist?
rescue Errno::ENOENT
end

#exist?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/osctld/run_state/start_config.rb', line 15

def exist?
  @exist
end

#open_configObject (protected)



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/osctld/run_state/start_config.rb', line 31

def open_config
  @cfg = {}

  begin
    data = File.read(path)
  rescue Errno::ENOENT
    @exist = false
    return
  end

  @exist = true
  @cfg = JSON.parse(data)
end