Custom Search

Monday, November 18, 2013

How to keystone API update user details

0)
Set Host

#OPSENSTACK_HOST="192.168.56.101"

1)
#### Get token ####

#export TOKEN=`curl -si -d @keystone_auth_admin_cred.json -H "Content-type: application/json" http://$OPSENSTACK_HOST:35357/v3/auth/tokens | awk '/X-Subject-Token/ {print $2}'`

#### keystone_auth_admin_cred.json ####
{
            "auth": {
                "identity": {
                    "methods": [
                "password"
                    ],
                    "password": {
                        "user": {
                            "domain": {
                                "name": "Default"
                            },
                            "name": "admin",
                            "password": "password"
                        }
                    }
                },
                "scope": {
                    "project": {
                        "domain": {
                            "name": "Default"
                        },
                        "name": "demo"
                    }
                }
            }
        }



2)
#### Check token ####

#echo $TOKEN

3)
#### List all users ####

##Port 35357
#curl -si -H "X-Auth-Token:$TOKEN" -H "Content-type: application/json" http://$OPSENSTACK_HOST:35357/v3/users

4)
Update user details (change email and set enabled flag to true)

#curl -si -X "PATCH" -H "X-Auth-Token:$TOKEN" -H "Content-type: application/json" http://$OPSENSTACK_HOST:35357/v3/users/ec11454782cd4703b618e106d18326fe -d @keystone_update_user_cred.json

######### keystone_update_user_cred.json #########

{
    "user": {
                "email":"cc@cc.com",
                "enabled":true
            }

}

5)
Ref
https://github.com/openstack/identity-api/blob/master/openstack-identity-api/v3/src/markdown/identity-api-v3.md


No comments:

Post a Comment