-
Re: Using vWLAN APIs
daniel.blackmon Aug 6, 2015 7:01 AM (in response to vasilek)1 of 1 people found this helpfulIf you haven't already, take a look at Using APIs with vWLAN. This should give you plenty of examples. That said, you should probably modify your curl command.
curl -i -H "Accept:application/xml" -H "Content-Type:application/xml" -X GET -k -u ${user}:${pass} https://server_ip:3000/locations?active_domain_name="$domain"
I use this in scripts, and I just tested again before posting.
-
Re: Using vWLAN APIs
vasilek Aug 6, 2015 7:55 AM (in response to daniel.blackmon)Thank you very much! I's working!
In manual not written by symbol " in active_domain_name.
The final request:
curl -H "Accept:application/xml" -H "Content-Type:application/xml" -X GET -k -u root@adtran.com:blueblue https://server_ip:3000/internalusers?active_domain_name="default"
Thanks,
Evgeniy.
-
-
Re: Using vWLAN APIs
vasilek Aug 10, 2015 12:16 AM (in response to vasilek)Hello, I have anothe question.
I want to delete internal user, but i don't know parameters in xml request. Maybe someone had to deal with it.
-
Re: Using vWLAN APIs
vasilek Aug 10, 2015 12:28 AM (in response to vasilek)If i used -X DELETE . I have reply HTML page 404.
-
Re: Using vWLAN APIs
daniel.blackmon Sep 21, 2016 9:57 AM (in response to vasilek)Make sure the URL looks something like this.
curl -i -H "Accept:application/xml" -H "Content-Type:application/xml" -X DELETE -k -u daniel@adtran.com:password https://localhost:3000/internalusers/3?active_domain_name="office"
-
-
Re: Using vWLAN APIs
kris Sep 19, 2016 4:27 AM (in response to vasilek)Can you help in get API for username from clients with the ip address ?
curl -H "Accept:application/xml" -H "Content-Type:application/xml" -X GET -k -u root@adtran.com:blueblue https://server_ip:3000/active_user_statuses?active_domain_name="default"
-
Re: Using vWLAN APIs
daniel.blackmon Sep 19, 2016 10:12 AM (in response to kris)I apologize in advance if I misunderstood your question, but you cannot pull specific fields directly from the UI. You would have to pull the whole list of active users and parse that out.
Maybe we can still help though. I tend towards Python, and I request JSON from the API. The reason being that JSON format translates directly to Python lists and dictionaries. First off, use these HTML headers.
HEADERS = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
The following code snippet is a method from a larger class which has some defined cleanup functions, so it won't translate directly into other code, but you can perhaps see that what I do is pull the active_user_statuses resource and return a list of individual statuses.
def all_user_status(self):
"""Returns a Python list of active user statuses."""
# Statuses will be returned as a list of dictionaries.
# Note that the vWLAN API cannot always process this request as there
# is a lot of information that gets returned.
active_user_statuses = []
for status in self.get('active_user_statuses', self.name):
if status == 'error':
msg = 'Error: vWLAN API was unable to process this request'
active_user_statuses.append(msg)
else:
status = self.convert_values(status['active_user_status'])
active_user_statuses.append(status)
return active_user_statuses
Now, to answer your question, here's an example of how what I do.
>>> import vwlan
>>> d = vwlan.Domain(server_host, server_admin, admin_password, domain_name)
>>> for status in d.all_user_status():
... if 'name' in status:
... print status['name']
... if 'host_name' in status:
... print status['host_name']
... print status['ipaddr']
...
user01
user01Phone5s
10.5.2.170
>>>
tl;dr: You need to parse the output returned from the API call, and look for name, host_name, and ipaddr.
-
Re: Using vWLAN APIs
kris Sep 22, 2016 12:35 AM (in response to daniel.blackmon)Thanks for the reply
Sorry I can understand this.
my question is to get the Name of the user and access point connected to with the provided ip address ?
Will i need to install Python in the windows to get this with the above script ?
-
-
-
Re: Using vWLAN APIs
sergey.batakov Sep 21, 2016 8:10 AM (in response to vasilek)Hello all.
Anyone can help me create location by using API.
I'm try example from documentation, but not work
curl -i -H “Accept:application/xml” -H “Content-Type:application/xml” -X POST -k -u xxx:xxx https://10.1.1.20:3000/locations -d "<locations><location><name>WIFI0</name><vlan type="integer">1000</vlan><cidr>100.64.0.0/21</cidr></location></locations>"
- <script>
- jQuery(function(){jQuery.gritter.add({image:'/assets/error-c9302e0b7e951136df31bed19b68d929.png',title:'Form Error',text:'Name can\'t be blank'});});
- </script>
- <script>
- jQuery(function(){jQuery.gritter.add({image:'/assets/error-c9302e0b7e951136df31bed19b68d929.png',title:'Form Error',text:'CIDR must be a valid IP address'});});
- </script>
- <script>
- jQuery(function(){jQuery.gritter.add({image:'/assets/error-c9302e0b7e951136df31bed19b68d929.png',title:'Form Error',text:'CIDR netmask should be between 0 and 32.'});});
- </script>
- <script>
- jQuery(function(){jQuery.gritter.add({image:'/assets/error-c9302e0b7e951136df31bed19b68d929.png',title:'Form Error',text:'Vlan is not a number'});});
- </script>
-
Re: Using vWLAN APIs
daniel.blackmon Sep 21, 2016 8:23 AM (in response to sergey.batakov)There are two things you can try.
- Make sure you include the active_domain_name parameter.
- Remove the encapsulating locations tag.
Since you are posting to the locations page anyways, you don't need those outer tags. Your URL should look something like this.
https://<server>:3000/locations?active_domain_name="default"
You can also use the active_domain_id if you happen to know the ID, but in most cases you would not have that data point.
Your data in XML or JSON will look like this.
<location><name>WIFI0</name><vlan type="integer">1000</vlan><cidr>100.64.0.0/21</cidr></location>
{"location" : {"name": "WIFI0", "vlan": 1000, "cidr": "100.64.0.0/21"}}
One thing you might consider is manually creating a Location, then use the GET method to pull that data from the system. You can then make sure you have all the formatting correct. Also note that when you create an item you use a POST (which you have correctly done) and you will not include an ID. So when you GET the data, you will see an ID. You do not need to set that when you create a new item.
-
Re: Using vWLAN APIs
sergey.batakov Sep 21, 2016 8:52 AM (in response to daniel.blackmon)Can you example how can modified AP by API
https://<server>:3000/accesspoints?active_domain_name="default"
Return 404
-
Re: Using vWLAN APIs
daniel.blackmon Sep 21, 2016 9:39 AM (in response to sergey.batakov)To edit an AP you do need to get the ID. There's a number of way to pull that, but for visual purposes, just edit the AP through the UI and note the URL you see. It should be something like this.
https://<server>:3000/accesspoints/8/edit
So now what you want to do is use PUT to update the AP, but you would strip '/edit' from the URL. Something like this.
curl -X PUT https://<server>:3000/accesspoints/8>active_domain_name="default" -d '{"accesspoint": {<ap stuffs>}}"
Please note that I am leaving out username/password information from cURL for the sake a brevity. Your previous comments indicate you are already familiar enough with that part of things.
-
Re: Using vWLAN APIs
sergey.batakov Sep 22, 2016 1:06 PM (in response to daniel.blackmon)...
* ALPN, server did not agree to a protocol
* Server auth using Basic with user 'RAPI@XXX'
> POST /accesspoints/103?active_domain_name=default HTTP/1.1
> Host: XXX.XXX.XXX.XX:3000
> Authorization: Basic UkFQSUBzb3V0aC5ydC5ydTpSQVBJMjAxNg==
> User-Agent: curl/7.47.0
> Accept: */*
> “Accept:application/json”
> “Content-Type:application/json”
> Content-Length: 37
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 37 out of 37 bytes
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
< Server: nginx/1.0.15
Server: nginx/1.0.15
Not working.
Maybe something missing....
-
-
-
Re: Using vWLAN APIs
sergey.batakov Sep 21, 2016 8:39 AM (in response to vasilek)Thank you. It's work.