Skip to content

Commit

Permalink
Merge pull request #2 from tjbalaji/first_version
Browse files Browse the repository at this point in the history
second code drop from stash
  • Loading branch information
tjbalaji committed May 3, 2018
2 parents 0aec429 + 6a7bbfd commit 0003f8a
Show file tree
Hide file tree
Showing 15 changed files with 287 additions and 96 deletions.
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ The current version of dellos10 module contains Providers that makes use of OS10

The `dellos10` module is dependant on the following ruby modules:

* `xmlhash`
* `dellos10shellapi`
* `os10_devops_ruby_utils`

## Setup

### Setup Requirements

#### Installing `libxml` module
#### Installing `os10_devops_ruby_utils` module

#### Installing `dellos10shellapi` module
The dellos10 puppet module requires `os10_devops_ruby_utils` module to be installed separately for communicating with the underlying OS10 operating system. The installation procedure can be found at [readthedocs.org](https://readthedocs.org/projects/puppet-dellos-docs/)

### Beginning with dellos10

Expand Down Expand Up @@ -359,6 +358,24 @@ Enable the Address Family for this Neighbor.
##### `allowas_in`
Configure allowed local AS number in as-path. Valid values are 1-10.

##### `add_path`
Configures the setting to Send or Receive multiple paths. Blank string removes the configuration.

##### `distribute_list`
Filter networks in routing updates. Valid parameter is an array of two Prefix list name (max 140 chars) for applying policy to incoming and outgoing routes respectively.

##### `next_hop_self`
Enables or Disables the next hop calculation for this neighbor.

##### `route_map`
Names of the route map. Valid parameter is an array of two Route-map name (max 140 chars) for filtering incoming and outgoing routing updates.

##### `sender_side_loop_detection`
Configures sender side loop detect for neighbor.

##### `soft_reconfiguration`
Configures per neighbor soft reconfiguration.

### Type: os10_lldp
`os10_lldp` resource type is to used to manage global LLDP configuration in OS10 EE switches. The os10_lldp resource is not an ensurable type and hence does not have an ensure attribute.

Expand All @@ -373,21 +390,14 @@ This property is a string with a value range of <1-10>. An empty string will rem
##### `timer`
This property is a string with a value range of <5-254>. An empty string will remove the timer value from the LLDP configuration.

<<<<<<< HEAD

##### `med_fast_start_repeat_count`
This property is a string with a value range of <1-10>, (default=3). An empty string will remove the med fast start repeat count value from the LLDP configuration.

=======
##### `med_fast_start_repeat_count`
This property is a string with a value range of <1-10>, (default=3). An empty string will remove the med fast start repeat count value from the LLDP configuration.

>>>>>>> eed90d49509d12294afcf970db637a89d4800169
##### `enable`
This property is a boolean string with value 'true' or 'false' to enable or disable the lldp globally.

##### `med_network_policy`
This will be an array of hash entries with the set of hash keys id<1-32>, app, vlan_id<1-4093>, vlan_type<tag/untag>, priority<0-7>, dscp<0-63>.
This will be an array of hash entries with the set of hash keys id<1-32>, app<guest-voice, guestvoice-signaling, softphone-voice, streaming-video, video-conferencing, voice-signaling, voice, video-signaling>, vlan_id<1-4093>, vlan_type<tag/untag>, priority<0-7>, dscp<0-63>.

### Type: os10_lldp_interface
`os10_lldp_interface` resource type is to used to manage LLDP configuration per interface in OS10 EE switches. The os10_lldp resource is not an ensurable type and hence does not have an ensure attribute. The per interface name is given as arg for the resource.
Expand Down Expand Up @@ -443,4 +453,4 @@ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2
~~~

© 2018 Dell EMC
© 2018 Dell EMC
1 change: 0 additions & 1 deletion lib/puppet/provider/os10_bgp/dellos10.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ def flush
end
info conf_lines.to_s
ecc conf_lines
end_os10_shell
rescue Exception => e
err "Exception in #{__method__}"
err e.message
Expand Down
21 changes: 8 additions & 13 deletions lib/puppet/provider/os10_bgp_af/dellos10.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def init(ipver)
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand Down Expand Up @@ -168,7 +167,6 @@ def extract(dict, *keys)
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand All @@ -185,7 +183,6 @@ def exists?
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand All @@ -203,7 +200,6 @@ def create
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand All @@ -216,7 +212,6 @@ def destroy
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand Down Expand Up @@ -325,24 +320,26 @@ def flush
add = val - @net_addr
del = @net_addr - val

add.each do |v|
# It is important to delete first then create!
del.each do |v|
l = v.split(' ')
if l.length == 2
conf_lines << "network #{l[0]} route-map #{l[1]}"
conf_lines << "no network #{l[0]} route-map #{l[1]}"
else
conf_lines << "network #{l[0]}"
conf_lines << "no network #{l[0]}"
end
end

del.each do |v|
add.each do |v|
l = v.split(' ')
if l.length == 2
conf_lines << "no network #{l[0]} route-map #{l[1]}"
conf_lines << "network #{l[0]} route-map #{l[1]}"
else
conf_lines << "no network #{l[0]}"
conf_lines << "network #{l[0]}"
end
end


when :redistribute
# Handle the case of creating from blank
@redis = [] if !@redis
Expand Down Expand Up @@ -371,12 +368,10 @@ def flush
end
info conf_lines.to_s
ecc conf_lines
end_os10_shell
rescue Exception => e
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/provider/os10_bgp_neighbor/dellos10.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ def flush
info conf_lines.to_s
ecc conf_lines

end_os10_shell
rescue Exception => e
err "Exception in #{__method__}"
err e.message
Expand Down
116 changes: 106 additions & 10 deletions lib/puppet/provider/os10_bgp_neighbor_af/dellos10.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# This is called only once during startup.
# neighbor_ipname is an ip address when neighbor_type is ip.
# neighbor_ipname is a name string when neighbor_type is template
def init(nbr_ipname, nbr_type)
def init(nbr_ipname, nbr_type, ip_ver)
begin
ret = esc 'show running-configuration bgp | display-xml'
bgp = extract(ret, :stdout, 'rpc-reply', :data, :'bgp-router')
Expand All @@ -46,19 +46,48 @@ def init(nbr_ipname, nbr_type)
nbr = extract_peer(bgp, nbr_ipname, nbr_type)
raise "neighbor #{nbr_ipname} not configured." if !nbr

@nbr_af = extract(nbr, ip_ver.to_s + '-unicast')
@nbr_af = extract(nbr, (ip_ver.to_s + '-unicast').to_sym)
if !@nbr_af
# There is no af configuration for the given ip type
return
end

@property_hash[:activate] = extract(@nbr_af, :'activate')
@property_hash[:allowas_in] = extract(@nbr_af, :'allowas-in')
@property_hash[:add_path] = extract_add_path(@nbr_af)

val = extract(@nbr_af, :'next-hop-self')
val = :false if !val
@property_hash[:next_hop_self] = val

val = extract(@nbr_af, :'sender-side-loop-detection')
val = :true if !val
@property_hash[:sender_side_loop_detection] = val

val = @nbr_af.has_key? :'soft-reconfiguration-inbound'
val = :false if !val
@property_hash[:soft_reconfiguration] = val

val = extract(@nbr_af, :'distribute-list-name-in')
val = '' if !val
@property_hash[:distribute_list] = [val]

val = extract(@nbr_af, :'distribute-list-name-out')
val = '' if !val
@property_hash[:distribute_list].push(val)

val = extract(@nbr_af, :'route-map-in')
val = '' if !val
@property_hash[:route_map] = [val]

val = extract(@nbr_af, :'route-map-out')
val = '' if !val
@property_hash[:route_map].push(val)

rescue Exception => e
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand All @@ -68,6 +97,18 @@ def initialize(value = {})
@property_flush = {}
end

def extract_add_path(nbr_af)
apath = extract(nbr_af, :'add-path')
ret = ''
if apath
ret = extract(apath, :'capability')
if ret == 'send' || ret == 'both'
ret += ' ' + extract(apath, :'count')
end
end
ret
end

# ip_name is either ip address if type==ip or template name if type==template
def extract_peer(bgp, ip_name, type)
# rubocop:disable Style/Semicolon
Expand Down Expand Up @@ -131,7 +172,6 @@ def extract(dict, *keys)
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand All @@ -140,15 +180,14 @@ def extract(dict, *keys)
def exists?
info "#{__method__} for #{resource[:asn]} #{resource[:neighbor]}"
begin
init(resource[:neighbor], resource[:type])
init(resource[:neighbor], resource[:type], resource[:ip_ver])
ret = (@nbr_af != nil)
info "exists? returning #{ret}"
ret
rescue Exception => e
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand All @@ -165,7 +204,6 @@ def create
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand All @@ -179,7 +217,6 @@ def destroy
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand Down Expand Up @@ -233,18 +270,77 @@ def flush
conf_lines << "allowas-in #{val}"
end

when :add_path
if val.empty?
conf_lines << 'no add-path'
else
conf_lines << "add-path #{val}"
end

when :next_hop_self
if val == 'false'
conf_lines << 'no next-hop-self'
else
conf_lines << 'next-hop-self'
end

when :sender_side_loop_detection
if val == 'false'
conf_lines << 'no sender-side-loop-detection'
else
conf_lines << 'sender-side-loop-detection'
end

when :soft_reconfiguration
if val == 'false'
conf_lines << 'no soft-reconfiguration inbound'
else
conf_lines << 'soft-reconfiguration inbound'
end

when :distribute_list
raise "Invalid distribute_list #{val}" if val.length != 2 ||
val[0].class != String ||
val[1].class != String
if !val[0].empty?
conf_lines << "distribute-list #{val[0]} in"
else
conf_lines << 'no distribute-list TEMP in'
end

if !val[1].empty?
conf_lines << "distribute-list #{val[1]} out"
else
conf_lines << 'no distribute-list TEMP out'
end

when :route_map
raise "Invalid route_map #{val}" if val.length != 2 ||
val[0].class != String ||
val[1].class != String
if !val[0].empty?
conf_lines << "route-map #{val[0]} in"
else
conf_lines << 'no route-map TEMP in'
end

if !val[1].empty?
conf_lines << "route-map #{val[1]} out"
else
conf_lines << 'no route-map TEMP out'
end

else
debug "skipping translating #{attr} to CLI"
end
end

info conf_lines.to_s
ecc conf_lines
end_os10_shell
rescue Exception => e
err "Exception in #{__method__}"
err e.message
err e.backtrace[0]
end_os10_shell
raise
end
end
Expand Down

0 comments on commit 0003f8a

Please sign in to comment.