]> git.proxmox.com Git - ovs.git/blame - tests/test-l7.py
packets: Reorder CS_* flags to remove gap.
[ovs.git] / tests / test-l7.py
CommitLineData
07659514
JS
1# Copyright (c) 2015 Nicira, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at:
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import argparse
16import socket
17
18from BaseHTTPServer import HTTPServer
19from SimpleHTTPServer import SimpleHTTPRequestHandler
20from SocketServer import TCPServer
21
22
23class TCPServerV6(HTTPServer):
24 address_family = socket.AF_INET6
25
26
27def get_ftpd():
28 try:
29 from pyftpdlib.authorizers import DummyAuthorizer
30 from pyftpdlib.handlers import FTPHandler
31 from pyftpdlib.servers import FTPServer
32
2a33a3c2
JR
33 import logging
34 import pyftpdlib.log
35 pyftpdlib.log.LEVEL = logging.DEBUG
36
07659514
JS
37 class OVSFTPHandler(FTPHandler):
38 authorizer = DummyAuthorizer()
39 authorizer.add_anonymous("/tmp")
40 server = [FTPServer, OVSFTPHandler, 21]
41 except ImportError:
42 server = None
43 pass
44 return server
45
46
47def main():
48 SERVERS = {
49 'http': [TCPServer, SimpleHTTPRequestHandler, 80],
50 'http6': [TCPServerV6, SimpleHTTPRequestHandler, 80],
51 }
52
53 ftpd = get_ftpd()
54 if ftpd is not None:
55 SERVERS['ftp'] = ftpd
56
57 protocols = [srv for srv in SERVERS]
58 parser = argparse.ArgumentParser(
59 description='Run basic application servers.')
60 parser.add_argument('proto', default='http', nargs='?',
61 help='protocol to serve (%s)' % protocols)
62 args = parser.parse_args()
63
64 if args.proto not in SERVERS:
65 parser.print_help()
66 exit(1)
67
68 constructor = SERVERS[args.proto][0]
69 handler = SERVERS[args.proto][1]
70 port = SERVERS[args.proto][2]
71 srv = constructor(('', port), handler)
72 srv.serve_forever()
73
74
75if __name__ == '__main__':
76 main()