Class: Tinet::Command::Down

Inherits:
Base
  • Object
show all
Defined in:
lib/tinet/command/down.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

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tinet/command/down.rb', line 6

def run
  exec_pre_cmd
  exec_pre_down

  nodes.each do |node|
    node.interfaces.each do |interface|
      if interface.type == :phys
        detach_physnet_from_docker("#{namespaced(node.name)}", interface.name)
      end
    end
  end

  nodes.each do |node|
    case node.type
    when :docker
      sudo "docker stop #{namespaced(node.name)}"
    when :netns
      sudo "ip netns del #{namespaced(node.name)}"
    end
  end

  switches.each do |switch|
    sudo "ovs-vsctl del-br #{namespaced(switch.name)}"
  end

  exec_post_down
end