0

I have implemented a python program to send data across to a Juniper wlc100 controller. I have to use the prewritten juniper wlc file to send data to the controller. The error was that a "host" parameter was missing. I don't think we need a host parameter to be sent along with the 3 parameters I already passed by looking at the program. The github page for viewing the jnpr.wlc code is https://github.com/Juniper/py-jnpr-wlc. Please take time and help me.Thank you.

The error I am getting is:

from jnpr.wlc import WirelessLanController as WLC
import sys
import urllib2
def WLC_login():
    login = {
        'user': 'xxxxx',
        'hostname': '172.31.99.14',
        'password': 'xxxxx',
        }
    wlc = WLC( login )
    try_again = 3
    login_ok = False
    while try_again > 1:
        try:
            wlc.open()
            login_ok = True
            print("Login successful")
            break;
        except:
            try_again-=1
            print "Unexpected error:", sys.exc_info()[0]
    if not login_ok:
        sys.exit(1)
    return wlc

WLC_login()

The tracedump is:

Traceback (most recent call last):

File "C:/Python27/py-jnpr-wlc-master/new.py", line 27, in <module>
    WLC_login()

File "C:/Python27/py-jnpr-wlc-master/new.py", line 11, in WLC_login
    wlc = WLC( login )

File "C:\Python27\lib\site-packages\jnpr_wlc-0.0.1-py2.7.egg\jnpr\wlc\wlc.py", line 160, in __init__
    assert (_a in kvargs), ("Missing required param: %s" % _a)
AssertionError: Missing required param: host
Alastair McCormack
  • 26,573
  • 8
  • 77
  • 100
  • shouldn't you be using "host" instead of "hostname" in your "login" dictionary? I have no idea about Juniper but doing a quick perusal of the documentation .. I thought that could be it.. on the git hub link you posted I see this .. "wlc = WLC( user='jeremy', host='192.168.56.191', password='logmein' ) " – vHalaharvi Jul 09 '15 at 17:41

1 Answers1

0

I'm not sure if you intend to send a dict as arguments to WLC(). While it's possible to send kwargs this way, I think what you really want to do is:

wlc = WLC( user="xxxxx", host='172.31.99.14', password="xxxxx" )
Alastair McCormack
  • 26,573
  • 8
  • 77
  • 100
  • Hi thank you for the quick reply.I changed wlc to pass values as you suggested and i get an Unexpected error: Unexpected error: ....Please help – Abishek Kumar Jul 09 '15 at 17:53
  • That is the entire error. Unexpected error: repeated twice as i used a loop.Thank You. – Abishek Kumar Jul 09 '15 at 18:04
  • Your except statement is masking the error. Please add `raise` after `print "Unexpected error:", sys.exc_info()[0]` – Alastair McCormack Jul 09 '15 at 18:07
  • When i added raise after print i got a lot of error which finally ended in urllib2.URLError: – Abishek Kumar Jul 09 '15 at 18:12
  • We're going way off piste here but try: `wlc = WLC( user="xxxxx", host='172.31.99.14', password="xxxxx", http="http" )` – Alastair McCormack Jul 09 '15 at 18:23
  • I changed https to http in the base juniper program given to me and have included your corrections and I got these 2 errors Unexpected error: Unexpected error: – Abishek Kumar Jul 09 '15 at 18:45
  • I suspect it's because port 80 is blocked. If port 80 is blocked, then you'll have to investigate how to work around CERTIFICATE error. I'm afraid we've gone as far as we should answer the original question. You should raise a new question with the new error. Please accept this answer before you do :) – Alastair McCormack Jul 09 '15 at 18:57
  • I changed port number to 8080.I now have got Unexpected error: Unexpected error: .Should i continue with this post or raise a new question? – Abishek Kumar Jul 09 '15 at 19:03
  • Good work. That would seem to indicate a problem with the wlc library. Perhaps you should raise an problem directly: https://github.com/Juniper/py-jnpr-wlc/issues – Alastair McCormack Jul 09 '15 at 19:06