Class: Bsdkrun::SandboxInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/bsdkrun/types.rb

Overview

A machine as reported by bsdkrun ps --json.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command

Returns:

  • (Object)

    the current value of command



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def command
  @command
end

#cpusObject (readonly)

Returns the value of attribute cpus

Returns:

  • (Object)

    the current value of cpus



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def cpus
  @cpus
end

#created_atObject (readonly)

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def created_at
  @created_at
end

#detachedObject (readonly)

Returns the value of attribute detached

Returns:

  • (Object)

    the current value of detached



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def detached
  @detached
end

#exit_codeObject (readonly)

Returns the value of attribute exit_code

Returns:

  • (Object)

    the current value of exit_code



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def exit_code
  @exit_code
end

#finished_atObject (readonly)

Returns the value of attribute finished_at

Returns:

  • (Object)

    the current value of finished_at



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def finished_at
  @finished_at
end

#idString (readonly)

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bsdkrun/types.rb', line 12

SandboxInfo = Data.define(
  :id, :name, :image, :kind, :command, :status, :running, :exit_code,
  :pid, :detached, :cpus, :mem, :volume, :state_dir, :network, :net_ip,
  :created_at, :finished_at
) do
  # Map a +ps --json+ row (String keys) to a typed instance.
  # @param row [Hash]
  # @return [SandboxInfo]
  def self.from_row(row)
    running = !!row["running"]
    new(
      id: row["id"].to_s,
      name: row["name"],
      image: row["image"].to_s,
      kind: row["kind"].to_s,
      command: (row["command"] || "").to_s,
      status: running ? "running" : "exited",
      running: running,
      exit_code: to_i_or_nil(row["exit_code"]),
      pid: to_i_or_nil(row["pid"]),
      detached: !!row["detached"],
      cpus: row["cpus"].to_i,
      mem: row["mem"].to_i,
      volume: row["volume"],
      state_dir: row["state_dir"].to_s,
      network: row["network"],
      net_ip: row["net_ip"],
      created_at: row["created_at"].to_i,
      finished_at: to_i_or_nil(row["finished_at"])
    )
  end

  def self.to_i_or_nil(value)
    value.nil? ? nil : value.to_i
  end
end

#imageObject (readonly)

Returns the value of attribute image

Returns:

  • (Object)

    the current value of image



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def image
  @image
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def kind
  @kind
end

#memObject (readonly)

Returns the value of attribute mem

Returns:

  • (Object)

    the current value of mem



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def mem
  @mem
end

#nameString? (readonly)

Returns DNS name on a network, or nil if unnamed.

Returns:

  • (String, nil)

    DNS name on a network, or nil if unnamed.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bsdkrun/types.rb', line 12

SandboxInfo = Data.define(
  :id, :name, :image, :kind, :command, :status, :running, :exit_code,
  :pid, :detached, :cpus, :mem, :volume, :state_dir, :network, :net_ip,
  :created_at, :finished_at
) do
  # Map a +ps --json+ row (String keys) to a typed instance.
  # @param row [Hash]
  # @return [SandboxInfo]
  def self.from_row(row)
    running = !!row["running"]
    new(
      id: row["id"].to_s,
      name: row["name"],
      image: row["image"].to_s,
      kind: row["kind"].to_s,
      command: (row["command"] || "").to_s,
      status: running ? "running" : "exited",
      running: running,
      exit_code: to_i_or_nil(row["exit_code"]),
      pid: to_i_or_nil(row["pid"]),
      detached: !!row["detached"],
      cpus: row["cpus"].to_i,
      mem: row["mem"].to_i,
      volume: row["volume"],
      state_dir: row["state_dir"].to_s,
      network: row["network"],
      net_ip: row["net_ip"],
      created_at: row["created_at"].to_i,
      finished_at: to_i_or_nil(row["finished_at"])
    )
  end

  def self.to_i_or_nil(value)
    value.nil? ? nil : value.to_i
  end
end

#net_ipObject (readonly)

Returns the value of attribute net_ip

Returns:

  • (Object)

    the current value of net_ip



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def net_ip
  @net_ip
end

#networkObject (readonly)

Returns the value of attribute network

Returns:

  • (Object)

    the current value of network



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def network
  @network
end

#pidObject (readonly)

Returns the value of attribute pid

Returns:

  • (Object)

    the current value of pid



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def pid
  @pid
end

#runningObject (readonly)

Returns the value of attribute running

Returns:

  • (Object)

    the current value of running



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def running
  @running
end

#state_dirObject (readonly)

Returns the value of attribute state_dir

Returns:

  • (Object)

    the current value of state_dir



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def state_dir
  @state_dir
end

#statusString (readonly)

Returns "running" or "exited" (derived from running).

Returns:

  • (String)

    "running" or "exited" (derived from running).



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bsdkrun/types.rb', line 12

SandboxInfo = Data.define(
  :id, :name, :image, :kind, :command, :status, :running, :exit_code,
  :pid, :detached, :cpus, :mem, :volume, :state_dir, :network, :net_ip,
  :created_at, :finished_at
) do
  # Map a +ps --json+ row (String keys) to a typed instance.
  # @param row [Hash]
  # @return [SandboxInfo]
  def self.from_row(row)
    running = !!row["running"]
    new(
      id: row["id"].to_s,
      name: row["name"],
      image: row["image"].to_s,
      kind: row["kind"].to_s,
      command: (row["command"] || "").to_s,
      status: running ? "running" : "exited",
      running: running,
      exit_code: to_i_or_nil(row["exit_code"]),
      pid: to_i_or_nil(row["pid"]),
      detached: !!row["detached"],
      cpus: row["cpus"].to_i,
      mem: row["mem"].to_i,
      volume: row["volume"],
      state_dir: row["state_dir"].to_s,
      network: row["network"],
      net_ip: row["net_ip"],
      created_at: row["created_at"].to_i,
      finished_at: to_i_or_nil(row["finished_at"])
    )
  end

  def self.to_i_or_nil(value)
    value.nil? ? nil : value.to_i
  end
end

#volumeObject (readonly)

Returns the value of attribute volume

Returns:

  • (Object)

    the current value of volume



12
13
14
# File 'lib/bsdkrun/types.rb', line 12

def volume
  @volume
end

Class Method Details

.from_row(row) ⇒ SandboxInfo

Map a ps --json row (String keys) to a typed instance.

Parameters:

  • row (Hash)

Returns:



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

def self.from_row(row)
  running = !!row["running"]
  new(
    id: row["id"].to_s,
    name: row["name"],
    image: row["image"].to_s,
    kind: row["kind"].to_s,
    command: (row["command"] || "").to_s,
    status: running ? "running" : "exited",
    running: running,
    exit_code: to_i_or_nil(row["exit_code"]),
    pid: to_i_or_nil(row["pid"]),
    detached: !!row["detached"],
    cpus: row["cpus"].to_i,
    mem: row["mem"].to_i,
    volume: row["volume"],
    state_dir: row["state_dir"].to_s,
    network: row["network"],
    net_ip: row["net_ip"],
    created_at: row["created_at"].to_i,
    finished_at: to_i_or_nil(row["finished_at"])
  )
end

.to_i_or_nil(value) ⇒ Object



44
45
46
# File 'lib/bsdkrun/types.rb', line 44

def self.to_i_or_nil(value)
  value.nil? ? nil : value.to_i
end