Wired Intelligent Edge

last person joined: yesterday 

Bring performance and reliability to your network with the HPE Aruba Networking Core, Aggregation, and Access layer switches. Discuss the latest features and functionality of your switching devices, and find ways to improve security across your network to bring together a mobile-first solution
Expand all | Collapse all

ArubaOS REST API /vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}

This thread has been viewed 28 times
  • 1.  ArubaOS REST API /vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}

    Posted Aug 07, 2017 02:12 PM

    Hello,

     

    I'm trying to add a VLAN to a port with an API call. I can retrieve and delete a VLAN from a port (GET .../vlans-ports and DELETE .../vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}).

     

    Accourding to the documentation a PUT .../vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id} should add the VLAN to the specified port and return VlanPort. Instead the call returns a session id:

    {
    "uri": "/rest/v1/login-sessions","cookie":
    "sessionId=09CG1bRuT5hkCPzI97mmDjpn4uLtsmgkBsAaWUr9h7GxlkbsiASak1PEyj7Ov3n"
    }

     

    Has anyone succeeded in adding a VLAN to a 802.1q port?

     

    Link to the documentation:https://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjX1Neh0b3VAhWLaVAKHWN-BRAQFggmMAA&url=http%3A%2F%2Fh20566.www2.hpe.com%2Fhpsc%2Fdoc%2Fpublic%2Fdisplay%3Fsp4ts.oid%3D7074783%26docLocale%3Den_US%26docId%3Demr_na-c05373669&usg=AFQjCNE0-ggh8-ZTfvY4u7P7pAKaQJcrOA

     



  • 2.  RE: ArubaOS REST API /vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}
    Best Answer

    EMPLOYEE
    Posted Aug 18, 2017 07:01 AM

    Hi,

     

    I think this is a bit different. In this case put is used to change a port mode to tag/untagg for e.g. This can be done in following way:

     

    vlan_port = { "port_id": "21", "port_mode" : "POM_TAGGED_STATIC"}

     r3 = requests.put('http://192.168.100.1/rest/v1/vlans-ports/1-21', data = json.dumps(vlan_port))

     

    vlan_port = { "port_id": "21", "port_mode" : "POM_UNTAGGED"}

     r3 = requests.put('http://192.168.100.1/rest/v1/vlans-ports/1-21', data = json.dumps(vlan_port))

     

    But if you want to add port in certain vlan you need to use post:

    vlan_port1 = { "vlan_id": 10, "port_id": "20", "port_mode" : "POM_UNTAGGED"}

    r4 = requests.post('http://192.168.100.1/rest/v1/vlans-ports', data = json.dumps(vlan_port1))

     

    vlan_port1 = { "vlan_id": 70, "port_id": "21", "port_mode" : "POM_TAGGED_STATIC"}

    r4 = requests.post('http://192.168.100.1/rest/v1/vlans-ports', data = json.dumps(vlan_port1))

     

    Hope this will help you!

     

    Regards, Dobias

     

     



  • 3.  RE: ArubaOS REST API /vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}
    Best Answer

    EMPLOYEE
    Posted Aug 22, 2017 10:32 AM

    Did this work for you?



  • 4.  RE: ArubaOS REST API /vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}

    Posted Nov 24, 2017 08:10 AM

    Thx, that did it!

     



  • 5.  RE: ArubaOS REST API /vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}

    Posted Jan 30, 2020 06:32 AM

    Hi Guys,

     

    I am unble to remove a port(untagged) from a vlan. I am using the following code:

     

    $sessionId = createSession();
    $url = 'http://IP/rest/v1/vlans-ports';
    $data_array = array(
    "vlan_id" => 93,
    "port_id" => 9,
    );
    $res = callAPI('DELETE', $url, $sessionId, json_encode($data_array));

     

    The call is not returning anything.

     

    Please suggest!

     

    Thanks



  • 6.  RE: ArubaOS REST API /vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}

    MVP GURU
    Posted Jan 31, 2020 02:34 AM

     


    @amardeepsingh wrote:

    Hi Guys,

     

    I am unble to remove a port(untagged) from a vlan. I am using the following code:

     

    $sessionId = createSession();
    $url = 'http://IP/rest/v1/vlans-ports';
    $data_array = array(
    "vlan_id" => 93,
    "port_id" => 9,
    );
    $res = callAPI('DELETE', $url, $sessionId, json_encode($data_array));

     

    The call is not returning anything.

     

    Please suggest!

     

    Thanks


    Hi,

    Do you have an error ?

    do you have check log ?

    it will be better to open on Dev section



  • 7.  RE: ArubaOS REST API /vlans-ports/{VlanPort.vlan_id}-{VlanPort.port_id}

    Posted Sep 19, 2023 11:16 AM

    Is it possible to change vlan name for a vlan with REST API?


    And what is the right way to delete a vlan with the rest api?

    I have tried with request.delete("hostUrl /rest/v1/vlans/vlan_idvlan"), but I get error method not allowed.