這裏freezer備份雲硬盤其實是調用了cinder-backup來實現的。python
這裏還要介紹下freezer依賴的幾個基本庫git
freezer api底層的restful api框架是基於falcon實現的。falcon簡介:https://falconframework.org/ github
freezer scheduler基於APScheduler來實現定時備份的功能json
具體實現見:https://github.com/yaoice/freezer-api/commit/4c3d371c28bc4635049bef4c037b7d1d36e9c532api
使用curl測試api(freezer api使用keystone v2)bash
# keystone v2獲取token curl -s -d '{"auth":{"passwordCredentials":{"username": "admin", "password": "cloud"},"tenantName": "demo"}}' -H "Content-Type: application/json" http://192.168.141.6:5000/v2.0/tokens | python -m json.tool # keystone v3獲取token curl -i -H "Content-Type: application/json" -d ' { "auth": { "identity": { "methods": ["password"], "password": { "user": { "name": "admin", "domain": { "id": "default" }, "password": "cloud" } } } } }' http://localhost:5000/v3/auth/tokens ; echo # 獲取cinder全部的backups,純屬測試 curl -s -H "X-Auth-Token: fced5d5ae9e84009b3dca7972d7c5131"\ -X GET\ -H "Content-type: application/json"\ http://192.168.141.6:8776/v2/b232965aeb9c4b3a883ce41b16394e3f/backups | python -m json.tool # freezer獲取backup list curl -s -H "X-Auth-Token: fced5d5ae9e84009b3dca7972d7c5131" -X GET -H "Content-type: application/json" http://192.168.141.6:9090/v1/cinderbackups | python -m json.tool # freezer建立backup curl -s -H "X-Auth-Token: fd60f3b93b2841e893269b887572c26d" -X POST -H "Content-type: application/json" -d '{"volume_id": "438de34e-ef9e-4f4f-b047-600ab6229cc0"}' http://192.168.141.6:9090/v1/cinderbackups # freezer刪除backup curl -s -H "X-Auth-Token: 76744b82dd8c49c490eb7c0ca5f33824" -X DELETE -H "Content-type: application/json" http://192.168.141.6:9090/v1/cinderbackups/1ffe9901-43de-490e-b675-0bb92e50c4f4 # freezer還原備份,並建立一個新volume curl -s -H "X-Auth-Token: 232685c229fd48d4b24629f7748bceda" -X POST -H "Content-type: application/json" http://192.168.141.6:9090/v1/cinderrestores/ed3e05bd-c892-441c-b9c6-226bbb030794 # freezer針對某個volume備份還原 curl -s -H "X-Auth-Token: 232685c229fd48d4b2a629f7748bceda" -X POST -H "Content-type: application/json" -d '{"volume_id": "496a7db9-3197-4658-9cc6-ef496f2b0cd1"}' http://192.168.141.6:9090/v1/cinderrestores/da1b7290-5e56-43ff-b95f-a1c511b305d2
參考連接restful
http://blog.scottlowe.org/2014/02/19/using-curl-to-interact-with-a-restful-api/ app
http://www.tuicool.com/articles/2miY3eN (curl經常使用參數)框架