Maybe, here some codes are worth thouhands of words:
keystone.catalog.backends.sql.Catalog:  
def get_catalog(self, user_id, tenant_id, metadata=None):
        d = dict(CONF.iteritems())
        d.update({'tenant_id': tenant_id,
                  'user_id': user_id})
        catalog = {}

        endpoints = [self.get_endpoint(e)
                     for e in self.list_endpoints()]
        for ep in endpoints:
            service = self.get_service(ep['service_id'])
            srv_type = service['type']
            srv_name = service['name']
            region = ep['region']

            if region not in catalog:
                catalog[region] = {}

            catalog[region][srv_type] = {}

            internal_url = ep['internalurl'].replace('$(', '%(')
            public_url = ep['publicurl'].replace('$(', '%(')
            admin_url = ep['adminurl'].replace('$(', '%(')
            catalog[region][srv_type]['name'] = srv_name
            catalog[region][srv_type]['publicURL'] = public_url % d
            catalog[region][srv_type]['adminURL'] = admin_url % d
            catalog[region][srv_type]['internalURL'] = internal_url % d

        return catalog



-----openstack-bounces+gongysh=cn.ibm....@lists.launchpad.net wrote: -----

To: Anne Gentle <a...@openstack.org>
From: Pete Zaitcev <zait...@redhat.com>
Sent by: openstack-bounces+gongysh=cn.ibm....@lists.launchpad.net
Date: 04/13/2012 06:44AM
Cc: Openstack Mail List <openstack@lists.launchpad.net>
Subject: Re: [Openstack] Endpoints problems

On Thu, 12 Apr 2012 15:28:21 -0500
Anne Gentle <a...@openstack.org> wrote:

> keystone --token 012345SECRET99TOKEN012345 --endpoint
> http://192.168.206.130:35357/v2.0 endpoint-create \
>[....]
>                        --internalurl
> http://192.168.206.130:8774/v2/$(tenant_id)s
>
> I haven't fixed this yet because I'm not sure if the $(tenant_id)s is
> literal or which tenant_id specifically to use (the Service tenant for the
> adminurl possibly)?

The _expression_ "$(tenant_id)s" is really contained inside the pattern
in the database. It is substituded with a specific tennant ID when
an application makes its request. The weird syntax is inherited from
Python, where one can use constructs like %s or %(key)s.

-- Pete

_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to     : openstack@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp



_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to     : openstack@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp

Reply via email to