diff --git a/lib/junos-ez/ip_ports/classic.rb b/lib/junos-ez/ip_ports/classic.rb index 4b38166..257aa75 100644 --- a/lib/junos-ez/ip_ports/classic.rb +++ b/lib/junos-ez/ip_ports/classic.rb @@ -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]) diff --git a/lib/junos-ez/l1_ports.rb b/lib/junos-ez/l1_ports.rb index 264c850..0949859 100644 --- a/lib/junos-ez/l1_ports.rb +++ b/lib/junos-ez/l1_ports.rb @@ -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 = {} diff --git a/lib/junos-ez/provider.rb b/lib/junos-ez/provider.rb index 7a11b79..ab204ee 100644 --- a/lib/junos-ez/provider.rb +++ b/lib/junos-ez/provider.rb @@ -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 ... @@ -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