Пример #1
0
class RdsInstanceConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    identifier = jsonobject.StringProperty(required=True)
    engine_version = jsonobject.StringProperty(default='9.6.6')
    instance_type = jsonobject.StringProperty(
        required=True)  # should start with 'db.'
    multi_az = jsonobject.BooleanProperty(default=False)
    storage = jsonobject.IntegerProperty(required=True)
    max_storage = jsonobject.IntegerProperty(default=0)
    create = jsonobject.BooleanProperty(default=True)
    username = "******"
    backup_window = "06:27-06:57"
    backup_retention = 30
    maintenance_window = "sat:08:27-sat:08:57"
    port = 5432
    params = jsonobject.DictProperty()

    _default_params = {
        'pg_stat_statements.track': 'all',
        'pg_stat_statements.max': 10000,
        'track_activity_query_size': 2048,
    }

    @classmethod
    def wrap(cls, data):
        if 'params' not in data:
            data['params'] = {}
        params = data['params']
        for name, value in cls._default_params.items():
            if name not in params:
                params[name] = value
        return super(RdsInstanceConfig, cls).wrap(data)
Пример #2
0
class FabSettingsConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    sudo_user = jsonobject.StringProperty()
    default_branch = jsonobject.StringProperty()
    home = jsonobject.StringProperty()
    project = jsonobject.StringProperty()
    code_repo = GitUriProperty()
    timing_log = jsonobject.StringProperty()
    keepalive = jsonobject.IntegerProperty()
    ignore_kafka_checkpoint_warning = jsonobject.BooleanProperty()
    acceptable_maintenance_window = jsonobject.ObjectProperty(
        lambda: AcceptableMaintenanceWindow)
    email_enabled = jsonobject.BooleanProperty()

    @classmethod
    def wrap(cls, data):
        for deprecated_property in ('py3_include_venv', 'py3_run_deploy'):
            if deprecated_property in data:
                print("{} {} {}".format(
                    color_notice("The property"),
                    color_code(deprecated_property),
                    color_notice("is deprecated and has no effect.")))
                print(
                    color_notice(
                        "Feel free to remove it from your fab-settings.yml."))
                del data[deprecated_property]

        obj = super(FabSettingsConfig, cls).wrap(data)
        return obj
Пример #3
0
class DBOptions(jsonobject.JsonObject):
    _allow_dynamic_properties = False

    name = jsonobject.StringProperty(required=True)
    host = jsonobject.StringProperty()
    pgbouncer_hosts = jsonobject.ListProperty(str)
    pgbouncer_endpoint = jsonobject.StringProperty(default=None)
    port = jsonobject.IntegerProperty(default=None)
    user = jsonobject.StringProperty()
    password = jsonobject.StringProperty()
    options = jsonobject.DictProperty(six.text_type)
    django_alias = jsonobject.StringProperty()
    django_migrate = jsonobject.BooleanProperty(default=True)
    query_stats = jsonobject.BooleanProperty(default=False)
    create = jsonobject.BooleanProperty(default=True)

    # config values to be set at the database level
    pg_config = jsonobject.ListProperty(lambda: PGConfigItem)

    @classmethod
    def wrap(cls, data):
        if 'pgbouncer_host' in data:
            assert 'pgbouncer_hosts' not in data and 'pgbouncer_endpoint' not in data
            pgbouncer_host = data.pop('pgbouncer_host')
            data['pgbouncer_hosts'] = [pgbouncer_host]
            data['pgbouncer_endpoint'] = pgbouncer_host

        return super(DBOptions, cls).wrap(data)
