..
[tests.git] / system / url_scanner.py
1 # a rough utility for testing xmlrpclib URL's
2 import xmlrpclib
3 auth={'AuthMethod':'password','Username':'root@test.onelab.eu','AuthString':'test++'}
4
5 host='vplc21'
6
7 import socket
8 hostname="%s.pl.sophia.inria.fr"%host
9 ip=socket.gethostbyname(hostname)
10
11 import traceback
12 verbose=True
13
14 def try_url (url,xmlrpclib_verbose=False):
15     try:
16         xmlrpclib.ServerProxy (url, verbose=xmlrpclib_verbose, allow_none=True).GetNodes(auth)
17         print 'YES',url
18     except xmlrpclib.ProtocolError as e:
19         print '... (http error %s)'%e.errcode,url
20     except Exception as e:
21         print '---',type(e).__name__,url
22         if verbose: traceback.print_exc()
23
24 def scan():
25     for protocol in ['http','https']:
26         for dest in [ hostname, ip ]:
27             for port in [ '',':80',':443']:
28 #            for port in [ ':80',':443']:
29                 for path in ['PLCAPI','PLCAPI/']:
30                     if protocol=='http' and port==':443': continue
31                     if protocol=='https' and port==':80': continue
32                     url="%s://%s%s/%s"%(protocol,dest,port,path)
33                     try_url (url)
34