Class: OsCtld::Container::StartMenu

Inherits:
Object
  • Object
show all
Includes:
OsCtl::Lib::Utils::Log
Defined in:
lib/osctld/container/start_menu.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ct, timeout) ⇒ StartMenu

Returns a new instance of StartMenu.



14
15
16
17
# File 'lib/osctld/container/start_menu.rb', line 14

def initialize(ct, timeout)
  @ct = ct
  @timeout = timeout
end

Instance Attribute Details

#ctObject (readonly)

Returns the value of attribute ct.



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

def ct
  @ct
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



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

def timeout
  @timeout
end

Class Method Details

.load(ct, cfg) ⇒ Object



6
7
8
# File 'lib/osctld/container/start_menu.rb', line 6

def self.load(ct, cfg)
  new(ct, cfg['timeout'] || 5)
end

Instance Method Details

#ct_pathObject



39
40
41
# File 'lib/osctld/container/start_menu.rb', line 39

def ct_path
  File.join('/', ct.mounts.shared_dir.mountpoint, 'ctstartmenu')
end

#deployObject



19
20
21
22
23
# File 'lib/osctld/container/start_menu.rb', line 19

def deploy
  FileUtils.copy_file(Daemon.get.config.ctstartmenu, host_path, preserve: true)
rescue SystemCallError => e
  log(:fatal, "Unable to deploy start menu: #{e.message} (#{e.class})")
end

#dumpObject



43
44
45
46
47
# File 'lib/osctld/container/start_menu.rb', line 43

def dump
  {
    'timeout' => timeout
  }
end

#dup(new_ct) ⇒ Object



49
50
51
52
53
# File 'lib/osctld/container/start_menu.rb', line 49

def dup(new_ct)
  ret = super()
  ret.instance_variable_set('@ct', new_ct)
  ret
end

#host_pathObject



35
36
37
# File 'lib/osctld/container/start_menu.rb', line 35

def host_path
  File.join(ct.mounts.shared_dir.path, 'ctstartmenu')
end

#init_cmd(cmd) ⇒ Object



31
32
33
# File 'lib/osctld/container/start_menu.rb', line 31

def init_cmd(cmd)
  [ct_path, '-timeout', timeout.to_s].concat(cmd)
end

#log_typeObject



55
56
57
# File 'lib/osctld/container/start_menu.rb', line 55

def log_type
  ct.log_type
end


25
26
27
28
29
# File 'lib/osctld/container/start_menu.rb', line 25

def unlink
  File.unlink(host_path)
rescue Errno::ENOENT
  # ignore
end