Пример #4
0
class AppProcessesConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    django_bind = IpAddressProperty()
    django_port = PortProperty()
    flower_port = PortProperty()
    gunicorn_workers_factor = jsonobject.IntegerProperty()
    gunicorn_workers_static_factor = jsonobject.IntegerProperty()
    formplayer_memory = MemorySpecProperty()
    http_proxy = IpAddressAndPortProperty()
    newrelic_djangoagent = jsonobject.BooleanProperty()
    newrelic_javaagent = jsonobject.BooleanProperty()
    django_command_prefix = jsonobject.StringProperty()
    celery_command_prefix = jsonobject.StringProperty()
    datadog_pythonagent = jsonobject.BooleanProperty()
    additional_no_proxy_hosts = CommaSeparatedStrings()

    service_blacklist = jsonobject.ListProperty(unicode)
    celery_processes = jsonobject.DictProperty(
        jsonobject.DictProperty(CeleryOptions))
    pillows = jsonobject.DictProperty(jsonobject.DictProperty())

    def check(self):
        validate_app_processes_config(self)

    def check_and_translate_hosts(self, environment):
        self.celery_processes = check_and_translate_hosts(
            environment, self.celery_processes)
        self.pillows = check_and_translate_hosts(environment, self.pillows)
        _validate_all_required_machines_mentioned(environment, self)

    def get_celery_heartbeat_thresholds(self):
        celery_queues = set()
        for host, celery_options in self.celery_processes.items():
            if host == 'None':
                continue
            for process_group in celery_options.keys():
                celery_queues.update(process_group.split(','))

        return {
            p.name: p.blockage_threshold
            for p in CELERY_PROCESSES if p.is_queue and p.name in celery_queues
        }

    def to_generated_variables(self):
        flower_host, = [
            machine
            for machine, queues_config in self.celery_processes.items()
            if 'flower' in queues_config
        ]
        return {
            'CELERY_FLOWER_URL':
            "http://{flower_host}:5555".format(flower_host=flower_host),
            'app_processes_config':
            self.to_json(),
            'celery_queues':
            CELERY_PROCESS_NAMES,
            'CELERY_HEARTBEAT_THRESHOLDS':
            self.get_celery_heartbeat_thresholds()
        }
class ExtraSchedulingOptions(jsonobject.JsonObject):
    active = jsonobject.BooleanProperty()
    include_descendant_locations = jsonobject.BooleanProperty()
    default_language_code = jsonobject.StringProperty()
    custom_metadata = jsonobject.DictProperty(six.text_type)
    use_utc_as_default_timezone = jsonobject.BooleanProperty()
    user_data_filter = jsonobject.DictProperty(jsonobject.ListProperty(six.text_type))
    stop_date_case_property_name = jsonobject.StringProperty()
Пример #6
0
class ProxyConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False

    SITE_HOST = jsonobject.StringProperty(required=True)
    NO_WWW_SITE_HOST = jsonobject.StringProperty()
    J2ME_SITE_HOST = jsonobject.StringProperty()
    nginx_combined_cert_value = jsonobject.StringProperty()
    nginx_key_value = jsonobject.StringProperty()
    nginx_hsts_max_age = jsonobject.IntegerProperty()
    nginx_max_worker_connection = jsonobject.IntegerProperty(default=512)
    nginx_worker_rlimit_nofile = jsonobject.IntegerProperty()
    nginx_ssl_protocols = jsonobject.StringProperty(exclude_if_none=True)
    nginx_ssl_ciphers = jsonobject.StringProperty(exclude_if_none=True)
    fake_ssl_cert = jsonobject.BooleanProperty(default=False)
    letsencrypt_cchq_ssl = jsonobject.BooleanProperty(default=False)
    letsencrypt_cas_ssl = jsonobject.BooleanProperty(default=False)
    primary_ssl_env = jsonobject.StringProperty()
    trusted_proxies = jsonobject.ListProperty(str)

    special_sites = jsonobject.ListProperty(str)

    extra_sites = jsonobject.ListProperty(str)

    nginx_block_ips = jsonobject.ListProperty(str)

    CAS_SITE_HOST = jsonobject.StringProperty(exclude_if_none=True)
    cas_nginx_combined_cert_value = jsonobject.StringProperty(
        exclude_if_none=True)
    cas_key_value = jsonobject.StringProperty(exclude_if_none=True)

    REACH_SITE_HOST = jsonobject.StringProperty(exclude_if_none=True)
    reach_errors_home = jsonobject.StringProperty(exclude_if_none=True)
    reach_commcare_errors_branch = jsonobject.StringProperty(
        exclude_if_none=True)

    TABLEAU_HOST = jsonobject.StringProperty(exclude_if_none=True)
    tableau_nginx_combined_cert_value = jsonobject.StringProperty(
        exclude_if_none=True)
    tableau_key_value = jsonobject.StringProperty(exclude_if_none=True)
    tableau_server = jsonobject.StringProperty(exclude_if_none=True)

    PNA_SITE_HOST = jsonobject.StringProperty(exclude_if_none=True)
    pna_nginx_combined_cert_value = jsonobject.StringProperty(
        exclude_if_none=True)
    pna_key_value = jsonobject.StringProperty(exclude_if_none=True)

    def check(self):
        pass

    def to_generated_variables(self):
        variables = self.to_json()
        if self.nginx_worker_rlimit_nofile is None:
            variables['nginx_worker_rlimit_nofile'] = "{{ nofile_limit }}"
        return variables

    @classmethod
    def get_claimed_variables(cls):
        return set(cls._properties_by_key.keys())
