curl -i 'http://193.160.15.13:5000/v2.0/tokens' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "xxxx1234"}}}'
v2token=`curl -i http://controller:35357/v2.0/tokens -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-neutronclient" -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "xxxx1234"}}}'| grep "access" | awk -F ' ' '{print $8}'`
token=`echo $v2token|awk -F, '{print $1}'|sed 's/"//g'`
1.获取token
token=`openstack token issue | awk '/ id / {print $4}'`
token=`openstack token issue | sed ':a;N;$!ba;s/
/ /g' | grep " id.* project_id" | sed 's/.* id(.*) project_id.*/1/g' | sed 's/ //g' | sed 's/|//g'`
2.查询system_tag,需要把下面命令里的“123456”换成要查询的虚拟机ID
curl -i -k -X GET https://compute-ext.localdomain.com:8880/v1.0/system-tags/server/123456/ecs_autorecovery_policy -H "Content-type: application/json" -H "X-Auth-Token:$MYTK"
v3token=`curl -i 'http://193.160.15.13:35357/v3/auth/tokens' -X POST -H 'Content-Type: application/json' -d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"name":"admin","domain":{"id":"default"},"password":"xxxx1234"}}}}}'| awk '/X-Subject-Token:/ {print $2}'`
curl -i 'http://193.160.15.13:35357/v3/auth/tokens' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"id":"bd456da75a784a0686eeebfd7627101e","password":"fnst1234"}}},"scope":{"project":{"id":"70bbb7ea3797467d86c0793e1289d86a"}}}}'
curl -d '{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"id": "cea368aa07164c4d89b2e1ad57b18151",
"password": "nes2n:cl4nsBJarh"
}
}
},
"scope": {
"project": {
"id": "31ceb599e8ff48aeb66f2fd748988960"
}
}
}
}' -X POST http://10.12.8.201:35357/v3/auth/tokens -i -H "Content-Type: application/json"
curl -i 'http://controller:35357/v3/users/bd456da75a784a0686eeebfd7627101e/projects' -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: $token"