Class: Fleet::Machine
- Inherits:
-
Object
- Object
- Fleet::Machine
- Defined in:
- lib/fleet/machine.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
readonly
Returns the value of attribute cluster.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #==(other_machine) ⇒ Object (also: #eql?)
- #controller ⇒ Object
-
#initialize(cluster: nil, id: nil, ip: nil, metadata: nil) ⇒ Machine
constructor
A new instance of Machine.
-
#ssh(*command, port: 22) ⇒ Object
run the command (string, array of command + args, whatever) and return stdout.
- #units ⇒ Object
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
#cluster ⇒ Object (readonly)
Returns the value of attribute cluster.
3 4 5 |
# File 'lib/fleet/machine.rb', line 3 def cluster @cluster end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/fleet/machine.rb', line 3 def id @id end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
3 4 5 |
# File 'lib/fleet/machine.rb', line 3 def ip @ip end |
#metadata ⇒ Object (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 |
#controller ⇒ Object
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 |
#units ⇒ Object
16 17 18 |
# File 'lib/fleet/machine.rb', line 16 def units controller.units.select { |unit| unit.machine.id == id } end |