Пример #7
0
class DotsApiParam(StrictJsonObject):
    """99DOTS <-> eNikshay API Parameter Definition

    This class defines api parameters for the patient details API between
    99DOTS and eNikshay.

    For incoming api requests from 99DOTS, it defines where and how to save
    parameters.

    For outgoing api requests to 99DOTS, it defines which properties to watch
    for changes to and how they are compiled.

    """

    # the parameter name for the json sent and received
    api_param_name = jsonobject.StringProperty(required=True)

    # whether this parameter is required when receiving and API request
    required_ = jsonobject.BooleanProperty(default=False, name='required')
    exclude_if_none = jsonobject.BooleanProperty(default=True)
    choices = jsonobject.ObjectProperty(DotsApiParamChoices)

    # the case type to save or get this property from
    case_type = jsonobject.ObjectProperty(DotsApiSectorParam)
    # the case property to save to or get
    case_property = jsonobject.ObjectProperty(DotsApiSectorParam)

    # path to a function to get the value of this property
    getter = jsonobject.StringProperty()

    # path to a jsonObject that will wrap the value from the getter
    payload_object = jsonobject.StringProperty()

    # if using a custom getter, the case properties to watch for changes to send outwards
    case_properties = jsonobject.ObjectProperty(DotsApiParamChoices)

    # path to a function to set the case property for incoming requests. Should
    # return a dict of case properties to update
    setter = jsonobject.StringProperty()

    # whether we should send, receive, or both.
    direction = jsonobject.IntegerProperty(
        default=DIRECTION_BOTH,
        choices=[DIRECTION_INBOUND, DIRECTION_OUTBOUND, DIRECTION_BOTH])

    # path to a function that takes a sector parameter and returns a validator function
    # see checkbox_validator in this file for an example
    validator = jsonobject.StringProperty()
    # values passed into the validator function
    validator_values = jsonobject.ObjectProperty(DotsApiParamChoices)

    def get_by_sector(self, prop, sector):
        prop = getattr(self, prop)
        if isinstance(prop, DotsApiSectorParam):
            return getattr(prop, sector) or prop.both
        else:
            return prop
Пример #8
0
class MetaConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    deploy_env = jsonobject.StringProperty(required=True)
    always_deploy_formplayer = jsonobject.BooleanProperty(default=False)
    env_monitoring_id = jsonobject.StringProperty(required=True)
    users = jsonobject.ListProperty(unicode, required=True)
    slack_alerts_channel = jsonobject.StringProperty()
    bare_non_cchq_environment = jsonobject.BooleanProperty(default=False)
    git_repositories = jsonobject.ListProperty(GitRepository)
    deploy_keys = jsonobject.DictProperty(unicode)
