Developer

last person joined: 8 days ago 

Expand all | Collapse all

How to push Json config into a switch ??

This thread has been viewed 9 times
  • 1.  How to push Json config into a switch ??

    Posted Apr 15, 2019 09:22 AM

    Guys,

     

    i have a json config file.

     

    example :

    },
    "no-syslog/ipv4": {
    "cfg_aces": {
    "10": {
    "action": "deny",
    "dst_ip": "10.30.56.31/255.255.255.255",
    "dst_l4_port_max": 514,
    "dst_l4_port_min": 514,
    "protocol": 17
    },
    "20": {
    "action": "permit"
    },
    "5": {
    "action": "deny",
    "dst_ip": "10.30.1.55/255.255.255.255",
    "dst_l4_port_max": 514,
    "dst_l4_port_min": 514,
    "protocol": 17
    }
    },
    "cfg_version": -1614603666118581,
    "list_type": "ipv4",
    "name": "no-syslog"
    }

     

     

    how do i get started to push this json config into a switch.

     

    I am fimiliar with postman "GET" and "POST" request. But i have a feeling it will be hard using postman.

     

    I could use python, but still unsure how API technically work.

     

    Is there any tool/application for pushing json configs ?

     

    Can anyone please point me in the right direction ??

     

    Thanks



  • 2.  RE: How to push Json config into a switch ??

    MVP GURU
    Posted Apr 15, 2019 09:27 AM

    Hi,

     

    What switch do you want to configure ?

     

    and where can from this json config ?



  • 3.  RE: How to push Json config into a switch ??

    Posted Apr 15, 2019 09:40 AM

    its a aruba os(2930)

     

    i dont get this "and where can from this json config ?"

     

    i will take a look at the link.



  • 4.  RE: How to push Json config into a switch ??

    MVP GURU
    Posted Apr 15, 2019 10:26 AM

    @headshotboy wrote:

     

     

    i will take a look at the link.


    for the link, it is only my signature about some PowerShell Module for ArubaSW..

     

    i can be a solution for import JSON to ArubaSW

    But you need to known the URL/URI and the payload

    and you can use

    Invoke-ArubaSWWebRequest -url "rest/v.." -method "post" -body $payload


  • 5.  RE: How to push Json config into a switch ??

    Posted Apr 15, 2019 10:08 AM

    following the link, i install the module and imported it.

     

    but the connect command is not working

    Connect to your switch

    Connect-ArubaSW 192.0.2.1

    Connect-ArubaSW : The term 'Connect-ArubaSW' is not recognized as the name of a cmdlet, function, script file, or
    operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
    again.
    At line:1 char:1



  • 6.  RE: How to push Json config into a switch ??

    Posted Apr 15, 2019 10:18 AM

    Sorry i had to import the module again.



  • 7.  RE: How to push Json config into a switch ??

    EMPLOYEE
    Posted Apr 16, 2019 05:14 PM

    Hi Headshotboy,

     

    There are plenty of options to utilize the REST API on AOS-Switch devices.  You are certainly welcome to use Postman to configure the switch.  After enabling REST on the switch, you'll simply need to first save the login cookie by sending a POST command to the URI https://<ip address>/rest/v1/login-sessions with the keys userName and password, such as in this screen shot:AOS-Switch Postman login.PNG

     

    which should return your session cookie, and you're then able to do more POST and GETs from there.  More information on this can be found in our REST guide here.

    Don't forget to "logout" of the session by sending a DELETE request to the sessionID of the login-sessions URI.

     

    For information about the Schema and format for each JSON request, here is the REST Schema for the 2930M (depending which firmware version you're running).

     

    If you were interested in Python, we actually have some examples in our GitHub (located here) as well as some videos on our Airheads Broadcasting Channel all about using Python and REST with our AOS-Switches!

     

    I hope this helps, and feel free to ask any more questions if you have them.