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


Python client.client函数代码示例

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


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


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