Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/junos-ez/ip_ports/classic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ def xml_read_parser( as_xml, as_hash )
xml_when_item(as_xml.xpath('description')){ |i| as_hash[:description] = i.text }
xml_when_item(ifa_inet.xpath('mtu')){ |i| as_hash[:mtu] = i.text.to_i }

# @@@ assuming a single IP address; prolly need to be more specific ...
as_hash[:address] = ifa_inet.xpath('address/name').text || nil
# The address could be a list.
address = []
ifa_inet.xpath('address').each do |addr|
address << addr.xpath('name').text
end
as_hash[:address] = address || nil

# check for firewall-filters (aka ACLs)
if (fw_acl = ifa_inet.xpath('filter')[0])
Expand Down
16 changes: 16 additions & 0 deletions lib/junos-ez/l1_ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ def build_list
ifs.text.strip
end
end

def build_port_mac
@port_mac = {}
interfaces = @ndev.rpc.get_interface_information({
:media => true,
:terse => true,
:interface_name => Junos::Ez::L1ports::IFS_NAME_FILTER
})

interfaces.xpath('physical-interface').each do |interface|
name= interface.xpath("name").text.strip
mac_addr = interface.xpath("current-physical-address").text.strip
@port_mac[name] = mac_addr
end
return @port_mac
end

def build_catalog
@catalog = {}
Expand Down
10 changes: 10 additions & 0 deletions lib/junos-ez/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def initialize( p_obj, name = nil, opts = {} )

@list = [] # array list of item names
@catalog = {} # hash catalog of named items
@port_mac = {} # hash of ports and its mac address

return unless @name
# resources only from here ...
Expand Down Expand Up @@ -192,6 +193,15 @@ def catalog!
@catalog.clear
@catalog = build_catalog
end

def port_mac
@port_mac.empty? ? port_mac! : @port_mac
end

def port_mac!
@port_mac.clear
@port_mac = build_port_mac
end

### ---------------------------------------------------------------
### CREATE methods
Expand Down