/usr/share/pyshared/landscape/broker/config.py is in landscape-common 12.04.3-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | """Configuration class for the broker."""
import os
from landscape.deployment import Configuration
class BrokerConfiguration(Configuration):
"""Specialized configuration for the Landscape Broker.
@cvar required_options: C{["url"]}
"""
def __init__(self):
super(BrokerConfiguration, self).__init__()
self._original_http_proxy = os.environ.get("http_proxy")
self._original_https_proxy = os.environ.get("https_proxy")
@property
def exchange_store_path(self):
return os.path.join(self.data_path, "exchange.database")
def make_parser(self):
"""Parser factory for broker-specific options.
@return: An L{OptionParser} preset for all the options
from L{Configuration.make_parser} plus:
- C{account_name}
- C{registration_password}
- C{computer_title}
- C{exchange_interval} (C{15*60})
- C{urgent_exchange_interval} (C{1*60})
- C{http_proxy}
- C{https_proxy}
- C{cloud}
- C{otp}
- C{provisioning_otp}
"""
parser = super(BrokerConfiguration, self).make_parser()
parser.add_option("-a", "--account-name", metavar="NAME",
help="The account this computer belongs to.")
parser.add_option("-p", "--registration-password", metavar="PASSWORD",
help="The account-wide password used for "
"registering clients.")
parser.add_option("-t", "--computer-title", metavar="TITLE",
help="The title of this computer")
parser.add_option("--exchange-interval", default=15 * 60, type="int",
metavar="INTERVAL",
help="The number of seconds between server "
"exchanges.")
parser.add_option("--urgent-exchange-interval", default=1 * 60,
type="int", metavar="INTERVAL",
help="The number of seconds between urgent server "
"exchanges.")
parser.add_option("--ping-interval", default=30, type="int",
metavar="INTERVAL",
help="The number of seconds between pings.")
parser.add_option("--http-proxy", metavar="URL",
help="The URL of the HTTP proxy, if one is needed.")
parser.add_option("--https-proxy", metavar="URL",
help="The URL of the HTTPS proxy, if one is needed.")
parser.add_option("--cloud", action="store_true",
help="Set this if your computer is in an EC2 cloud.")
parser.add_option("--otp", default="",
help="The OTP to use in cloud configuration.")
parser.add_option("--tags",
help="Comma separated list of tag names to be sent "
"to the server.")
parser.add_option("--provisioning-otp", default="",
help="The OTP to use for a provisioned machine.")
return parser
@property
def message_store_path(self):
"""Get the path to the message store."""
return os.path.join(self.data_path, "messages")
def load(self, args, accept_nonexistent_config=False):
"""
Load options from command line arguments and a config file.
Load the configuration with L{Configuration.load}, and then set
C{http_proxy} and C{https_proxy} environment variables based on
that config data.
"""
super(BrokerConfiguration, self).load(
args, accept_nonexistent_config=accept_nonexistent_config)
if self.http_proxy:
os.environ["http_proxy"] = self.http_proxy
elif self._original_http_proxy:
os.environ["http_proxy"] = self._original_http_proxy
if self.https_proxy:
os.environ["https_proxy"] = self.https_proxy
elif self._original_https_proxy:
os.environ["https_proxy"] = self._original_https_proxy
|