Пример #9
0
class EfsFileSystem(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    create = jsonobject.BooleanProperty(default=True)
    transition_to_ia = jsonobject.StringProperty(required=True)
    efs_name = jsonobject.StringProperty(required=True)
    create_access = jsonobject.BooleanProperty(default=True)
    create_mount = jsonobject.BooleanProperty(default=True)
    create_record = jsonobject.BooleanProperty(default=True)
    domain_name = jsonobject.StringProperty(required=True)
    record_type = jsonobject.StringProperty(default="CNAME")
    route_names = jsonobject.StringProperty(required=True)
Пример #10
0
class FabSettingsConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    sudo_user = jsonobject.StringProperty()
    default_branch = jsonobject.StringProperty()
    home = jsonobject.StringProperty()
    project = jsonobject.StringProperty()
    code_repo = GitUriProperty()
    timing_log = jsonobject.StringProperty()
    keepalive = jsonobject.IntegerProperty()
    ignore_kafka_checkpoint_warning = jsonobject.BooleanProperty()
    acceptable_maintenance_window = jsonobject.ObjectProperty(
        lambda: AcceptableMaintenanceWindow)
    email_enabled = jsonobject.BooleanProperty()
Пример #11
0
class DBOptions(jsonobject.JsonObject):
    _allow_dynamic_properties = False

    name = jsonobject.StringProperty(required=True)
    host = jsonobject.StringProperty()
    port = jsonobject.IntegerProperty(default=6432)
    user = jsonobject.StringProperty()
    password = jsonobject.StringProperty()
    options = jsonobject.DictProperty(unicode)
    django_alias = jsonobject.StringProperty()
    django_migrate = jsonobject.BooleanProperty(default=True)
    query_stats = jsonobject.BooleanProperty(default=False)
    create = jsonobject.BooleanProperty(default=True)
Пример #12
0
class SecretSpec(jsonobject.JsonObject):
    name = jsonobject.StringProperty(required=True)
    required = jsonobject.BooleanProperty(default=False)
    default = jsonobject.DefaultProperty(default=None)
    default_overrides_falsy_values = jsonobject.BooleanProperty(default=False)
    fall_back_to_vars = jsonobject.ListProperty(str)
    deprecated = jsonobject.BooleanProperty(default=False)
    legacy_namespace = jsonobject.StringProperty(
        choices=('localsettings_private', 'secrets', None))
    ansible_var_lowercase = jsonobject.BooleanProperty(default=False)

    @classmethod
    def wrap(cls, data):
        self = super(SecretSpec, cls).wrap(data)
        if self.required:
            assert self.default is None, "A required secret cannot also have a default."
        return self

    def get_legacy_reference(self):
        if self.legacy_namespace:
            return "{}.{}".format(self.legacy_namespace, self.name)
        else:
            return self.name

    def get_ansible_var_name(self):
        if self.ansible_var_lowercase:
            return self.name.lower()
        else:
            return self.name

    def get_ansible_expression(self, expression_base_function,
                               other_secret_specs_by_name):
        expression = expression_base_function(self)
        for var_name in self.fall_back_to_vars:
            expression += ' | default({})'.format(
                other_secret_specs_by_name[var_name].get_ansible_var_name())
        if not self.required:
            if self.default_overrides_falsy_values:
                expression += ' | default({}, true)'.format(
                    repr(self.default).strip('u'))
            else:
                expression += ' | default({})'.format(
                    repr(self.default).strip('u'))
        if expression == self.name:
            # avoid redundant/cyclical `x: {{ x }}`
            return None
        else:
            return "{{{{ {} }}}}".format(expression)
Пример #13
0
class CeleryOptions(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    concurrency = jsonobject.IntegerProperty(default=1)
    pooling = jsonobject.StringProperty(choices=['gevent', 'prefork'], default='prefork')
    max_tasks_per_child = jsonobject.IntegerProperty(default=None)
    num_workers = jsonobject.IntegerProperty(default=1)
    optimize = jsonobject.BooleanProperty(default=False)
Пример #14
0
class PrometheusConfig(jsonobject.JsonObject):
    prometheus_monitoring_enabled = jsonobject.BooleanProperty(required=True)
    grafana_security = jsonobject.DictProperty()

    def to_generated_variables(self):
        variables = self.to_json()
        return variables
Пример #15
0
class AppProcessesConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    environment = jsonobject.StringProperty()
    django_bind = IpAddressProperty()
    django_port = PortProperty()
    flower_port = PortProperty()
    gunicorn_workers_factor = jsonobject.IntegerProperty()
    gunicorn_workers_static_factor = jsonobject.IntegerProperty()
    jython_memory = MemorySpecProperty()
    formplayer_memory = MemorySpecProperty()
    http_proxy = IpAddressAndPortProperty()
    newrelic_javaagent = jsonobject.BooleanProperty()
    additional_no_proxy_hosts = CommaSeparatedStrings()

    service_blacklist = jsonobject.ListProperty(unicode)
    celery_processes = jsonobject.DictProperty(
        jsonobject.DictProperty(CeleryOptions))
    pillows = jsonobject.DictProperty(jsonobject.DictProperty())

    def check(self):
        validate_app_processes_config(self)

    def check_and_translate_hosts(self, environment):
        self.celery_processes = check_and_translate_hosts(
            environment, self.celery_processes)
        self.pillows = check_and_translate_hosts(environment, self.pillows)
Пример #16
0
class PillowOptions(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    start_process = jsonobject.IntegerProperty(default=0)
    num_processes = jsonobject.IntegerProperty(default=1)
    dedicated_migration_process = jsonobject.BooleanProperty(default=False)
    total_processes = jsonobject.IntegerProperty(default=None, exclude_if_none=True)
    processor_chunk_size = jsonobject.IntegerProperty(default=None, exclude_if_none=True)
Пример #17
0
class ElasticacheConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    create = jsonobject.BooleanProperty(default=True)
    node_type = jsonobject.StringProperty()
    num_cache_nodes = jsonobject.IntegerProperty(default=1)
    engine_version = jsonobject.StringProperty(default="4.0.10")
    parameter_group_name = jsonobject.StringProperty(default="default.redis4.0")
Пример #18
0
class MetaConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    deploy_env = jsonobject.StringProperty(required=True)
    env_monitoring_id = jsonobject.StringProperty(required=True)
    users = jsonobject.ListProperty(unicode, required=True)
    slack_alerts_channel = jsonobject.StringProperty()
    bare_non_cchq_environment = jsonobject.BooleanProperty(default=False)
Пример #19
0
class GitRepository(jsonobject.JsonObject):
    url = jsonobject.StringProperty(required=True)
    dest = jsonobject.StringProperty(
        required=True)  # relative to the code_source/external directory
    version = jsonobject.StringProperty(default="master")
    requirements_path = jsonobject.StringProperty()
    deploy_key = jsonobject.StringProperty(
    )  # name of the deploy key file to use
    is_private = jsonobject.BooleanProperty(default=False)

    @property
    def relative_dest(self):
        return "extensions/" + self.dest

    @memoized_property
    def repo(self):
        match = re.match(r"[email protected]:(.*?).git", self.url)
        if not match:
            raise EnvironmentException(
                "Unable to parse repository URL: {}".format(self.url))
        repo = match.group(1)
        return get_github(self).get_repo(repo)

    @memoized_property
    def deploy_ref(self):
        return self.repo.get_commit(self.version).sha

    def to_generated_variables(self):
        vars = self.to_json()
        vars["dest"] = self.relative_dest
        return vars
Пример #20
0
class ServerConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    server_name = jsonobject.StringProperty()
    server_instance_type = jsonobject.StringProperty()
    network_tier = jsonobject.StringProperty(
        choices=['app-private', 'public', 'db-private'])
    az = jsonobject.StringProperty()
    volume_size = jsonobject.IntegerProperty(default=20)
    volume_encrypted = jsonobject.BooleanProperty(default=True, required=True)
    block_device = jsonobject.ObjectProperty(lambda: BlockDevice, default=None)
    group = jsonobject.StringProperty()
    os = jsonobject.StringProperty(
        required=True, choices=['trusty', 'bionic', 'ubuntu_pro_bionic'])
    count = jsonobject.IntegerProperty(default=None)

    @classmethod
    def wrap(cls, data):
        self = super(cls, ServerConfig).wrap(data)
        if self.count is not None and not self.server_name.split(
                '-', 1)[0].endswith('{i}'):
            raise ValueError(
                'To use count, server_name must be a template string using {i}, '
                'and {i} must be the final part before the env suffix')
        return self

    def get_all_server_names(self):
        if self.count is None:
            # e.g. server0-test => ["server0-test"]
            return [self.server_name]
        else:
            # e.g. server_a{i}-test => ["server_a000-test", "server_a001-test", ...]
            return [
                self.server_name.format(i='{:03d}'.format(i))
                for i in range(self.count)
            ]

    def get_all_host_names(self):
        host_name = self.server_name.split('-', 1)[0]
        if self.count is None:
            # e.g. server0-test => ["server0"]
            return [host_name]
        else:
            # e.g. server_a{i}-test => ["server_a000", "server_a001", ...]
            return [
                host_name.format(i='{:03d}'.format(i))
                for i in range(self.count)
            ]

    def get_host_group_name(self):
        if self.count is None:
            raise ValueError(
                "Can only call get_host_group_name() on a server with count")
        else:
            # e.g. server_a{i}-test => ["server_a"]
            return self.server_name.split('-', 1)[0][:-3]

    def to_generated_json(self):
        obj = self.to_json()
        obj['get_all_server_names'] = self.get_all_server_names()
        return obj
Пример #21
0
class ChangelogEntry(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    # filename is the only property that is populated from outside the yaml file
    filename = jsonobject.StringProperty()

    title = jsonobject.StringProperty()

    key = jsonobject.StringProperty()

    # Date when this change was added (purely for informational purposes)
    date = jsonobject.DateProperty()

    optional_per_env = jsonobject.BooleanProperty()

    # Min version of HQ that MUST be deployed before this change can be rolled out
    min_commcare_version = GitVersionProperty()

    # Max version of HQ that can be deployed before this change MUST be rolled out
    max_commcare_version = GitVersionProperty()

    # Description of the change
    # This will be shown as a sort of "preview" in the index
    context = MarkdownProperty()

    # Details of the change
    details = MarkdownProperty()

    # Steps to update
    update_steps = MarkdownProperty()
Пример #22
0
class TerraformConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    aws_profile = jsonobject.StringProperty(required=True)
    account_alias = jsonobject.StringProperty()
    manage_users = jsonobject.BooleanProperty(default=True)
    state_bucket = jsonobject.StringProperty()
    state_bucket_region = jsonobject.StringProperty()
    region = jsonobject.StringProperty()
    environment = jsonobject.StringProperty()
    openvpn_image = jsonobject.StringProperty()
    azs = jsonobject.ListProperty(str)
    az_codes = jsonobject.ListProperty(str, default=['a', 'b', 'c'])
    vpc_begin_range = jsonobject.StringProperty()
    vpn_connections = jsonobject.ListProperty(lambda: VpnConnectionConfig)
    external_routes = jsonobject.ListProperty(lambda: ExternalRouteConfig)
    servers = jsonobject.ListProperty(lambda: ServerConfig)
    proxy_servers = jsonobject.ListProperty(lambda: ServerConfig)
    rds_instances = jsonobject.ListProperty(lambda: RdsInstanceConfig)
    elasticache = jsonobject.ObjectProperty(lambda: ElasticacheConfig,
                                            default=None)

    @classmethod
    def wrap(cls, data):
        if 'aws_profile' not in data:
            data['aws_profile'] = data.get('account_alias')
        return super(TerraformConfig, cls).wrap(data)
Пример #23
0
class DBOptions(jsonobject.JsonObject):
    _allow_dynamic_properties = False

    name = jsonobject.StringProperty(required=True)
    host = jsonobject.StringProperty()
    pgbouncer_host = jsonobject.StringProperty(default=None)
    port = jsonobject.IntegerProperty(default=None)
    user = jsonobject.StringProperty()
    password = jsonobject.StringProperty()
    options = jsonobject.DictProperty(unicode)
    django_alias = jsonobject.StringProperty()
    django_migrate = jsonobject.BooleanProperty(default=True)
    query_stats = jsonobject.BooleanProperty(default=False)
    create = jsonobject.BooleanProperty(default=True)

    # config values to be set at the database level
    pg_config = jsonobject.ListProperty(lambda: PGConfigItem)
Пример #24
0
class ElasticacheClusterConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    create = jsonobject.BooleanProperty(default=True)
    cache_node_type = jsonobject.StringProperty(default="cache.t3.micro")
    cache_engine = jsonobject.StringProperty(default="redis")
    cache_engine_version = jsonobject.StringProperty(default="4.0.10")
    cache_prameter_group = jsonobject.StringProperty(
        default="default.redis4.0")
    automatic_failover = jsonobject.BooleanProperty(default=True)
    transit_encryption = jsonobject.BooleanProperty(default=False)
    at_rest_encryption = jsonobject.BooleanProperty(default=True)
    auto_minor_version = jsonobject.BooleanProperty(default=False)
    cluster_size = jsonobject.IntegerProperty(default=1)
    maintenance_window = jsonobject.StringProperty(
        default="sun:03:30-sun:04:30")
    snapshot_retention = jsonobject.IntegerProperty(default=5)
    snapshot_window = jsonobject.StringProperty(default="07:30-08:30")
Пример #25
0
class RichValidatorOutputProblem(jsonobject.JsonObject):
    type = jsonobject.StringProperty(choices=[
        "error", "markup", "invalid-structure", "dangerous", "technical"
    ])
    message = jsonobject.StringProperty()
    xml_location = jsonobject.StringProperty()
    fatal = jsonobject.BooleanProperty()
    model_location = jsonobject.StringProperty()
Пример #26
0
class MetaConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    deploy_env = jsonobject.StringProperty(required=True)
    always_deploy_formplayer = jsonobject.BooleanProperty(default=False)
    env_monitoring_id = jsonobject.StringProperty(required=True)
    users = jsonobject.ListProperty(six.text_type, required=True)
    slack_alerts_channel = jsonobject.StringProperty()
    bare_non_cchq_environment = jsonobject.BooleanProperty(default=False)
    git_repositories = jsonobject.ListProperty(GitRepository)
    deploy_keys = jsonobject.DictProperty(six.text_type)
    secrets_backend = jsonobject.StringProperty(
        choices=list(all_secrets_backends_by_name),
        default='ansible-vault',
    )

    def get_secrets_backend_class(self):
        # guaranteed to succeed because of the validation above on secrets_backend
        return all_secrets_backends_by_name[self.secrets_backend]
Пример #27
0
class AppProcessesConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    django_bind = IpAddressProperty()
    django_port = PortProperty()
    flower_port = PortProperty()
    gunicorn_workers_factor = jsonobject.IntegerProperty()
    gunicorn_workers_static_factor = jsonobject.IntegerProperty()
    jython_memory = MemorySpecProperty()
    formplayer_memory = MemorySpecProperty()
    http_proxy = IpAddressAndPortProperty()
    newrelic_djangoagent = jsonobject.BooleanProperty()
    newrelic_javaagent = jsonobject.BooleanProperty()
    django_command_prefix = jsonobject.StringProperty()
    datadog_pythonagent = jsonobject.BooleanProperty()
    additional_no_proxy_hosts = CommaSeparatedStrings()

    service_blacklist = jsonobject.ListProperty(unicode)
    celery_processes = jsonobject.DictProperty(
        jsonobject.DictProperty(CeleryOptions))
    pillows = jsonobject.DictProperty(jsonobject.DictProperty())

    def check(self):
        validate_app_processes_config(self)

    def check_and_translate_hosts(self, environment):
        self.celery_processes = check_and_translate_hosts(
            environment, self.celery_processes)
        self.pillows = check_and_translate_hosts(environment, self.pillows)
        _validate_all_required_machines_mentioned(environment, self)

    def to_generated_variables(self):
        flower_host, = [
            machine
            for machine, queues_config in self.celery_processes.items()
            if 'flower' in queues_config
        ]
        return {
            'CELERY_FLOWER_URL':
            "http://{flower_host}:5555".format(flower_host=flower_host),
            'app_processes_config':
            self.to_json(),
        }
Пример #28
0
class OpenmrsConceptJSON(jsonobject.JsonObject):
    """
    Intermediate model used for validation
    """
    uuid = jsonobject.StringProperty()
    display = jsonobject.StringProperty()
    concept_class = jsonobject.StringProperty()
    retired = jsonobject.BooleanProperty()
    datatype = jsonobject.StringProperty()
    answers = jsonobject.ListProperty(unicode)
    descriptions = jsonobject.ListProperty(unicode)
    names = jsonobject.ListProperty(lambda: OpenmrsConceptName)
Пример #29
0
class RdsInstanceConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    identifier = jsonobject.StringProperty(required=True)
    instance_type = jsonobject.StringProperty(
        required=True)  # should start with 'db.'
    storage = jsonobject.IntegerProperty()
    create = jsonobject.BooleanProperty(default=True)
    username = "******"
    backup_window = "06:27-06:57"
    backup_retention = 30
    maintenance_window = "sat:08:27-sat:08:57"
    port = 5432
    parameter_group_name = "default.postgres9.6"
Пример #30
0
class FabSettingsConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    sudo_user = jsonobject.StringProperty()
    default_branch = jsonobject.StringProperty()
    home = jsonobject.StringProperty()
    project = jsonobject.StringProperty()
    code_repo = GitUriProperty()
    timing_log = jsonobject.StringProperty()
    keepalive = jsonobject.IntegerProperty()
    ignore_kafka_checkpoint_warning = jsonobject.BooleanProperty()
    acceptable_maintenance_window = jsonobject.ObjectProperty(
        lambda: AcceptableMaintenanceWindow)
    email_enabled = jsonobject.BooleanProperty()
    tag_deploy_commits = jsonobject.BooleanProperty(default=False)
    use_shared_dir_for_staticfiles = jsonobject.BooleanProperty(default=False)
    shared_dir_for_staticfiles = jsonobject.StringProperty(default=None)
    deploy_event_url = jsonobject.StringProperty(default=None)
    generate_deploy_diffs = jsonobject.BooleanProperty(default=True)
    custom_deploy_details = jsonobject.DictProperty()

    @classmethod
    def wrap(cls, data):
        for deprecated_property in ('py3_include_venv', 'py3_run_deploy'):
            if deprecated_property in data:
                print("{} {} {}".format(
                    color_notice("The property"),
                    color_code(deprecated_property),
                    color_notice("is deprecated and has no effect.")))
                print(
                    color_notice(
                        "Feel free to remove it from your fab-settings.yml."))
                del data[deprecated_property]

        obj = super(FabSettingsConfig, cls).wrap(data)
        if obj.use_shared_dir_for_staticfiles:
            assert obj.shared_dir_for_staticfiles, \
                "Cannot have use_shared_dir_for_staticfiles without shared_dir_for_staticfiles"
        return obj