Hi Guys:

My openstack version is Mitaka.  I want to use curl to call openstack API , but 
I met a issue. Can you help me ?

[root@ospp9-ctrl1 site-packages(keystone_demo)]# source ~/keystonerc_admin

[root@ospp9-ctrl1 site-packages(keystone_admin)]# curl -s -X POST 
$OS_AUTH_URL/tokens   -H "Content-Type: application/json" -d '{"auth": 
{"tenantName": "", "passwordCredentials": {"username": "'"$OS_USERNAME"'", 
"password": "'"$OS_PASSWORD"'"}}}'  | python -m json.tool
{
    "access": {
        "metadata": {
            "is_admin": 0,
            "roles": []
        },
        "serviceCatalog": [],
        "token": {
            "audit_ids": [
                "RJrDyNfIShyKTmXu5IWZUw"
            ],
            "expires": "2016-12-10T13:12:15Z",
            "id": "80b3d146c5614c149ccf983b21d93055",
            "issued_at": "2016-12-10T12:12:15.171884Z"
        },
        "user": {
            "id": "ae11a07ef07e47bba4a91d1c3516ac01",
            "name": "admin",
            "roles": [],
            "roles_links": [],
            "username": "admin"
        }
    }
}
[root@ospp9-ctrl1 site-packages(keystone_admin)]# export 
OS_TOKEN=80b3d146c5614c149ccf983b21d93055
[root@ospp9-ctrl1 site-packages(keystone_admin)]# export 
OS_PROJECT_ID=e5ec75ca491049b2b3d6758269aad07c
[root@ospp9-ctrl1 site-packages(keystone_admin)]# curl -s -H 
"X-Auth-Token:$OS_TOKEN" 
http://192.168.122.64:8774/v2/e5ec75ca491049b2b3d6758269aad07c/flavors  | 
python -m json.tool
{
    "badRequest": {
        "code": 400,
        "message": "Malformed request URL: URL's project_id 
'e5ec75ca491049b2b3d6758269aad07c' doesn't match Context's project_id 'None'"
    }
}

[root@ospp9-ctrl1 site-packages(keystone_admin)]# openstack catalog show nova
+-----------+-------------------------------------------------------------------------------+
| Field     | Value                                                             
            |
+-----------+-------------------------------------------------------------------------------+
| endpoints | RegionOne                                                         
            |
|           |   publicURL: 
http://192.168.122.64:8774/v2/e5ec75ca491049b2b3d6758269aad07c   |
|           |   internalURL: 
http://192.168.122.64:8774/v2/e5ec75ca491049b2b3d6758269aad07c |
|           |   adminURL: 
http://192.168.122.64:8774/v2/e5ec75ca491049b2b3d6758269aad07c    |
|           |                                                                   
            |
| name      | nova                                                              
            |
| type      | compute                                                           
            |
+-----------+-------------------------------------------------------------------------------+

1. After I deep into the code, and have a question : How to get/set the 
context.project_id?


[root@ospp9-ctrl1 site-packages(keystone_admin)]# vim 
nova/api/openstack/wsgi.py +721
```python
       project_id = action_args.pop("project_id", None)
        context = request.environ.get('nova.context')
        if (context and project_id and (project_id != context.project_id)):
            msg = _("Malformed request URL: URL's project_id '%(project_id)s'"
                    " doesn't match Context's project_id"
                    " '%(context_project_id)s'") % \
                    {'project_id': project_id,
                     'context_project_id': context.project_id}
            return Fault(webob.exc.HTTPBadRequest(explanation=msg))
```

2. Why  got empty SeviceCatalog    "serviceCatalog": []" but  it is not in 
official docs

http://developer.openstack.org/api-guide/quick-start/api-quick-start.html#openstack-api-quick-guide


--
----------------------------------------------------
Margin Hu
Love Open Source Software.
Mobile: (86) 186-8035-6499
email : jhu_...@outlook.com<mailto:jhu_...@outlook.com>
github: http://github.com/todaygood
 ---------------------------------------------------
_______________________________________________
Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to     : openstack@lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack

Reply via email to