def _create_magnum_client(region): session = auth_utils.get_token_client_session(conf=CONF) params = auth_utils.get_session_client_parameters( service_type='container', region=region, conf=CONF, session=session) return client.Client(**params)
def get_network_driver(context): session = auth_utils.get_token_client_session( context.auth_token, context.tenant) try: session.get_endpoint(service_type='network') except ks_exceptions.EndpointNotFound: LOG.debug("Will use NovaNetwork as a network driver") return "nova" else: LOG.debug("Will use Neutron as a network driver") return "neutron"
def test_get_token_client_session(self, mock_cfg, mock_get_execution_session, mock_identity, mock_get_session): mock_cfg.CONF.__getitem__.return_value.auth_uri = 'foo_auth_uri/v2.0' mock_get_execution_session.return_value = \ mock.Mock(token=mock.sentinel.token, project_id=mock.sentinel.project_id) mock_identity.Token.return_value = mock.sentinel.auth mock_get_session.return_value = mock.sentinel.session session = auth_utils.get_token_client_session(conf=mock.sentinel.conf) self.assertEqual(mock.sentinel.session, session) mock_get_execution_session.assert_called_once_with() mock_identity.Token.assert_called_once_with( 'foo_auth_uri/v3', token=mock.sentinel.token, project_id=mock.sentinel.project_id) mock_get_session.assert_called_once_with( auth=mock.sentinel.auth, conf_section=mock.sentinel.conf)
def test_get_token_client_session(self, mock_get_execution_session, mock_identity, mock_get_session): cfg.CONF.set_override('auth_uri', 'foo_auth_uri/v2.0', auth_utils.CFG_MURANO_AUTH_GROUP) mock_get_execution_session.return_value = \ mock.Mock(token=mock.sentinel.token, project_id=mock.sentinel.project_id) mock_identity.Token.return_value = mock.sentinel.auth mock_get_session.return_value = mock.sentinel.session session = auth_utils.get_token_client_session() self.assertEqual(mock.sentinel.session, session) mock_get_execution_session.assert_called_once_with() mock_identity.Token.assert_called_once_with( 'foo_auth_uri/v3', token=mock.sentinel.token, project_id=mock.sentinel.project_id) mock_get_session.assert_called_once_with(auth=mock.sentinel.auth, conf_section=None)
def _get_token_client(self): ks_session = auth_utils.get_token_client_session(conf=CONF.heat) region = None if self._owner is None else self._owner['region'] return self._create_client(ks_session, region)
def _create_magnum_client(region): session = auth_utils.get_token_client_session(conf=CONF) params = auth_utils.get_session_client_parameters( service_type='container', region=region, conf=CONF, session=session) return magnumclient.client.Client(**params)
def _get_token_client(self): ks_session = auth_utils.get_token_client_session(conf=CONF.heat) return self._create_client(ks_session, self._region_name)
def _get_token_client(cls): ks_session = auth_utils.get_token_client_session(conf=CONF.heat) return cls._create_client(ks_session, CONF.home_region)