diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2011-01-02 19:26:19 +0100 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2011-04-08 18:19:54 +1000 |
| commit | 28e3db87a105eba5eddbb11167d0a6c33b18f8ce (patch) | |
| tree | 528522c0f8f73fdd88facbc4dfe27cc05444554d /lib/puppet/util | |
| parent | 1cb18410732a4b51efa0a106d4a1437daef08fc5 (diff) | |
| download | puppet-28e3db87a105eba5eddbb11167d0a6c33b18f8ce.tar.gz puppet-28e3db87a105eba5eddbb11167d0a6c33b18f8ce.tar.xz puppet-28e3db87a105eba5eddbb11167d0a6c33b18f8ce.zip | |
Add management of router/switchs global vlans
This allows to manage the global device list of vlans.
Currently supports only cisco IOS devices.
This is as easy as:
Vlan {
device_url => "ssh://user:pass@switch.domain.com/"
}
vlan {
"200": description => "R&D";
"99": description => "Management";
}
The device_url conforms to the same specs as for the interface
type.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/util')
| -rw-r--r-- | lib/puppet/util/network_device/cisco/device.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/puppet/util/network_device/cisco/device.rb b/lib/puppet/util/network_device/cisco/device.rb index 97489bd8c..1f350991a 100644 --- a/lib/puppet/util/network_device/cisco/device.rb +++ b/lib/puppet/util/network_device/cisco/device.rb @@ -163,11 +163,11 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice:: case l # vlan name status when /^(\d+)\s+(\w+)\s+(\w+)\s+([a-zA-Z0-9,\/. ]+)\s*$/ - vlan = { :id => $1, :name => $2, :status => $3, :interfaces => [] } + vlan = { :name => $1, :description => $2, :status => $3, :interfaces => [] } if $4.strip.length > 0 vlan[:interfaces] = $4.strip.split(/\s*,\s*/).map{ |ifn| canonalize_ifname(ifn) } end - vlans[vlan[:id]] = vlan + vlans[vlan[:name]] = vlan when /^\s+([a-zA-Z0-9,\/. ]+)\s*$/ raise "invalid sh vlan summary output" unless vlan if $1.strip.length > 0 @@ -179,6 +179,27 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice:: vlans end + def update_vlan(id, is = {}, should = {}) + if should[:ensure] == :absent + Puppet.info "Removing #{id} from device vlan" + transport.command("conf t") + transport.command("no vlan #{id}") + transport.command("exit") + return + end + + # We're creating or updating an entry + transport.command("conf t") + transport.command("vlan #{id}") + [is.keys, should.keys].flatten.uniq.each do |property| + Puppet.debug("trying property: #{property}: #{should[property]}") + next if property != :description + transport.command("name #{should[property]}") + end + transport.command("exit") + transport.command("exit") + end + def parse_trunking(interface) trunking = {} out = transport.command("sh interface #{interface} switchport") |
