Class: OsCtld::ContainerControl::Commands::GetHostname::Frontend

Inherits:
Frontend
  • Object
show all
Defined in:
lib/osctld/container_control/commands/get_hostname.rb

Instance Attribute Summary

Attributes inherited from Frontend

#command_class, #ct

Instance Method Summary collapse

Methods inherited from Frontend

#exec_runner, #fork_runner, #initialize

Constructor Details

This class inherits a constructor from OsCtld::ContainerControl::Frontend

Instance Method Details

#executeString

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/osctld/container_control/commands/get_hostname.rb', line 12

def execute
  init_pid = ct.init_pid

  if init_pid.nil?
    return ContainerControl::Result.new(
      false,
      message: 'container not running or init PID not set'
    )
  end

  ret = fork_runner(args: [init_pid], switch_to_system: false)
  ret.ok? ? ret.data : ret
end