Example #1
0
    def _get_client(self):
        ctx = context.ctx()

        LOG.debug("Cinder action security context: %s" % ctx)

        cinder_endpoint = keystone_utils.get_endpoint_for_project(
            service_type='volumev2'
        )

        cinder_url = keystone_utils.format_url(
            cinder_endpoint.url,
            {
                'tenant_id': ctx.project_id,
                'project_id': ctx.project_id
            }
        )

        client = self._client_class(
            ctx.user_name,
            ctx.auth_token,
            project_id=ctx.project_id,
            auth_url=cinder_url,
            region_name=cinder_endpoint.region
        )

        client.client.auth_token = ctx.auth_token
        client.client.management_url = cinder_url

        return client
Example #2
0
    def test_format_url_percent_sign(self):
        url_template = "http://host:port/v1/%(id)s"

        expected = "http://host:port/v1/my_id"

        self.assertEqual(expected,
                         keystone.format_url(url_template, self.values))
Example #3
0
    def _create_client(self):
        ctx = context.ctx()

        LOG.debug("Nova action security context: %s" % ctx)

        keystone_endpoint = keystone_utils.get_keystone_endpoint_v2()
        nova_endpoint = keystone_utils.get_endpoint_for_project('nova')

        client = novaclient.Client(
            2,
            username=None,
            api_key=None,
            endpoint_type=CONF.os_actions_endpoint_type,
            service_type='compute',
            auth_token=ctx.auth_token,
            tenant_id=ctx.project_id,
            region_name=keystone_endpoint.region,
            auth_url=keystone_endpoint.url
        )

        client.client.management_url = keystone_utils.format_url(
            nova_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        return client
Example #4
0
    def _create_client(self):
        ctx = context.ctx()

        LOG.debug("Trove action security context: %s" % ctx)

        trove_endpoint = keystone_utils.get_endpoint_for_project(
            service_type='database'
        )

        trove_url = keystone_utils.format_url(
            trove_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        client = self._get_client_class()(
            ctx.user_name,
            ctx.auth_token,
            project_id=ctx.project_id,
            auth_url=trove_url,
            region_name=trove_endpoint.region
        )

        client.client.auth_token = ctx.auth_token
        client.client.management_url = trove_url

        return client
Example #5
0
    def _get_client(self):
        ctx = context.ctx()

        LOG.debug("Cinder action security context: %s" % ctx)

        cinder_endpoint = keystone_utils.get_endpoint_for_project(
            service_type='volume'
        )

        cinder_url = keystone_utils.format_url(
            cinder_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        client = self._client_class(
            ctx.user_name,
            ctx.auth_token,
            project_id=ctx.project_id,
            auth_url=cinder_url,
            region_name=cinder_endpoint.region
        )

        client.client.auth_token = ctx.auth_token
        client.client.management_url = cinder_url

        return client
Example #6
0
    def _create_client(self):
        ctx = context.ctx()

        LOG.debug("Designate action security context: %s" % ctx)

        designate_endpoint = keystone_utils.get_endpoint_for_project(
            service_type='dns'
        )

        designate_url = keystone_utils.format_url(
            designate_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        client = self._get_client_class()(
            endpoint=designate_url,
            tenant_id=ctx.project_id,
            auth_url=ctx.auth_uri,
            region_name=designate_endpoint.region,
            service_type='dns'
        )

        client.client.auth_token = ctx.auth_token
        client.client.management_url = designate_url

        return client
Example #7
0
    def _get_client(self):
        ctx = context.ctx()

        LOG.debug("Designate action security context: %s" % ctx)

        designate_endpoint = keystone_utils.get_endpoint_for_project(
            service_type='dns'
        )

        designate_url = keystone_utils.format_url(
            designate_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        client = self._get_client_class()(
            endpoint=designate_url,
            tenant_id=ctx.project_id,
            auth_url=ctx.auth_uri,
            region_name=designate_endpoint.region,
            service_type='dns'
        )

        client.client.auth_token = ctx.auth_token
        client.client.management_url = designate_url

        return client
Example #8
0
    def _get_client(self):
        ctx = context.ctx()

        LOG.debug("Trove action security context: %s" % ctx)

        trove_endpoint = keystone_utils.get_endpoint_for_project(
            service_type='database'
        )

        trove_url = keystone_utils.format_url(
            trove_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        client = self._get_client_class()(
            ctx.user_name,
            ctx.auth_token,
            project_id=ctx.project_id,
            auth_url=trove_url,
            region_name=trove_endpoint.region
        )

        client.client.auth_token = ctx.auth_token
        client.client.management_url = trove_url

        return client
Example #9
0
    def _get_client(self):
        ctx = context.ctx()

        LOG.debug("Nova action security context: %s" % ctx)

        keystone_endpoint = keystone_utils.get_keystone_endpoint_v2()
        nova_endpoint = keystone_utils.get_endpoint_for_project('nova')

        client = self._client_class(
            username=None,
            api_key=None,
            endpoint_type='publicURL',
            service_type='compute',
            auth_token=ctx.auth_token,
            tenant_id=ctx.project_id,
            region_name=keystone_endpoint.region,
            auth_url=keystone_endpoint.url
        )

        client.client.management_url = keystone_utils.format_url(
            nova_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        return client
    def test_format_url_percent_sign(self):
        url_template = "http://host:port/v1/%(id)s"

        expected = "http://host:port/v1/my_id"

        self.assertEqual(
            expected,
            keystone.format_url(url_template, self.values)
        )
Example #11
0
    def get_orchestration_client(self, context):
        heat_endpoint = keystone_utils.get_endpoint_for_project('heat')

        endpoint_url = keystone_utils.format_url(
            heat_endpoint.url, {'tenant_id': context.project_id})

        return heatclient.Client(endpoint_url,
                                 region_name=heat_endpoint.region,
                                 token=context.auth_token,
                                 username=context.user_name)
Example #12
0
    def _create_client(self, context):

        LOG.debug("Glare action security context: %s", context)

        glare_endpoint = self.get_service_endpoint()

        endpoint_url = keystone_utils.format_url(
            glare_endpoint.url, {'tenant_id': context.project_id})

        return self._get_client_class()(endpoint_url,
                                        **self.get_session_and_auth(context))
Example #13
0
    def _create_client(self, context):

        LOG.debug("Vitrage action security context: %s", context)

        vitrage_endpoint = self.get_service_endpoint()

        endpoint_url = keystone_utils.format_url(
            vitrage_endpoint.url, {'tenant_id': context.project_id})

        session_and_auth = self.get_session_and_auth(context)

        return vitrageclient.Client(session=session_and_auth['session'],
                                    endpoint_override=endpoint_url)
Example #14
0
    def _create_client(self, context):

        LOG.debug("Gnocchi action security context: %s", context)

        gnocchi_endpoint = self.get_service_endpoint()

        endpoint_url = keystone_utils.format_url(
            gnocchi_endpoint.url, {'tenant_id': context.project_id})

        return self._get_client_class()(endpoint_url,
                                        region_name=gnocchi_endpoint.region,
                                        token=context.auth_token,
                                        username=context.user_name)
Example #15
0
    def _create_client(self, context):

        LOG.debug("Swift action security context: %s", context)

        swift_endpoint = self.get_service_endpoint()

        swift_url = keystone_utils.format_url(
            swift_endpoint.url, {'tenant_id': context.project_id})

        session_and_auth = self.get_session_and_auth(context)

        return self._get_client_class()(session=session_and_auth['session'],
                                        preauthurl=swift_url)
Example #16
0
    def _create_client(self):
        ctx = context.ctx()

        LOG.debug("Gnocchi action security context: %s" % ctx)

        gnocchi_endpoint = keystone_utils.get_endpoint_for_project('gnocchi')

        endpoint_url = keystone_utils.format_url(gnocchi_endpoint.url,
                                                 {'tenant_id': ctx.project_id})

        return self._get_client_class()(endpoint_url,
                                        region_name=gnocchi_endpoint.region,
                                        token=ctx.auth_token,
                                        username=ctx.user_name)
Example #17
0
    def _create_client(self, context):

        LOG.debug("Ceilometer action security context: %s" % context)

        ceilometer_endpoint = self.get_service_endpoint()

        endpoint_url = keystone_utils.format_url(
            ceilometer_endpoint.url, {'tenant_id': context.project_id})

        return self._get_client_class()(endpoint_url,
                                        region_name=ceilometer_endpoint.region,
                                        token=context.auth_token,
                                        username=context.user_name,
                                        insecure=context.insecure)
Example #18
0
    def _get_client(self):
        ctx = context.ctx()

        LOG.debug("Heat action security context: %s" % ctx)

        heat_endpoint = keystone_utils.get_endpoint_for_project('heat')

        endpoint_url = keystone_utils.format_url(heat_endpoint.url,
                                                 {'tenant_id': ctx.project_id})

        return self._client_class(endpoint_url,
                                  region_name=heat_endpoint.region,
                                  token=ctx.auth_token,
                                  username=ctx.user_name)
Example #19
0
    def _create_client(self, context):

        LOG.debug("Glare action security context: %s", context)

        glare_endpoint = self.get_service_endpoint()

        endpoint_url = keystone_utils.format_url(
            glare_endpoint.url,
            {'tenant_id': context.project_id}
        )

        return self._get_client_class()(
            endpoint_url,
            **self.get_session_and_auth(context)
        )
Example #20
0
    def _get_orchestration_client(self):
        ctx = context.ctx()
        heat_endpoint = keystone_utils.get_endpoint_for_project('heat')

        endpoint_url = keystone_utils.format_url(
            heat_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        return heatclient.Client(
            endpoint_url,
            region_name=heat_endpoint.region,
            token=ctx.auth_token,
            username=ctx.user_name
        )
Example #21
0
    def _create_client(self, context):

        LOG.debug("Heat action security context: %s" % context)

        heat_endpoint = self.get_service_endpoint()

        endpoint_url = keystone_utils.format_url(
            heat_endpoint.url, {
                'tenant_id': context.project_id,
                'project_id': context.project_id
            })

        return self._get_client_class()(endpoint_url,
                                        region_name=heat_endpoint.region,
                                        **self.get_session_and_auth(context))
Example #22
0
    def _create_client(self):
        ctx = context.ctx()

        LOG.debug("Ceilometer action security context: %s" % ctx)

        ceilometer_endpoint = keystone_utils.get_endpoint_for_project(
            'ceilometer')

        endpoint_url = keystone_utils.format_url(ceilometer_endpoint.url,
                                                 {'tenant_id': ctx.project_id})

        return self._get_client_class()(endpoint_url,
                                        region_name=ceilometer_endpoint.region,
                                        token=ctx.auth_token,
                                        username=ctx.user_name,
                                        insecure=ctx.insecure)
Example #23
0
    def _create_client(self, context):

        LOG.debug("Swift action security context: %s", context)

        swift_endpoint = self.get_service_endpoint()

        swift_url = keystone_utils.format_url(
            swift_endpoint.url,
            {'tenant_id': context.project_id}
        )

        session_and_auth = self.get_session_and_auth(context)

        return self._get_client_class()(
            session=session_and_auth['session'],
            preauthurl=swift_url
        )
Example #24
0
    def _create_client(self, context):

        LOG.debug("Vitrage action security context: %s", context)

        vitrage_endpoint = self.get_service_endpoint()

        endpoint_url = keystone_utils.format_url(
            vitrage_endpoint.url,
            {'tenant_id': context.project_id}
        )

        session_and_auth = self.get_session_and_auth(context)

        return vitrageclient.Client(
            session=session_and_auth['session'],
            endpoint_override=endpoint_url
        )
Example #25
0
    def _create_client(self, context):

        LOG.debug("Gnocchi action security context: %s", context)

        gnocchi_endpoint = self.get_service_endpoint()

        endpoint_url = keystone_utils.format_url(
            gnocchi_endpoint.url,
            {'tenant_id': context.project_id}
        )

        return self._get_client_class()(
            endpoint_url,
            region_name=gnocchi_endpoint.region,
            token=context.auth_token,
            username=context.user_name
        )
Example #26
0
    def get_compute_client(self, context):
        keystone_endpoint = keystone_utils.get_endpoint_for_project('keystone')
        nova_endpoint = keystone_utils.get_endpoint_for_project('nova')

        client = nova_client(2,
                             username=None,
                             api_key=None,
                             service_type='compute',
                             auth_token=context.auth_token,
                             tenant_id=context.project_id,
                             region_name=keystone_endpoint.region,
                             auth_url=keystone_endpoint.url,
                             insecure=context.insecure)

        client.client.management_url = keystone_utils.format_url(
            nova_endpoint.url, {'tenant_id': context.project_id})

        return client
Example #27
0
    def _get_client(self):
        ctx = context.ctx()

        LOG.debug("Heat action security context: %s" % ctx)

        heat_endpoint = keystone_utils.get_endpoint_for_project('heat')

        endpoint_url = keystone_utils.format_url(
            heat_endpoint.url,
            {'tenant_id': ctx.project_id}
        )

        return self._client_class(
            endpoint_url,
            region_name=heat_endpoint.region,
            token=ctx.auth_token,
            username=ctx.user_name
        )
Example #28
0
    def _create_client(self, context):

        LOG.debug("Trove action security context: %s", context)

        trove_endpoint = self.get_service_endpoint()

        trove_url = keystone_utils.format_url(
            trove_endpoint.url, {'tenant_id': context.project_id})

        client = self._get_client_class()(context.user_name,
                                          context.auth_token,
                                          project_id=context.project_id,
                                          auth_url=trove_url,
                                          region_name=trove_endpoint.region,
                                          insecure=context.insecure)

        client.client.auth_token = context.auth_token
        client.client.management_url = trove_url

        return client
Example #29
0
    def _create_client(self, context):

        LOG.debug("Designate action security context: %s", context)

        designate_endpoint = self.get_service_endpoint()

        designate_url = keystone_utils.format_url(
            designate_endpoint.url, {'tenant_id': context.project_id})

        client = self._get_client_class()(
            endpoint=designate_url,
            tenant_id=context.project_id,
            auth_url=context.auth_uri,
            region_name=designate_endpoint.region,
            service_type='dns',
            insecure=context.insecure)

        client.client.auth_token = context.auth_token
        client.client.management_url = designate_url

        return client
Example #30
0
    def _create_client(self, context):

        LOG.debug("Nova action security context: %s" % context)

        keystone_endpoint = keystone_utils.get_keystone_endpoint_v2()
        nova_endpoint = self.get_service_endpoint()

        client = novaclient.Client(
            2,
            username=None,
            api_key=None,
            endpoint_type=CONF.openstack_actions.os_actions_endpoint_type,
            service_type='compute',
            auth_token=context.auth_token,
            tenant_id=context.project_id,
            region_name=nova_endpoint.region,
            auth_url=keystone_endpoint.url,
            insecure=context.insecure)

        client.client.management_url = keystone_utils.format_url(
            nova_endpoint.url, {'tenant_id': context.project_id})

        return client
Example #31
0
    def _create_client(self, context):

        LOG.debug("Trove action security context: %s", context)

        trove_endpoint = self.get_service_endpoint()

        trove_url = keystone_utils.format_url(
            trove_endpoint.url,
            {'tenant_id': context.project_id}
        )

        client = self._get_client_class()(
            context.user_name,
            context.auth_token,
            project_id=context.project_id,
            auth_url=trove_url,
            region_name=trove_endpoint.region,
            insecure=context.insecure
        )

        client.client.auth_token = context.auth_token
        client.client.management_url = trove_url

        return client
Example #32
0
    def _create_client(self, context):

        LOG.debug("Designate action security context: %s", context)

        designate_endpoint = self.get_service_endpoint()

        designate_url = keystone_utils.format_url(
            designate_endpoint.url,
            {'tenant_id': context.project_id}
        )

        client = self._get_client_class()(
            endpoint=designate_url,
            tenant_id=context.project_id,
            auth_url=context.auth_uri,
            region_name=designate_endpoint.region,
            service_type='dns',
            insecure=context.insecure
        )

        client.client.auth_token = context.auth_token
        client.client.management_url = designate_url

        return client