Exemplo n.º 1
0
 def __init__(self):
     loginmgr = PersistentLogin("admin","admin")
     self.wsc = NOXWSClient("127.0.0.1", 443, True, loginmgr)
     self.debug = True
Exemplo n.º 2
0
 def __init__(self):
     loginmgr = PersistentLogin("admin", "admin")
     self.wsc = NOXWSClient("127.0.0.1", 8888, False, loginmgr)
     self.print_progress = True
     self.print_requests = False
Exemplo n.º 3
0
            command = a
        elif o == '-u':
            adminu = a
        elif o == '-p':
            adminp = a
        else:
            assert False, "unhandled option"

    if not directory or not switch or not command:
        usage()
        sys.exit()

    print ' Logging into web service.. ',
    loginmgr = PersistentLogin("admin", "admin")
    # currently only support localhost
    wsc = NOXWSClient("127.0.0.1", 443, True, loginmgr)
    print 'done'

    urlstr = '/ws.v1/switch/' + directory + '/' + switch + '/command'
    print ' Issuing:'
    print '\t', urlstr
    url = urllib.quote(urlstr)

    d = {}
    d['command'] = command
    d['args'] = args
    headers = {}
    headers["content-type"] = "application/json"
    response = wsc.put(url, headers, simplejson.dumps(d))
    body = response.getBody()