lib/junos-ez/l1_ports.rb
## returns a Hash of status information, from "show interface ..."
## basic information, not absolutely everything.  but if a 
## block is given, then pass the XML to the block.

returns a Hash of status information, from "show interface ..."
basic information, not absolutely everything.  but if a
block is given, then pass the XML to the block.
returns a Hash of status information from " show interface ... " basic information not absolutely everything . but if a block is given then pass the XML to the block .
def status
    got = @ndev.rpc.get_interface_information(:interface_name => @name, :media => true )
    phy = got.xpath('physical-interface')[0]
    return nil unless phy
    ret_h = {}
    ret_h[:macaddr] = phy.xpath('current-physical-address').text.strip 
    xml_when_item(phy.xpath('description')){|i| ret_h[:description] = i.text.strip }
    ret_h[:oper_status] = phy.xpath('oper-status').text.strip
    ret_h[:admin_status] = phy.xpath('admin-status').text.strip
    ret_h[:mtu] = phy.xpath('mtu').text.to_i
    ret_h[:speed] = {:admin => phy.xpath('speed').text.strip }
    ret_h[:duplex] = {:admin => phy.xpath('duplex').text.strip }
    ret_h[:autoneg] = phy.xpath('if-auto-negotiation').text.strip 
    if ret_h[:autoneg] == "enabled"
      autoneg = phy.xpath('ethernet-autonegotiation')[0]
      ret_h[:speed][:oper] = autoneg.xpath('link-partner-speed').text.strip
      ret_h[:duplex][:oper] = autoneg.xpath('link-partner-duplexity').text.strip
    end
    yield( phy ) if block_given?
    ret_h
  end
def status got = @ndev . rpc . get_interface_information ( :interface_name => @name , :media => true ) phy = got . xpath ( 'physical-interface' ) [ 0 ] return nil unless phy ret_h = { } ret_h [ :macaddr ] = phy . xpath ( 'current-physical-address' ) . text . strip xml_when_item ( phy . xpath ( 'description' ) ) { | i | ret_h [ :description ] = i . text . strip } ret_h [ :oper_status ] = phy . xpath ( 'oper-status' ) . text . strip ret_h [ :admin_status ] = phy . xpath ( 'admin-status' ) . text . strip ret_h [ :mtu ] = phy . xpath ( 'mtu' ) . text . to_i ret_h [ :speed ] = { :admin => phy . xpath ( 'speed' ) . text . strip } ret_h [ :duplex ] = { :admin => phy . xpath ( 'duplex' ) . text . strip } ret_h [ :autoneg ] = phy . xpath ( 'if-auto-negotiation' ) . text . strip if ret_h [ :autoneg ] == "enabled" autoneg = phy . xpath ( 'ethernet-autonegotiation' ) [ 0 ] ret_h [ :speed ] [ :oper ] = autoneg . xpath ( 'link-partner-speed' ) . text . strip ret_h [ :duplex ] [ :oper ] = autoneg . xpath ( 'link-partner-duplexity' ) . text . strip end yield ( phy ) if block_given? ret_h end
returns a Hash of status information, from "show interface ..."
basic information, not absolutely everything.
returns a Hash of status information from " show interface ... " basic information not absolutely everything .
# if a block is given, then it means the caller wants to process the XML data.
