Class: Construqt::Flavour::FlavourDelegate
- Inherits:
-
Object
- Object
- Construqt::Flavour::FlavourDelegate
- Defined in:
- lib/construqt/flavour/flavour.rb
Instance Attribute Summary collapse
-
#flavour ⇒ Object
readonly
Returns the value of attribute flavour.
Instance Method Summary collapse
- #bgp ⇒ Object
- #clazzes ⇒ Object
- #create_bgp(cfg) ⇒ Object
-
#create_host(name, cfg) ⇒ Object
def clazz(name) delegate = self.clazzes throw “class not found ##name” unless delegate flavour = @flavour.clazz(name) throw “class not found ##name” unless flavour delegate.new(flavour) end.
-
#create_interface(dev_name, cfg) ⇒ Object
def create_result(name, cfg) HostDelegate.new(@flavour.create_host(name, cfg)) end.
- #create_ipsec(cfg) ⇒ Object
-
#initialize(flavour) ⇒ FlavourDelegate
constructor
A new instance of FlavourDelegate.
- #ipsec ⇒ Object
- #name ⇒ Object
- #pre_clazzes(&block) ⇒ Object
Constructor Details
#initialize(flavour) ⇒ FlavourDelegate
Returns a new instance of FlavourDelegate.
9 10 11 |
# File 'lib/construqt/flavour/flavour.rb', line 9 def initialize(flavour) @flavour = flavour end |
Instance Attribute Details
#flavour ⇒ Object (readonly)
Returns the value of attribute flavour.
8 9 10 |
# File 'lib/construqt/flavour/flavour.rb', line 8 def flavour @flavour end |
Instance Method Details
#bgp ⇒ Object
21 22 23 |
# File 'lib/construqt/flavour/flavour.rb', line 21 def bgp @flavour.bgp end |
#clazzes ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/construqt/flavour/flavour.rb', line 25 def clazzes ret = { "opvn" => OpvnDelegate, "gre" => GreDelegate, "host" => HostDelegate, "device"=> DeviceDelegate, "vrrp" => VrrpDelegate, "bridge" => BridgeDelegate, "bond" => BondDelegate, "vlan" => VlanDelegate, #"result" => ResultDelegate, "template" => TemplateDelegate } end |
#create_bgp(cfg) ⇒ Object
66 67 68 |
# File 'lib/construqt/flavour/flavour.rb', line 66 def create_bgp(cfg) BgpDelegate.new(@flavour.create_bgp(cfg)) end |
#create_host(name, cfg) ⇒ Object
def clazz(name)
delegate = self.clazzes[name]
throw "class not found #{name}" unless delegate
flavour = @flavour.clazz(name)
throw "class not found #{name}" unless flavour
delegate.new(flavour)
end
54 55 56 |
# File 'lib/construqt/flavour/flavour.rb', line 54 def create_host(name, cfg) HostDelegate.new(@flavour.create_host(name, cfg)) end |
#create_interface(dev_name, cfg) ⇒ Object
def create_result(name, cfg)
HostDelegate.new(@flavour.create_host(name, cfg))
end
62 63 64 |
# File 'lib/construqt/flavour/flavour.rb', line 62 def create_interface(dev_name, cfg) clazzes[cfg['clazz']].new(@flavour.create_interface(dev_name, cfg)) end |
#create_ipsec(cfg) ⇒ Object
70 71 72 |
# File 'lib/construqt/flavour/flavour.rb', line 70 def create_ipsec(cfg) IpsecDelegate.new(@flavour.create_ipsec(cfg)) end |
#ipsec ⇒ Object
17 18 19 |
# File 'lib/construqt/flavour/flavour.rb', line 17 def ipsec @flavour.ipsec end |
#name ⇒ Object
13 14 15 |
# File 'lib/construqt/flavour/flavour.rb', line 13 def name @flavour.name end |
#pre_clazzes(&block) ⇒ Object
40 41 42 43 44 |
# File 'lib/construqt/flavour/flavour.rb', line 40 def pre_clazzes(&block) @flavour.clazzes.each do |key, clazz| block.call(key, clazz) end end |