Forum Discussion

Dan_Mather's avatar
Dan_Mather
Icon for Nimbostratus rankNimbostratus
May 19, 2018

selfLink not work for sys/hardware

Hi, I've been working with the iControl REST interface for several months. While researching the hardware information returned in the mgmt/tm/sys/hardware call, I found that I cannot use any of the selfLinks returned to narrow my request.

 

For instance, I'd like to get just the power supply information. The self link says Substituting the hostname for localhost I get an error: {"code":400,"message":"Found unexpected json pair at component /sys/hardware. The json pair is \"\":{\"chassis-power-supply-index\":null}.","errorstack":[]}

 

Am I missing something? Thanks

 

2 Replies

  • Despite the URL "; in the output, it does not seem to be directly accessible, even with v13.1.0. So you still need to get the whole output and use a tool to parse it. You must already have something to do the parsing. Nonetheless, here's a "simple" way I have tried to get this info:

    curl -s -k -u admin:admin -X GET 'https://mgmt_IP_address/mgmt/tm/sys/hardware/' | jq '.entries."https://localhost/mgmt/tm/sys/hardware/chassis-power-supply-status-index" | tostring'

    You will need jg v1.5 for this.

  • As Niels said, you need to strip off the

    chassis-power-supply-status-index
    part:

    !/usr/bin/env python3
    
    import pprint
    import requests
    
    requests.packages.urllib3.disable_warnings()
    
    s = requests.Session()
    s.auth = ('username', 'password')
    
    r = s.get('https://hostname/mgmt/tm/sys/hardware', verify=False)
    
    pprint.pprint(r.json())
    

    You can deduce this by looking at the TMSH command to pull this information:

    tmsh show sys hardware
    (there isn't a
    chassis-power-supply-status-index
    argument).

    But once you have the JSON you can pull the info directly from there.