- Timestamp:
- Nov 28, 2008 2:54:22 PM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 1b57352
- Parents:
- 0ea5050
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd.py
r0ea5050 ra2da110 3 3 import sys 4 4 5 from socket import error as socket_error 5 6 from BaseHTTPServer import BaseHTTPRequestHandler 6 7 … … 268 269 version="0.1") 269 270 270 self.set_defaults(host="localhost", port=23235, transport="soap", 271 logfile=None, debug=0) 271 self.set_defaults(logfile=None, debug=0) 272 272 273 273 self.add_option("-d", "--debug", action="count", dest="debug", 274 274 help="Set debug. Repeat for more information") 275 275 self.add_option("-f", "--configfile", action="store", 276 default="/usr/local/etc/fedd.conf", 276 277 dest="configfile", help="Configuration file (required)") 277 self.add_option("-H", "--host", action="store", type="string",278 dest="host", help="Hostname to listen on (default %default)")279 278 self.add_option("-l", "--logfile", action="store", dest="logfile", 280 279 help="File to send log messages to") 281 self.add_option("-p", "--port", action="store", type="int",282 dest="port", help="Port to listen on (default %default)")283 self.add_option("-s", "--service", action="append", type="string",284 dest="services",285 help="Service description: host:port:transport")286 self.add_option("-x","--transport", action="store", type="choice",287 choices=("xmlrpc", "soap"),288 help="Transport for request (xmlrpc|soap) (Default: %default)")289 280 self.add_option("--trace", action="store_const", dest="tracefile", 290 281 const=sys.stderr, help="Print SOAP exchange to stderr") 291 282 292 283 servers_active = True # Sub-servers run while this is True 293 services = [ ] # Service descriptions294 284 servers = [ ] # fedd_server instances instantiated from services 295 285 servers_lock = Lock() # Lock to manipulate servers from sub-server threads … … 385 375 raise 386 376 387 # Walk through the service descriptions and pack them into the services list. 388 # That list has the form (transport (host, port)). 389 if opts.services: 390 for s in opts.services: 391 try: 392 h, p, t = s.split(':') 393 except ValueError: 394 sys.exit("Invalid services specification: %s" % s) 395 396 if not h: h = opts.host 397 if not p: p = opts.port 398 if not t: h = opts.transport 399 400 p = int(p) 401 402 services.append((t, (h, p))) 403 else: 404 services.append((opts.transport, (opts.host, opts.port))) 405 406 # Create the servers and put them into a list 407 for s in services: 408 if s[0] == "soap": 409 servers.append(fedd_server(s[1], fedd_soap_handler, ctx, impl)) 410 elif s[0] == "xmlrpc": 411 servers.append(fedd_server(s[1], fedd_xmlrpc_handler, ctx, impl)) 412 else: flog.warning("Unknown transport: %s" % s[0]) 377 services = config.get("globals", "services", "23235") 378 379 for s in services.split(","): 380 s = s.strip() 381 colons = s.count(":") 382 try: 383 if colons == 0: 384 p = int(s) 385 h = '' 386 t = 'soap' 387 elif colons == 1: 388 p, t = s.split(":") 389 p = int(p) 390 h = '' 391 elif colons == 2: 392 h, p, t = s.split(":") 393 p = int(p) 394 else: 395 flog.error("Invalid service specification %s ignored." % s) 396 continue 397 except ValueError: 398 flog.error("Error converting port to integer in %s: spec ignored" % s) 399 continue 400 401 t = t.lower() 402 try: 403 if t == 'soap': 404 servers.append(fedd_server((h, p), fedd_soap_handler, ctx, impl)) 405 elif t == 'xmlrpc': 406 servers.append(fedd_server((h, p), fedd_xmlrpc_handler, ctx, impl)) 407 else: 408 flog.error("Invalid transport specification (%s) in service %s" % \ 409 (t, s)) 410 continue 411 except socket_error, e: 412 flog.error("Cannot create server for %s: %s" % (s, e[1])) 413 continue 413 414 414 415 # Make sure that there are no malformed servers in the list 415 serv ices = [ s for s in services if s ]416 servers = [ s for s in servers if s ] 416 417 417 418 # Catch signals
Note: See TracChangeset
for help on using the changeset viewer.