コード例 #1
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)
    pgbouncer_pool_size = jsonobject.IntegerProperty(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)
コード例 #2
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
コード例 #3
0
class CeleryOptions(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    concurrency = jsonobject.IntegerProperty()
    pooling = jsonobject.StringProperty(choices=['gevent', 'prefork'],
                                        default='prefork')
    max_tasks_per_child = jsonobject.IntegerProperty()
    server_whitelist = IpAddressProperty()
コード例 #4
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)
コード例 #5
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)
コード例 #6
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)
コード例 #7
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)
コード例 #8
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()
        }
コード例 #9
0
class VpnConnectionConfig(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    name = jsonobject.StringProperty()
    cidr_blocks = jsonobject.ListProperty(str)
    type = jsonobject.StringProperty()
    ip_address = jsonobject.StringProperty()
    bgp_asn = jsonobject.IntegerProperty()
    amazon_side_asn = jsonobject.IntegerProperty()
コード例 #10
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())
コード例 #11
0
class SimpleSMSDailyScheduleWithTime(jsonobject.JsonObject):
    schedule_type = SIMPLE_SMS_DAILY_SCHEDULE_WITH_TIME
    time = jsonobject.TimeProperty()
    message = jsonobject.DictProperty(six.text_type)
    total_iterations = jsonobject.IntegerProperty()
    start_offset = jsonobject.IntegerProperty()
    start_day_of_week = jsonobject.IntegerProperty()
    extra_options = jsonobject.ObjectProperty(ExtraSchedulingOptions)
    repeat_every = jsonobject.IntegerProperty()
コード例 #12
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
コード例 #13
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")
コード例 #14
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")
コード例 #15
0
class SampleSchema(jsonobject.JsonObject):
    stringfield = jsonobject.StringProperty()
    intfield = jsonobject.IntegerProperty()
    dictfield = jsonobject.DictProperty()
    arrayfield = jsonobject.ListProperty()
    documentarrayfield = jsonobject.ListProperty(item_type=SubSchema)
    documentfield = jsonobject.DictProperty(item_type=SubSchema)
    datefield = jsonobject.DateProperty()
    datetimefield = jsonobject.DateTimeProperty()
コード例 #16
0
ファイル: terraform.py プロジェクト: mmthiam/commcare-cloud
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)
    block_device = jsonobject.ObjectProperty(lambda: BlockDevice, default=None)
コード例 #17
0
class InternalAlbs(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    name = jsonobject.StringProperty(required=True)
    identifier = jsonobject.StringProperty(required=False)
    targets = jsonobject.ListProperty(str)
    target_port = jsonobject.IntegerProperty(required=True)
    listener_port = jsonobject.IntegerProperty(required=True)

    @classmethod
    def wrap(cls, data):
        self = super(InternalAlbs, cls).wrap(data)
        if not self.identifier:
            self.identifier = self.name.replace('_', '-')
        if not re.match('[a-z]+-alb-[a-z]+', self.identifier):
            raise ValueError(
                "commcare-cloud requires internal alb identifier to be of the form 'internal{name}-alb-{environment}'"
            )
        return self
コード例 #18
0
ファイル: api_spec.py プロジェクト: mekete/commcare-hq
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
コード例 #19
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)
    conn_max_age = jsonobject.IntegerProperty(default=None)
    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)
コード例 #20
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(),
        }
コード例 #21
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)
    block_device = jsonobject.ObjectProperty(lambda: BlockDevice, default=None)
    group = jsonobject.StringProperty()
    # todo: invert this so that all new machines are bionic unless otherwise specified
    os = jsonobject.StringProperty(required=True)
コード例 #22
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()
コード例 #23
0
ファイル: terraform.py プロジェクト: mmthiam/commcare-cloud
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"
コード例 #24
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)
コード例 #25
0
ファイル: terraform.py プロジェクト: demis-svenska/covid2019
class BlockDevice(jsonobject.JsonObject):
    _allow_dynamic_properties = False
    volume_type = jsonobject.StringProperty(default='gp2',
                                            choices=['gp2', 'io1', 'standard'])
    volume_size = jsonobject.IntegerProperty(required=True)
    encrypted = jsonobject.BooleanProperty(default=False, required=True)

    @classmethod
    def wrap(cls, data):
        if 'encrypted' in data:
            puts(
                color_warning(
                    'Warning! The "encrypted" option on block_device is experimental '
                    'and not well-integrated into provisioning scripts.'))
        return super(BlockDevice, cls).wrap(data)
