Class: Tinet::Command::Up

Inherits:
Base
  • Object
show all
Defined in:
lib/tinet/command/up.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/up.rb', line 6

def run
  exec_pre_cmd
  exec_pre_init

  # Create Nodes and Switches
  nodes.each { |node| node_up(node) }
  switches.each { |switch| switch_up(switch) }

  # Create Links
  links.each { |link| link_up(link) }

  # Attach physnet / veth to Conitaner
  nodes.each do |node|
    node.interfaces.each do |interface|
      case interface.type
      when :phys
        koko_physnet("#{namespaced(node.name)}", interface.name)
      when :veth
        sudo "ip link add #{interface.name} type veth peer name #{interface.args}"
        koko_physnet("#{namespaced(node.name)}", interface.name)
        sudo "ip link set #{interface.args} up"
      end
    end
  end

  exec_post_init
end