当前位置: 首页>>代码示例>>Python>>正文


Python context.WSGIWorkerConfigContext方法代码示例

本文整理汇总了Python中charmhelpers.contrib.openstack.context.WSGIWorkerConfigContext方法的典型用法代码示例。如果您正苦于以下问题:Python context.WSGIWorkerConfigContext方法的具体用法?Python context.WSGIWorkerConfigContext怎么用?Python context.WSGIWorkerConfigContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在charmhelpers.contrib.openstack.context的用法示例。


在下文中一共展示了context.WSGIWorkerConfigContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resource_map

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import WSGIWorkerConfigContext [as 别名]
def resource_map():
    """Dynamically generate a map of resources that will be managed for a
    single hook execution.
    """
    resource_map = deepcopy(BASE_RESOURCE_MAP)

    if CompareOpenStackReleases(os_release('keystone')) < 'liberty':
        resource_map.pop(POLICY_JSON)
    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    if run_in_apache():
        for cfile in resource_map:
            svcs = resource_map[cfile]['services']
            if 'keystone' in svcs:
                svcs.remove('keystone')
                if 'apache2' not in svcs:
                    svcs.append('apache2')
        admin_script = os.path.join(git_determine_usr_bin(),
                                    "keystone-wsgi-admin")
        public_script = os.path.join(git_determine_usr_bin(),
                                     "keystone-wsgi-public")
        resource_map[WSGI_KEYSTONE_API_CONF] = {
            'contexts': [
                context.WSGIWorkerConfigContext(name="keystone",
                                                admin_script=admin_script,
                                                public_script=public_script),
                keystone_context.KeystoneContext()],
            'services': ['apache2']
        }
    return resource_map 
开发者ID:konono,项目名称:equlipse,代码行数:35,代码来源:keystone_utils.py

示例2: wsgi_worker_context

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import WSGIWorkerConfigContext [as 别名]
def wsgi_worker_context(self):
        """Return a WSGIWorkerConfigContext dictionary.

        This is used to configure a WSGI worker.  The charm_instance class can
        define some attributes (or properties - anything getattr(...) will work
        against for:

            wsgi_script: a script/name to pass to the WSGIW... constructor
            wsgi_admin_script: a script/name to pass to the WSGIW...
                constructor
            wsgi_public_script: a script/name to pass to the WSGIW...
                constructor
            wsgi_process_weight: an float between 0.0 and 1.0 to split the
                share of all workers between main, admin and public workers.
            wsgi_admin_process_weight: an float between 0.0 and 1.0 to split
                the share of all workers between main, admin and public workers
            wsgi_public_process_weight: an float between 0.0 and 1.0 to split
                the share of all workers between main, admin and public workers

            The sum of the process weights should equal 1 to make sense.

        :returns: WSGIWorkerConfigContext dictionary.
        """
        charm_instance = self.charm_instance or {}
        kwargs = dict(
            name=getattr(charm_instance, 'name', None),
            script=getattr(charm_instance, 'wsgi_script', None),
            admin_script=getattr(charm_instance, 'wsgi_admin_script', None),
            public_script=getattr(charm_instance, 'wsgi_public_script', None),
            process_weight=getattr(
                charm_instance, 'wsgi_process_weight', None),
            admin_process_weight=getattr(
                charm_instance, 'wsgi_admin_process_weight', None),
            public_process_weight=getattr(
                charm_instance, 'wsgi_public_process_weight', None),
        )
        # filtering the kwargs of Nones allows the default arguments on
        # WSGIWorkerConfigContext.__init__(...) to be used.
        filtered_kwargs = dict((k, v) for k, v in kwargs.items()
                               if v is not None)
        return ch_context.WSGIWorkerConfigContext(**filtered_kwargs)() 
开发者ID:openstack,项目名称:charms.openstack,代码行数:43,代码来源:adapters.py

示例3: test_wsgi_worker_config_context

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import WSGIWorkerConfigContext [as 别名]
def test_wsgi_worker_config_context(self, usr_bin, python_path,
                                        _calculate_workers):
        self.config.return_value = 2  # worker-multiplier=2
        usr_bin_path = '/usr/bin'
        usr_bin.return_value = usr_bin_path
        python_path.return_value = None
        _calculate_workers.return_value = 8
        service_name = 'service-name'
        script = '/usr/bin/script'
        ctxt = context.WSGIWorkerConfigContext(name=service_name,
                                               script=script)
        expect = {
            "service_name": service_name,
            "user": service_name,
            "group": service_name,
            "script": script,
            "admin_script": None,
            "public_script": None,
            "processes": 8,
            "admin_processes": 2,
            "public_processes": 6,
            "threads": 1,
            "usr_bin": usr_bin_path,
            "python_path": None,
        }
        self.assertEqual(expect, ctxt()) 
开发者ID:juju,项目名称:charm-helpers,代码行数:28,代码来源:test_os_contexts.py


注:本文中的charmhelpers.contrib.openstack.context.WSGIWorkerConfigContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。