Class: Fleet::Machine

Inherits:
Object
  • Object
show all
Defined in:
lib/fleet/machine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster: nil, id: nil, ip: nil, metadata: nil) ⇒ Machine

Returns a new instance of Machine.



5
6
7
8
9
10
# File 'lib/fleet/machine.rb', line 5

def initialize(cluster: nil, id: nil, ip: nil, metadata: nil)
  @cluster = cluster
  @id = id
  @ip = ip
  @metadata = 
end

Instance Attribute Details

#clusterObject (readonly)

Returns the value of attribute cluster.



3
4
5
# File 'lib/fleet/machine.rb', line 3

def cluster
  @cluster
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/fleet/machine.rb', line 3

def id
  @id
end

#ipObject (readonly)

Returns the value of attribute ip.



3
4
5
# File 'lib/fleet/machine.rb', line 3

def ip
  @ip
end

#metadataObject (readonly)

Returns the value of attribute metadata.



3
4
5
# File 'lib/fleet/machine.rb', line 3

def 
  @metadata
end

Instance Method Details

#==(other_machine) ⇒ Object Also known as: eql?



27
28
29
# File 'lib/fleet/machine.rb', line 27

def ==(other_machine)
  id == other_machine.id && ip == other_machine.ip
end

#controllerObject



12
13
14
# File 'lib/fleet/machine.rb', line 12

def controller
  cluster.controller
end

#ssh(*command, port: 22) ⇒ Object

run the command (string, array of command + args, whatever) and return stdout



21
22
23
24
25
# File 'lib/fleet/machine.rb', line 21

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

#unitsObject



16
17
18
# File 'lib/fleet/machine.rb', line 16

def units
  controller.units.select { |unit| unit.machine.id == id }
end