Exemplo n.º 1
0
class RegionConfiguration(Configuration, metaclass=RegionConfigurationMeta):
    """Local configuration for the MAAS region."""

    maas_url = ConfigurationOption(
        "maas_url", "The HTTP URL for the MAAS region.", ExtendedURL(
            require_tld=False, if_missing="http://localhost:5240/MAAS"))

    # Database options.
    database_host = ConfigurationOption(
        "database_host", "The address of the PostgreSQL database.",
        UnicodeString(if_missing="localhost", accept_python=False))
    database_port = ConfigurationOption(
        "database_port", "The port of the PostgreSQL database.",
        Int(if_missing=5432, accept_python=False, min=1, max=65535))
    database_name = ConfigurationOption(
        "database_name", "The name of the PostgreSQL database.",
        UnicodeString(if_missing="maasdb", accept_python=False))
    database_user = ConfigurationOption(
        "database_user", "The user to connect to PostgreSQL as.",
        UnicodeString(if_missing="maas", accept_python=False))
    database_pass = ConfigurationOption(
        "database_pass", "The password for the PostgreSQL user.",
        UnicodeString(if_missing="", accept_python=False))
    database_conn_max_age = ConfigurationOption(
        "database_conn_max_age",
        "The lifetime of a database connection, in seconds.",
        Int(if_missing=(5 * 60), accept_python=False, min=0))

    # Worker options.
    num_workers = ConfigurationOption(
        "num_workers", "The number of regiond worker process to run.",
        Int(if_missing=4, accept_python=False, min=1))

    # Debug options.
    debug = ConfigurationOption(
        "debug", "Enable debug mode for detailed error and log reporting.",
        StringBool(if_missing=False))
    debug_queries = ConfigurationOption(
        "debug_queries",
        "Enable query debugging. Reports number of queries and time for all "
        "actions performed. Requires debug to also be True. mode for detailed "
        "error and log reporting.",
        StringBool(if_missing=False))
    debug_http = ConfigurationOption(
        "debug_http",
        "Enable HTTP debugging. Logs all HTTP requests and HTTP responses.",
        StringBool(if_missing=False))
Exemplo n.º 2
0
    def __init__(self, settings):
        self.site_root_url = settings['site_root_url']
        self.clientToken = settings['apiToken']
        self.trackUsers = StringBool().to_python(settings['trackUsers'])
        self.gaCode = settings['gaCode']
        self.gaDomain = settings['gaDomain']
        self.filepickerKey = settings['filepickerKey']

        networks = settings['network']
        for network, params in networks.items():
            moduleName = params.pop('module')
            module = import_module(moduleName)
            self.networks[network] = SocialNetworkSettings(
                module.SocialResource, network=network, **params)

        # so on startup time we know if it exists, it is very much required for the send button:
        self.fb_app_id = self.networks['facebook'].appid
Exemplo n.º 3
0
class ClusterConfiguration(Configuration, metaclass=ClusterConfigurationMeta):
    """Local configuration for the MAAS cluster."""

    maas_url = ConfigurationOption(
        "maas_url", "The HTTP URL for the MAAS region.", ExtendedURL(
            require_tld=False, if_missing="http://localhost:5240/MAAS"))

    # TFTP options.
    tftp_port = ConfigurationOption(
        "tftp_port", "The UDP port on which to listen for TFTP requests.",
        Number(min=0, max=(2 ** 16) - 1, if_missing=69))
    tftp_root = ConfigurationOption(
        "tftp_root", "The root directory for TFTP resources.",
        DirectoryString(
            # Don't validate values that are already stored.
            accept_python=True, if_missing=get_tentative_data_path(
                "/var/lib/maas/boot-resources/current")))

    # HTTP options.
    http_workers = ConfigurationOption(
        "http_workers",
        "Number of HTTP workers to run for serving boot images.",
        Number(min=1, if_missing=2))

    # GRUB options.

    @property
    def grub_root(self):
        "The root directory for GRUB resources."
        return os.path.join(self.tftp_root, "grub")

    # NodeGroup UUID Option, used for migrating to rack controller
    cluster_uuid = ConfigurationOption(
        "cluster_uuid", "The UUID for this cluster controller",
        UUIDString(if_missing=UUID_NOT_SET))

    # Debug options.
    debug = ConfigurationOption(
        "debug", "Enable debug mode for detailed error and log reporting.",
        StringBool(if_missing=False))
Exemplo n.º 4
0
from maasserver.djangosettings import (
    fix_up_databases,
    import_settings,
    settings,
)

# We expect the following settings to be overridden. They are mentioned here
# to silence lint warnings: import_settings() below will actually re-set it
# to a tuple as set in settings.INSTALLED_APPS, and TEMPLATES to a dict.
INSTALLED_APPS = None
TEMPLATES = {}

# Extend base settings.
import_settings(settings)

prevent_migrations = StringBool().to_python(
    os.environ.get("MAAS_PREVENT_MIGRATIONS", 0))

if prevent_migrations:
    INSTALLED_APPS += ("maasserver.tests", "metadataserver.tests")

# Use our custom test runner, which makes sure that a local database
# cluster is running in the branch.
TEST_RUNNER = 'maastesting.djangoloader.MAASDjangoTestRunner'

# Don't connect to the DNS server in development because bind is not running
# and no access to write into the required directories.
DNS_CONNECT = False

# Don't setup DHCP servers in tests, this will be enabled on a case per case
# basis. TODO: Use the signals manager instead.
DHCP_CONNECT = os.environ.get("MAAS_DHCP_CONNECT", "0") == "1"