當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。