16
16
class BrokerConfiguration(Configuration):
17
"""Specialized configuration for the Landscape Broker."""
17
"""Specialized configuration for the Landscape Broker.
19
@cvar required_options: C{["url"]}
19
22
required_options = ["url"]
24
27
self._original_https_proxy = os.environ.get("https_proxy")
26
29
def make_parser(self):
28
Specialize L{Configuration.make_parser}, adding many
29
broker-specific options.
30
"""Parser factory for broker-specific options.
32
@return: An L{OptionParser} preset for all the options
33
from L{Configuration.make_parser} plus:
35
- C{registration_password}
39
- C{exchange_interval} (C{15*60})
40
- C{urgent_exchange_interval} (C{1*60})
31
46
parser = super(BrokerConfiguration, self).make_parser()
65
80
def message_store_path(self):
81
"""Get the path to the message store."""
66
82
return os.path.join(self.data_path, "messages")
68
84
def load(self, args, accept_nonexistent_config=False):
86
Load options from command line arguments and a config file.
70
88
Load the configuration with L{Configuration.load}, and then set
71
http_proxy and https_proxy environment variables based on that config
89
C{http_proxy} and C{https_proxy} environment variables based on
74
92
super(BrokerConfiguration, self).load(
75
93
args, accept_nonexistent_config=accept_nonexistent_config)
87
105
class BrokerService(LandscapeService):
89
The core Twisted Service which creates and runs all necessary
90
components when started.
106
"""The core C{Service} of the Landscape Broker C{Application}.
108
The Landscape broker service handles all the communication between the
109
client and server. When started it creates and runs all necessary components
110
to exchange messages with the Landscape server.
112
@ivar persist_filename: Path to broker-specific persisted data.
113
@ivar persist: A L{Persist} object saving and loading from
114
C{self.persist_filename}.
115
@ivar message_store: A L{MessageStore} used by the C{exchanger} to
116
queue outgoing messages.
117
@ivar transport: A L{HTTPTransport} used by the C{exchanger} to deliver messages.
118
@ivar identity: The L{Identity} of the Landscape client the broker runs on.
119
@ivar exchanger: The L{MessageExchange} exchanges messages with the server.
120
@ivar pinger: The L{Pinger} checks if the server has new messages for us.
121
@ivar registration: The L{RegistrationHandler} performs the initial
124
@cvar service_name: C{"broker"}
93
127
transport_factory = HTTPTransport
94
128
service_name = "broker"
96
130
def __init__(self, config):
132
@param config: a L{BrokerConfiguration}.
97
134
self.persist_filename = os.path.join(
98
135
config.data_path, "%s.bpickle" % (self.service_name,))
99
136
super(BrokerService, self).__init__(config)
130
167
def startService(self):
132
Set up the persist, message store, transport, reactor, and
133
dbus message exchange service.
170
Create the DBus-published L{BrokerDBusObject}, and start
171
the L{MessageExchange} and L{Pinger} services.
135
173
If the configuration specifies the bus as 'session', the DBUS
136
174
message exchange service will use the DBUS Session Bus.