コード例 #1
0
    def get_magnum_client(token=None, endpoint=None, previous_tries=0):
        if previous_tries > 3:
            return None

        # first try to use auth details from auth_ref so we
        # don't need to auth with keystone every time
        auth_ref = get_auth_ref()
        auth_details = get_auth_details()
        keystone = get_keystone_client(auth_ref)

        if not token:
            token = keystone.auth_token
        if not endpoint:
            endpoint = get_endpoint_url_for_service(
                'container-infra', auth_ref, get_endpoint_type(auth_details))

        magnum = magnum_client.Client('1',
                                      endpoint_override=endpoint,
                                      auth_token=token,
                                      insecure=auth_details['OS_API_INSECURE'])
        try:
            magnum.cluster_templates.list()
        except h_exc.HTTPUnauthorized:
            auth_ref = force_reauth()
            keystone = get_keystone_client(auth_ref)

            token = keystone.auth_token
            magnum = get_magnum_client(token, endpoint, previous_tries + 1)
        except magnum_exc.HttpError:
            raise
        except Exception as e:
            metric_bool('client_success', False, m_name='maas_magnum')
            status_err(str(e), m_name='maas_magnum')

        return magnum
コード例 #2
0
ファイル: __init__.py プロジェクト: ISCAS-VDI/murano-base
 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)
コード例 #3
0
    def create_client(self, version=None, service_type=None):
        """Return magnum client."""
        from magnumclient import client as magnum

        api_url = self._get_endpoint(service_type)
        session = self._get_session(endpoint=api_url)
        endpoint_type = self.credential.endpoint_type,

        return magnum.Client(session=session, interface=endpoint_type[0])
コード例 #4
0
ファイル: discovery.py プロジェクト: NeCTAR-RC/nectar-metrics
 def __init__(self, conf):
     super(MagnumClusterDiscovery, self).__init__(conf)
     creds = conf.service_credentials
     self.client = client.Client(
         version='1',
         session=keystone_client.get_session(conf),
         region_name=creds.region_name,
         interface=creds.interface,
     )
コード例 #5
0
 def test_valid_version_argument(self, mock_magnum_client):
     client.Client(version='1', magnum_url='http://myurl/')
     mock_magnum_client.assert_called_with(magnum_url='http://myurl/')
コード例 #6
0
 def test_no_version_argument(self, mock_magnum_client):
     client.Client(auth_token='mytoken', magnum_url='http://myurl/')
     mock_magnum_client.assert_called_with(auth_token='mytoken',
                                           magnum_url='http://myurl/')
コード例 #7
0
 def __init__(self, options):
     self.magnum = magnumclient.Client('1',
                                       session=keystone_session_v3(options))