码迷,mamicode.com
首页 > 其他好文 > 详细

Freezer - 备份云硬盘实现

时间:2016-09-11 23:11:34      阅读:651      评论:0      收藏:0      [点我收藏+]

标签:freezer

这里freezer备份云硬盘实际上是调用了cinder-backup来实现的。


这里还要介绍下freezer依赖的几个基本库

freezer api底层的restful api框架是基于falcon实现的。falcon简介:https://falconframework.org/

freezer scheduler基于APScheduler来实现定时备份的功能


具体实现见:https://github.com/yaoice/freezer-api/commit/4c3d371c28bc4635049bef4c037b7d1d36e9c532


使用curl测试api(freezer api使用keystone v2)

# 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


参考链接

http://blog.scottlowe.org/2014/02/19/using-curl-to-interact-with-a-restful-api/




本文出自 “the-way-to-cloud” 博客,请务必保留此出处http://iceyao.blog.51cto.com/9426658/1851753

Freezer - 备份云硬盘实现

标签:freezer

原文地址:http://iceyao.blog.51cto.com/9426658/1851753

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!