• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python client.client函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mistralclient.api.client.client函数的典型用法代码示例。如果您正苦于以下问题:Python client函数的具体用法?Python client怎么用?Python client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_mistral_url_https_insecure

    def test_mistral_url_https_insecure(self, mock, keystone_client_mock):
        keystone_client_instance = keystone_client_mock.return_value
        keystone_client_instance.auth_token = str(uuid.uuid4())
        keystone_client_instance.project_id = str(uuid.uuid4())
        keystone_client_instance.user_id = str(uuid.uuid4())

        expected_args = (
            MISTRAL_HTTPS_URL,
            keystone_client_instance.auth_token,
            keystone_client_instance.project_id,
            keystone_client_instance.user_id
        )

        expected_kwargs = {
            'cacert': None,
            'insecure': True
        }

        client.client(
            mistral_url=MISTRAL_HTTPS_URL,
            username='mistral',
            project_name='mistral',
            auth_url=AUTH_HTTP_URL,
            cacert=None,
            insecure=True
        )

        self.assertTrue(mock.called)
        self.assertEqual(mock.call_args[0], expected_args)
        self.assertDictEqual(mock.call_args[1], expected_kwargs)
开发者ID:icclab,项目名称:python-mistralclient,代码行数:30,代码来源:test_client.py


示例2: test_mistral_url_https_bad_insecure

    def test_mistral_url_https_bad_insecure(self, session_mock,
                                            log_warning_mock):
        fd, path = tempfile.mkstemp(suffix='.pem')

        keystone_client_instance = self.setup_keystone_mock(
            session_mock
        )

        try:
            client.client(
                mistral_url=MISTRAL_HTTPS_URL,
                user_id=keystone_client_instance.user_id,
                project_id=keystone_client_instance.project_id,
                api_key='password',
                user_domain_name='Default',
                project_domain_name='Default',
                auth_url=AUTH_HTTP_URL_v3,
                cacert=path,
                insecure=True
            )
        finally:
            os.close(fd)
            os.unlink(path)

        self.assertTrue(log_warning_mock.called)
开发者ID:openstack,项目名称:python-mistralclient,代码行数:25,代码来源:test_client.py


示例3: test_mistral_profile_enabled

    def test_mistral_profile_enabled(self, mock, keystone_client_mock):
        keystone_client_instance = keystone_client_mock.return_value
        keystone_client_instance.auth_token = str(uuid.uuid4())
        keystone_client_instance.project_id = str(uuid.uuid4())
        keystone_client_instance.user_id = str(uuid.uuid4())

        expected_args = (
            MISTRAL_HTTP_URL,
            keystone_client_instance.auth_token,
            keystone_client_instance.project_id,
            keystone_client_instance.user_id
        )

        expected_kwargs = {
            'cacert': None,
            'insecure': False
        }

        client.client(
            username='mistral',
            project_name='mistral',
            auth_url=AUTH_HTTP_URL,
            profile=PROFILER_HMAC_KEY
        )

        self.assertTrue(mock.called)
        self.assertEqual(mock.call_args[0], expected_args)
        self.assertDictEqual(mock.call_args[1], expected_kwargs)

        profiler = osprofiler.profiler.get()

        self.assertEqual(profiler.hmac_key, PROFILER_HMAC_KEY)
开发者ID:icclab,项目名称:python-mistralclient,代码行数:32,代码来源:test_client.py


示例4: test_mistral_url_https_secure

    def test_mistral_url_https_secure(self, http_client_mock, session_mock):
        fd, cert_path = tempfile.mkstemp(suffix='.pem')

        keystone_client_instance = self.setup_keystone_mock(  # noqa
            session_mock
        )

        expected_args = (
            MISTRAL_HTTPS_URL,
        )

        try:
            client.client(
                mistral_url=MISTRAL_HTTPS_URL,
                username='mistral',
                project_name='mistral',
                api_key='password',
                user_domain_name='Default',
                project_domain_name='Default',
                auth_url=AUTH_HTTP_URL_v3,
                cacert=cert_path,
                insecure=False
            )
        finally:
            os.close(fd)
            os.unlink(cert_path)

        self.assertTrue(http_client_mock.called)
        self.assertEqual(http_client_mock.call_args[0], expected_args)
        self.assertEqual(http_client_mock.call_args[1]['cacert'], cert_path)
开发者ID:openstack,项目名称:python-mistralclient,代码行数:30,代码来源:test_client.py


示例5: test_mistral_url_defult

 def test_mistral_url_defult(self, mock, keystone_client_mock):
     client.client(username='mistral',
                   project_name='misteal',
                   auth_url="http://localhost:35357/v3")
     self.assertTrue(mock.called)
     params = mock.call_args
     self.assertEqual('http://localhost:8989/v2',
                      params[0][0])
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:8,代码来源:test_client.py


