Class: Construqt::Flavour::Ciscian::Hp2510g
- Inherits:
-
Object
- Object
- Construqt::Flavour::Ciscian::Hp2510g
show all
- Defined in:
- lib/construqt/flavour/ciscian/dialect_hp-2510g.rb
Defined Under Namespace
Classes: Tagged, TrunkVerb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(result) ⇒ Hp2510g
Returns a new instance of Hp2510g.
9
10
11
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 9
def initialize(result)
@result=result
end
|
Class Method Details
.name ⇒ Object
5
6
7
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 5
def self.name
'hp-2510g'
end
|
Instance Method Details
#add_bond(bond) ⇒ Object
41
42
43
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 41
def add_bond(bond)
throw "not implemented yet"
end
|
#add_device(device) ⇒ Object
38
39
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 38
def add_device(device)
end
|
#add_host(host) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 26
def add_host(host)
@result.add("hostname", Ciscian::SingleValueVerb).add(@result.host.name)
@result.add("max-vlans", Ciscian::SingleValueVerb).add(64)
@result.add("snmp-server community \"public\" Unrestricted", Ciscian::SingleValueVerb)
@result.host.interfaces.values.each do |iface|
next unless iface.delegate.address
iface.delegate.address.routes.each do |route|
@result.add("ip route #{route.dst.to_s} #{route.dst.netmask} #{route.via.to_s}", Ciscian::SingleValueVerb)
end
end
end
|
#add_vlan(vlan) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 45
def add_vlan(vlan)
@result.add("vlan #{vlan.delegate.vlan_id}") do |section|
next unless vlan.delegate.description && !vlan.delegate.description.empty?
throw "vlan name too long, max 32 chars" if vlan.delegate.description.length > 32
section.add("name", Ciscian::SingleValueVerb).add(vlan.delegate.description)
vlan.interfaces.each do |port|
section.add({
true => "tagged",
false => "untagged"
}[port.template.is_tagged?(vlan.vlan_id)], Ciscian::RangeVerb).add(port.delegate.number)
end
if vlan.delegate.address
if vlan.delegate.address.first_ipv4
section.add("ip address").add(vlan.delegate.address.first_ipv4.to_string)
elsif vlan.delegate.address.dhcpv4?
section.add("ip address").add("dhcp-bootp")
end
end
end
end
|
#block_end?(line) ⇒ Boolean
83
84
85
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 83
def block_end?(line)
['end','exit'].include?(line.strip)
end
|
#clear_interface(line) ⇒ Object
76
77
78
79
80
81
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 76
def clear_interface(line)
line.to_s.split(/\s+/).map do |i|
split = /^([^0-9]+)([0-9].*)$/.match(i)
split ? split[1..-1] : i
end.flatten.join(' ')
end
|
#commit ⇒ Object
13
14
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 13
def commit
end
|
#expand_device_name(device) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 16
def expand_device_name(device)
return device.delegate.dev_name if device.delegate.dev_name
pattern = (({
"po" => "Trk%s",
"ge" => "ethernet %s"
})[device.name[0..1]])
throw "device not expandable #{device.name}" unless pattern
pattern%device.name[2..-1]
end
|
#parse_line(line, lines, section, result) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/construqt/flavour/ciscian/dialect_hp-2510g.rb', line 69
def parse_line(line, lines, section, result)
[TrunkVerb, Tagged
].find do |i|
i.parse_line(line, lines, section, result)
end
end
|