Example #1
0
 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)
Example #2
0
 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"
Example #3
0
 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"
Example #4
0
    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)
Example #6
0
 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)
Example #7
0
 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)
Example #8
0
 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)
Example #9
0
 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)
Example #10
0
 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)