示例6: test_mistral_no_auth

    def test_mistral_no_auth(self, get_auth_handler_mock):
        # Test that we don't authenticate if auth url wasn't provided

        client.client(
            username='mistral',
            project_name='mistral',
            api_key='password',
            service_type='workflowv2'
        )

        self.assertEqual(0, get_auth_handler_mock.call_count)
开发者ID:openstack,项目名称:python-mistralclient,代码行数:11,代码来源:test_client.py


示例7: initialize_app

    def initialize_app(self, argv):
        self._clear_shell_commands()

        ver = client.determine_client_version(self.options.mistral_version)

        self._set_shell_commands(self._get_commands(ver))

        do_help = ('help' in argv) or ('-h' in argv) or not argv

        # Set default for auth_url if not supplied. The default is not
        # set at the parser to support use cases where auth is not enabled.
        # An example use case would be a developer's environment.
        if not self.options.auth_url:
            if self.options.password or self.options.token:
                self.options.auth_url = 'http://localhost:35357/v3'

        # bash-completion should not require authentification.
        if do_help or ('bash-completion' in argv):
            self.options.auth_url = None

        self.client = client.client(mistral_url=self.options.mistral_url,
                                    username=self.options.username,
                                    api_key=self.options.password,
                                    project_name=self.options.tenant_name,
                                    auth_url=self.options.auth_url,
                                    project_id=self.options.tenant_id,
                                    endpoint_type=self.options.endpoint_type,
                                    service_type=self.options.service_type,
                                    auth_token=self.options.token,
                                    cacert=self.options.cacert)
开发者ID:aneeshkp,项目名称:python-mistralclient,代码行数:30,代码来源:shell.py


示例8: run

    def run(self, action_parameters):
        client = mistral.client(mistral_url='%s/v2' % self.url)

        # Update workbook definition.
        workbook_name = self.action.pack + '.' + self.action.name
        with open(self.entry_point, 'r') as wbkfile:
            definition = wbkfile.read()
            try:
                wbk = client.workbooks.get(workbook_name)
                if wbk.definition != definition:
                    client.workbooks.update(definition)
            except:
                client.workbooks.create(definition)

        # Setup context for the workflow execution.
        context = self.runner_parameters.get('context', dict())
        context.update(action_parameters)
        endpoint = 'http://%s:%s/actionexecutions' % (cfg.CONF.api.host, cfg.CONF.api.port)
        params = {'st2_api_url': endpoint,
                  'st2_parent': self.action_execution_id}

        # Execute the workflow.
        execution = client.executions.create(self.runner_parameters.get('workflow'),
                                             workflow_input=context, **params)

        # Return status and output.
        output = {
            'id': str(execution.id),
            'state': str(execution.state)
        }

        self.container_service.report_status(ACTIONEXEC_STATUS_RUNNING)
        self.container_service.report_result(output)

        return (str(execution.state) == 'RUNNING')
开发者ID:bjoernbessert,项目名称:st2,代码行数:35,代码来源:v2.py


示例9: _create_client

    def _create_client(region):
        if not mistralclient:
            raise mistral_import_error

        mistral_settings = CONF.mistral

        endpoint_type = mistral_settings.endpoint_type
        service_type = mistral_settings.service_type
        session = auth_utils.get_client_session()

        mistral_url = mistral_settings.url or session.get_endpoint(
            service_type=service_type,
            endpoint_type=endpoint_type,
            region_name=region)
        auth_ref = session.auth.get_access(session)

        return mistralclient.client(
            mistral_url=mistral_url,
            project_id=auth_ref.project_id,
            endpoint_type=endpoint_type,
            service_type=service_type,
            auth_token=auth_ref.auth_token,
            user_id=auth_ref.user_id,
            insecure=mistral_settings.insecure,
            cacert=mistral_settings.ca_cert
        )
开发者ID:olivierlemasle,项目名称:murano,代码行数:26,代码来源:mistralclient.py


示例10: _get_workflow_client

    def _get_workflow_client(self):
        ctx = context.ctx()
        mistral_endpoint = keystone_utils.get_endpoint_for_project('mistral')

        mc = mistral_client.client(auth_token=ctx.auth_token,
                                   mistral_url=mistral_endpoint.url)

        return mc
开发者ID:rbrady,项目名称:tripleo-common,代码行数:8,代码来源:base.py


示例11: get_workflow_client

    def get_workflow_client(self, context):
        mistral_endpoint = keystone_utils.get_endpoint_for_project(
            context, 'mistral')

        mc = mistral_client.client(auth_token=context.auth_token,
                                   mistral_url=mistral_endpoint.url)

        return mc
开发者ID:infraredgirl,项目名称:tripleo-common,代码行数:8,代码来源:base.py


示例12: __init__

 def __init__(self):
     super(MistralWorkflowValidator, self).__init__()
     self._client = mistral.client(
         mistral_url=self.url,
         username=cfg.CONF.mistral.keystone_username,
         api_key=cfg.CONF.mistral.keystone_password,
         project_name=cfg.CONF.mistral.keystone_project_name,
         auth_url=cfg.CONF.mistral.keystone_auth_url)
