blob: 274bd36596ea168fa24d9f9ac3bd7aa9e046ec44 (
plain)
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
|
#!/usr/bin/env python
"""The XML-RPC Bcfg2 server."""
import sys
import logging
import Bcfg2.Options
from Bcfg2.Server.Core import CoreInitError
class BackendAction(Bcfg2.Options.ComponentAction):
""" Action to load Bcfg2 backends """
islist = False
bases = ['Bcfg2.Server']
class CLI(object):
""" bcfg2-server CLI class """
options = [
Bcfg2.Options.Option(
cf=('server', 'backend'), help='Server Backend',
default='BuiltinCore', type=lambda b: b.title() + "Core",
action=BackendAction)]
def __init__(self):
parser = Bcfg2.Options.get_parser("Bcfg2 server", components=[self])
parser.parse()
self.logger = logging.getLogger(parser.prog)
def run(self):
""" Run the bcfg2 server """
try:
core = Bcfg2.Options.setup.backend()
core.run()
except CoreInitError:
self.logger.error(sys.exc_info()[1])
return 1
except TypeError:
self.logger.error("Failed to load %s server backend: %s" %
(Bcfg2.Options.setup.backend.__name__,
sys.exc_info()[1]))
raise
except KeyboardInterrupt:
return 1
if __name__ == '__main__':
sys.exit(CLI().run())
|