5 from http.server import BaseHTTPRequestHandler
8 ch = logging.StreamHandler(sys.stdout)
12 format='[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s',
16 logger = logging.getLogger('AAI-simulator-logger')
21 class AAISetup(BaseHTTPRequestHandler):
24 logger.info('AAI SIM Setup Put execution')
25 if re.search('/set_pnf', self.path):
27 content_length = int(self.headers['Content-Length'])
28 pnfs = self.rfile.read(content_length)
29 logger.info('Execution status 200')
30 httpServerLib.header_200_and_json(self)
32 if re.search('/set_pnf_entry',self.path):
33 logger.info('Execution status 200')
34 httpServerLib.header_200_and_json(self)
39 logger.info('AAI SIM Setup Post execution')
40 if re.search('/reset', self.path):
43 logger.info('Execution status 200')
44 httpServerLib.header_200_and_json(self)
49 class AAIHandler(BaseHTTPRequestHandler):
52 logger.info('AAI SIM Patch execution')
53 pnfs_name = '/aai/v12/network/pnfs/pnf/' + pnfs.decode()
54 if re.search('wrong_aai_record', self.path):
55 self.send_response(400)
56 logger.info('Execution status 400')
58 elif re.search(pnfs_name, self.path):
59 self.send_response(200)
60 logger.info('Execution status 200')
66 def _main_(handler_class=AAIHandler, protocol="HTTP/1.0"):
67 handler_class.protocol_version = protocol
68 httpServerLib.start_http_endpoint(3333, AAIHandler)
69 httpServerLib.start_https_endpoint(3334, AAIHandler, keyfile="certs/org.onap.aai.key", certfile="certs/aai_aai.onap.org.cer", ca_certs="certs/ca_local_0.cer")
70 httpServerLib.start_http_endpoint(3335, AAISetup)
75 if __name__ == '__main__':