コード例 #26
0
ファイル: mod_version.py プロジェクト: allista/PyKSPutils
class ModVersion(WithId):
    created = jo.DateTimeProperty(required=True)
    download_path = jo.StringProperty(required=True)
    friendly_version = jo.StringProperty(required=True)
    game_version = jo.StringProperty(required=True)
    changelog = jo.StringProperty()
    downloads = jo.IntegerProperty()

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._version = SimpleVersion.from_str(self.friendly_version)
        if self._version is None:
            raise SpacedockError(
                f"Unable to parse mod version: {self.friendly_version}")

    @property
    def version(self) -> SimpleVersion:
        return self._version

    @property
    def download_url(self) -> str:
        return f"{SPACEDOCK_URL}{self.download_path}"
コード例 #27
0
class ShardDetails(jsonobject.JsonObject):
    node = jsonobject.StringProperty()
    db_name = jsonobject.StringProperty()

    # shards/c0000000-dfffffff/commcarehq.1541009837
    shard_name = jsonobject.StringProperty()
    engine = jsonobject.StringProperty()
    doc_count = jsonobject.IntegerProperty()
    doc_del_count = jsonobject.IntegerProperty()
    purge_seq = jsonobject.IntegerProperty()
    compact_running = jsonobject.BooleanProperty()
    sizes = jsonobject.DictProperty()
    disk_size = jsonobject.IntegerProperty()
    data_size = jsonobject.IntegerProperty()
    other = jsonobject.DictProperty()
    instance_start_time = jsonobject.StringProperty()
    disk_format_version = jsonobject.IntegerProperty()
    committed_update_seq = jsonobject.IntegerProperty()
    compacted_seq = jsonobject.IntegerProperty()
    uuid = jsonobject.StringProperty()

    @property
    def shard_name_short(self):
        return self.shard_name.split('/')[1]
コード例 #28
0
ファイル: util.py プロジェクト: adixsyukri/morp
def jsl_field_to_jsonobject_property(
        prop: jsl.BaseField) -> jsonobject.JsonProperty:
    if isinstance(prop, jsl.DateTimeField):
        return jsonobject.DateTimeProperty(name=prop.name,
                                           required=prop.required)
    if isinstance(prop, jsl.StringField):
        return jsonobject.StringProperty(name=prop.name,
                                         required=prop.required)
    if isinstance(prop, jsl.IntField):
        return jsonobject.IntegerProperty(name=prop.name,
                                          required=prop.required)
    if isinstance(prop, jsl.DictField):
        return jsonobject.DictProperty(name=prop.name, required=prop.required)
    if isinstance(prop, jsl.NumberField):
        return jsonobject.FloatProperty(name=prop.name, required=prop.required)
    if isinstance(prop, jsl.BooleanField):
        return jsonobject.BooleanProperty(name=prop.name,
                                          required=prop.required)
    if isinstance(prop, jsl.DocumentField):
        if prop.document_cls:
            subtype = jsl_to_jsonobject(prop.document_cls)
            return jsonobject.DictProperty(name=prop.name,
                                           item_type=subtype,
                                           required=prop.required)
        return jsonobject.DictProperty(name=prop.name, required=prop.required)
    if isinstance(prop, jsl.ArrayField):
        if prop.items:
            if isinstance(prop.items, jsl.DocumentField):
                subtype = jsl_to_jsonobject(prop.items.document_cls)
            elif isinstance(prop.items, jsl.BaseField):
                subtype = jsl_field_to_jsonobject_property(prop.items)
            else:
                raise KeyError(prop.items)
            return jsonobject.ListProperty(item_type=subtype,
                                           required=prop.required)
        return jsonobject.ListProperty(name=prop.name, required=prop.required)

    raise KeyError(prop)
コード例 #29
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
コード例 #30
0
class StandbyDBOptions(PartitionDBOptions):
    name = jsonobject.StringProperty()
    master = jsonobject.StringProperty(required=True)
    acceptable_replication_delay = jsonobject.IntegerProperty(default=None)
    create = False
    django_migrate = False