Class: Phut::Syntax::NetnsDirective

Inherits:
Directive
  • Object
show all
Defined in:
lib/phut/syntax/netns_directive.rb

Overview

The ‘netns(name) { …attributes… }’ directive.

Instance Method Summary collapse

Methods inherited from Directive

#[], attribute, #method_missing

Constructor Details

#initialize(alias_name, &block) ⇒ NetnsDirective

Returns a new instance of NetnsDirective.



11
12
13
14
15
# File 'lib/phut/syntax/netns_directive.rb', line 11

def initialize(alias_name, &block)
  @attributes = { name: alias_name,
                  netmask: '255.255.255.255' }
  instance_eval(&block) if block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Phut::Syntax::Directive

Instance Method Details

#ip(value) ⇒ Object



17
18
19
20
# File 'lib/phut/syntax/netns_directive.rb', line 17

def ip(value)
  @attributes[:ip] = value
  @attributes[:name] ||= value
end

#mac(value) ⇒ Object



27
28
29
# File 'lib/phut/syntax/netns_directive.rb', line 27

def mac(value)
  @attributes[:mac_address] = value
end

#route(options) ⇒ Object



22
23
24
25
# File 'lib/phut/syntax/netns_directive.rb', line 22

def route(options)
  @attributes[:net] = options.fetch(:net)
  @attributes[:gateway] = options.fetch(:gateway)
end

#vlan(value) ⇒ Object



31
32
33
# File 'lib/phut/syntax/netns_directive.rb', line 31

def vlan(value)
  @attributes[:vlan] = value
end