Exemple #1
0
    def _get_glare_client(self):
        glare_settings = CONF.glare
        session = auth_utils.get_client_session(self._execution_session)
        token = session.auth.get_token(session)
        if self._last_glare_token != token:
            self._last_glare_token = token
            self._glare_client = None

        if self._glare_client is None:
            url = glare_settings.url
            if not url:
                url = session.get_endpoint(
                    service_type='artifact',
                    interface=glare_settings.endpoint_type,
                    region_name=CONF.home_region)

            self._glare_client = glare_client.Client(
                endpoint=url,
                token=token,
                insecure=glare_settings.insecure,
                key_file=glare_settings.key_file or None,
                ca_file=glare_settings.ca_file or None,
                cert_file=glare_settings.cert_file or None,
                type_name='murano',
                type_version=1)
        return self._glare_client
Exemple #2
0
    def _create_client(region):
        if not mistralcli:
            LOG.warning(_LW("Mistral client is not available"))
            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 mistralcli.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)
    def _get_glare_client(self):
        glare_settings = CONF.glare
        session = auth_utils.get_client_session(self._execution_session)
        token = session.auth.get_token(session)
        if self._last_glare_token != token:
            self._last_glare_token = token
            self._glare_client = None

        if self._glare_client is None:
            url = glare_settings.url
            if not url:
                url = session.get_endpoint(
                    service_type='artifact',
                    interface=glare_settings.endpoint_type,
                    region_name=CONF.home_region)

            self._glare_client = glare_client.Client(
                endpoint=url, token=token,
                insecure=glare_settings.insecure,
                key_file=glare_settings.key_file or None,
                ca_file=glare_settings.ca_file or None,
                cert_file=glare_settings.cert_file or None,
                type_name='murano',
                type_version=1)
        return self._glare_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
        )
Exemple #5
0
    def _create_client(region):
        if not mistralcli:
            LOG.warning("Mistral client is not available")
            raise ImportError("Import mistralcliet 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)

        # TODO(gyurco): use auth_utils.get_session_client_parameters
        return mistralcli.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.cafile
        )
    def test_get_client_session_without_trust_id(
            self, mock_get_execution_session, mock_get_token_client_session):
        mock_get_token_client_session.return_value = mock.sentinel.session
        mock_exec_session = mock.Mock(trust_id=None,
                                      token=mock.sentinel.token,
                                      project_id=mock.sentinel.project_id)

        session = auth_utils.get_client_session(
            execution_session=mock_exec_session, conf=mock.sentinel.conf)

        self.assertEqual(mock.sentinel.session, session)
        self.assertFalse(mock_get_execution_session.called)
        mock_get_token_client_session.assert_called_once_with(
            token=mock.sentinel.token, project_id=mock.sentinel.project_id)
    def test_get_client_session(self, mock_get_execution_session,
                                mock_get_keystone_auth, mock_get_session):
        mock_exec_session = mock.Mock(trust_id=mock.sentinel.trust_id)
        mock_get_execution_session.return_value = mock_exec_session
        mock_get_keystone_auth.return_value = mock.sentinel.auth
        mock_get_session.return_value = mock.sentinel.session

        session = auth_utils.get_client_session(conf=mock.sentinel.conf)

        self.assertEqual(mock.sentinel.session, session)
        mock_get_execution_session.assert_called_once_with()
        mock_get_keystone_auth.assert_called_once_with(mock.sentinel.trust_id)
        mock_get_session.assert_called_once_with(
            auth=mock.sentinel.auth, conf_section=mock.sentinel.conf)
Exemple #8
0
 def _get_client(region_name):
     session = auth_utils.get_client_session(conf=CONF.heat)
     return HeatStack._create_client(session, region_name)
Exemple #9
0
 def _get_client(region_name):
     session = auth_utils.get_client_session(conf=CONF.heat)
     return HeatStack._create_client(session, region_name)