Class: Tinet::Command::Exec

Inherits:
Base
  • Object
show all
Defined in:
lib/tinet/command/exec.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Shell

#sh, #sudo

Constructor Details

This class inherits a constructor from Tinet::Command::Base

Instance Method Details

#run(node_name, command) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/tinet/command/exec.rb', line 6

def run(node_name, command)
  node = nodes.find { |node| node.name == node_name }
  raise "No such container: #{node_name}" if node.nil?
  case node.type
  when :docker
    sudo "docker exec -it #{namespaced(node.name)} #{command}"
  when :netns
    sudo "ip netns exec #{namespaced(node.name)} #{command}"
  end
end