-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenstack-dns
More file actions
executable file
·61 lines (46 loc) · 1.48 KB
/
openstack-dns
File metadata and controls
executable file
·61 lines (46 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
import logging
import sys
import argparse
import novacfg
import novaqueue
import novapdns
import background
# parse command line arguments
def parseArgs():
parser = argparse.ArgumentParser(description='openstackdns')
parser.add_argument('-c', action="store", dest="configfile", required=True)
parser.add_argument('-d', action="store_true", dest="debug")
args = parser.parse_args()
return(args)
def main(argv):
logLevel = logging.DEBUG # default to debug
# parse up the command line arguments
args = parseArgs()
# parse the config file
config = novacfg.novaConfig()
try:
if not args.debug:
background.createDaemon()
logLevel = logging.INFO # switch to info if not debugging
except:
pass
# first we setup the logger
logger = logging.getLogger('novadns')
hdlr = logging.FileHandler( config.get('LOG', 'logfile') )
formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logLevel)
logger.info("Starting openstack-dns")
# make a pdns object to deal with talking to the database
pdns = novapdns.pdnsDatabase(config)
# make a queue object to watch qpid for nova messages
queue = novaqueue.novaQueue(config)
# start watching the queue pushing entries into pdns
try:
queue.get(pdns)
except:
logger.exception("Something bad happened")
if __name__ == "__main__":
main(sys.argv[1:])