开发者ID:automotola,项目名称:st2,代码行数:8,代码来源:v2.py


示例13: _create

    def _create(self):
        endpoint_type = self._get_client_option("mistral", "endpoint_type")
        endpoint = self.url_for(service_type=self.WORKFLOW_V2, endpoint_type=endpoint_type)

        args = {"mistral_url": endpoint, "auth_token": self.auth_token}

        client = mistral_client.client(**args)
        return client
开发者ID:yizhongyin,项目名称:OpenstackLiberty,代码行数:8,代码来源:mistral.py


示例14: get_workflow_client

    def get_workflow_client(self, context):
        security_ctx = context.security
        mistral_endpoint = keystone_utils.get_endpoint_for_project(
            security_ctx, 'mistral')

        mc = mistral_client.client(auth_token=security_ctx.auth_token,
                                   mistral_url=mistral_endpoint.url)

        return mc
开发者ID:openstack,项目名称:tripleo-common,代码行数:9,代码来源:base.py


示例15: create_client

    def create_client(self, service_type=None):
        """Return Mistral client."""
        from mistralclient.api import client as mistral

        client = mistral.client(
            mistral_url=self._get_endpoint(service_type),
            service_type=self.choose_service_type(service_type),
            auth_token=self.keystone.auth_ref.auth_token)
        return client
开发者ID:andreykurilin,项目名称:rally,代码行数:9,代码来源:osclients.py


示例16: __init__

 def __init__(self, id, *args, **kwargs):
     super(MistralResultsQuerier, self).__init__(*args, **kwargs)
     self._base_url = get_url_without_trailing_slash(cfg.CONF.mistral.v2_base_url)
     self._client = mistral.client(
         mistral_url=self._base_url,
         username=cfg.CONF.mistral.keystone_username,
         api_key=cfg.CONF.mistral.keystone_password,
         project_name=cfg.CONF.mistral.keystone_project_name,
         auth_url=cfg.CONF.mistral.keystone_auth_url)
开发者ID:jspittman,项目名称:st2,代码行数:9,代码来源:v2.py


示例17: test_mistral_url_default

    def test_mistral_url_default(self, http_client_mock, session_mock):
        session = mock.Mock()
        session_mock.side_effect = [session]

        get_endpoint = mock.Mock(side_effect=Exception)
        session.get_endpoint = get_endpoint

        client.client(
            username='mistral',
            project_name='mistral',
            api_key='password',
            user_domain_name='Default',
            project_domain_name='Default',
            auth_url=AUTH_HTTP_URL_v3
        )

        self.assertTrue(http_client_mock.called)
        mistral_url_for_http = http_client_mock.call_args[0][0]
        self.assertEqual(MISTRAL_HTTP_URL, mistral_url_for_http)
开发者ID:openstack,项目名称:python-mistralclient,代码行数:19,代码来源:test_client.py


示例18: __init__

 def __init__(self, runner_id):
     super(MistralRunner, self).__init__(runner_id=runner_id)
     self._on_behalf_user = cfg.CONF.system_user.user
     self._notify = None
     self._skip_notify_tasks = []
     self._client = mistral.client(
         mistral_url=self.url,
         username=cfg.CONF.mistral.keystone_username,
         api_key=cfg.CONF.mistral.keystone_password,
         project_name=cfg.CONF.mistral.keystone_project_name,
         auth_url=cfg.CONF.mistral.keystone_auth_url)
开发者ID:azamsheriff,项目名称:st2,代码行数:11,代码来源:v2.py


示例19: _create

    def _create(self):
        endpoint_type = self._get_client_option(CLIENT_NAME, 'endpoint_type')
        endpoint = self.url_for(service_type=self.WORKFLOW_V2,
                                endpoint_type=endpoint_type)
        args = {
            'mistral_url': endpoint,
            'auth_token': self.context.keystone_session.get_token()
        }

        client = mistral_client.client(**args)
        return client
开发者ID:Hopebaytech,项目名称:heat,代码行数:11,代码来源:mistral.py


示例20: test_mistral_profile_enabled

    def test_mistral_profile_enabled(self, http_client_mock, session_mock):
        keystone_client_instance = self.setup_keystone_mock(  # noqa
            session_mock
        )

        client.client(
            username='mistral',
            project_name='mistral',
            api_key='password',
            user_domain_name='Default',
            project_domain_name='Default',
            auth_url=AUTH_HTTP_URL_v3,
            profile=PROFILER_HMAC_KEY
        )

        self.assertTrue(http_client_mock.called)

        profiler = osprofiler.profiler.get()

        self.assertEqual(profiler.hmac_key, PROFILER_HMAC_KEY)
开发者ID:openstack,项目名称:python-mistralclient,代码行数:20,代码来源:test_client.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mistrequests.MistRequests类代码示例发布时间:2022-05-27
下一篇:
Python states.is_completed函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap