class Fleet::Unit
Attributes
linuxrackers.com/doku.php?id=fedora_systemd_services LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
linuxrackers.com/doku.php?id=fedora_systemd_services LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
linuxrackers.com/doku.php?id=fedora_systemd_services LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
linuxrackers.com/doku.php?id=fedora_systemd_services LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
linuxrackers.com/doku.php?id=fedora_systemd_services LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
linuxrackers.com/doku.php?id=fedora_systemd_services LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
linuxrackers.com/doku.php?id=fedora_systemd_services LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
linuxrackers.com/doku.php?id=fedora_systemd_services LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
Public Class Methods
# File lib/fleet/unit.rb, line 9 def initialize(controller:, name:, state:, load:, active:, sub:, desc:, machine:) @controller = controller @name = name @state = state @load = load @active = active @sub = sub @machine = machine end
Public Instance Methods
# File lib/fleet/unit.rb, line 79 def ==(other_unit) name == other_unit.name end
# File lib/fleet/unit.rb, line 31 def creating? active == 'activating' && sub == 'start-pre' end
returns a JSON object representing the container assumes that this unit corresponds to a docker container
# File lib/fleet/unit.rb, line 74 def docker_inspect(container_name = name) raw = ssh('docker', 'inspect', container_name) JSON.parse(raw) end
gets the external port corresponding to the internal port specified assumes that this unit corresponds to a docker container TODO: split this sort of docker-related functionality out into a separate class
# File lib/fleet/unit.rb, line 53 def docker_port(internal_port, container_name = name) docker_runner = Fleetctl::Runner::SSH.new('docker', 'port', container_name, internal_port) docker_runner.run(host: ip) output = docker_runner.output if output output.rstrip! output.split(':').last end end
# File lib/fleet/unit.rb, line 35 def failed? active == 'failed' && sub == 'failed' end
# File lib/fleet/unit.rb, line 27 def ip machine && machine.ip end
# File lib/fleet/unit.rb, line 39 def running? active == 'active' && sub == 'running' end
run the command on host (string, array of command + args, whatever) and return stdout
# File lib/fleet/unit.rb, line 44 def ssh(*command, port: 22) runner = Fleetctl::Runner::SSH.new([*command].flatten.compact.join(' ')) runner.run(host: ip, ssh_options: { port: port }) runner.output end