django和amazon web服务的结构任务
django-fabfile的Python项目详细描述
Django和Amazon Web服务的结构任务注意:路径中应列出"django_fabfile"包。如果您使用"pip install django fabfile"安装它,它已经
就位。但是,如果
您正在存储库中工作,则::
如果选项未在django设置中配置
,则其值将取自`./fabfile.cfg``
file-复制粘贴应该从默认值覆盖的行
:下载:`django fabfile/fabfile.cfg.def<;./django fabfile/fabfile.cfg.def>;`.
django设置应按以下格式配置(保留
节大小写)::
fabfile={
"默认":{
"日志文件夹":",
},
"凭据":{
"aws访问密钥id":"akiaabcdefghijklmnop",
"aws_secret_access_key":"abcdefghijklmnopqrstuvxyzabcdefghijklm",
},
}
……注意:
boto配置文件http://code.google.com/p/boto/wiki/boto config将被
至少检查-如果在django设置或`./fabfile.cfg``中填写了```[credentials]``或其他一些选项,或者:下载:`django fabfile/fabfile.cfg.def<;./django fabfile/fabfile.cfg.def>;`.
所需的AWS IAM策略示例
--------
>对于使用结构任务,您需要具有以下权限的AWS帐户:
*创建快照::
{
"语句":[
{
"sid":"stmt1304003463574",
"操作":[
"ec2:createSnapshot"、
"ec2:createTags"、
"ec2:descibeInstances"、
"ec2:descibeRegions"、
"ec2:descibeSnapshots"、
"ec2:descibeTags"、
"ec2:descibeVolumes"
]、
"效果":"允许"、
"resource":"*"
}
]
}
*delete snapshot::
{
"statement":[
{
"sid":"stmt1306410750989",
"action":[
"ec2:describeRegions",
"ec2:describesnapshots",
"ec2:deleteSnapshot"
],
"effect":"allow"、
"resource":"*"
}
]
}
*重启实例:
{
"statement":[
{
"sid":"stmt1312204628195"、
"action":[
"ec2:重启实例"
、
"effect":"allow"、
"resource":"*"
},
{
"sid":"stmt1312276311113",
"action":[
"ec2:detachvolume"
],
"effect":"allow",
"resource":"*"
}
]
}
*rsync快照::
{
"statement":[
{
"effect":"allow",
"action":[
"ec2:attachvolume",
"ec2:createkeypair",
"ec2:createvolume",
"ec2:deleteKeyPair"、
"ec2:deleteVolume"、
"ec2:describeAvailabilityZones"、
"ec2:describeImages"、
"ec2:describeKeyPairs"、
"ec2:runInstances"、
"ec2:terminateInstances"
]、
"resource":"*"
}
]
}
备份脚本注意:实例和快照按标记"earmar"进行筛选特大号"价值
"生产"。这可以在"设置"中进行配置-请参阅上面的"预运行
配置"部分。
可以使用crontab将以下备份命令配置为每天运行:
/bin/sh
ve=/home/backup agent/.virtualenvs/backup
。$ve/bin/activate&;\
fab--keepalive=60-f$ve/lib/python2.6/site-packages/django_fabfile/backup.py\
backup_instances_by_tag\
trim_snapshots\
rsync_region:src_region_name=us-east-1,dst_region_name=eu-west-1\
rsync_region:src_region_name=us-west-1,dst_region_name=eu-west-1\
rsync_region:src_region_name=eu-west-1,dst_region_name=us-east-1
使用30个生产实例大约需要6小时来复制快照更新。第一次复制显然要花更多的时间。
运行测试
----
包有测试用例来确保所有正在测试的方法都保持整个程序逻辑。测试用例使用包"fudge"和"unittest"。测试文件(``'test*.py```)位于文件夹
``'/django_fabfile/tests/'```中。要从命令行运行测试,实现:
python-m unittest discover django_fabfile
recent changes
----
请参见:doc:`changelog`了解最新更新。
许可
-
该产品由odesk http://www.odesk.com/在
:下载:`gnu general public license version 3<;license.txt>;`除了带有附加的内联许可证信息的
:func:`django_fabfile.backup.\u trim_snapshots`。
就位。但是,如果
您正在存储库中工作,则::
如果选项未在django设置中配置
,则其值将取自`./fabfile.cfg``
file-复制粘贴应该从默认值覆盖的行
:下载:`django fabfile/fabfile.cfg.def<;./django fabfile/fabfile.cfg.def>;`.
django设置应按以下格式配置(保留
节大小写)::
fabfile={
"默认":{
"日志文件夹":",
},
"凭据":{
"aws访问密钥id":"akiaabcdefghijklmnop",
"aws_secret_access_key":"abcdefghijklmnopqrstuvxyzabcdefghijklm",
},
}
……注意:
boto配置文件http://code.google.com/p/boto/wiki/boto config将被
至少检查-如果在django设置或`./fabfile.cfg``中填写了```[credentials]``或其他一些选项,或者:下载:`django fabfile/fabfile.cfg.def<;./django fabfile/fabfile.cfg.def>;`.
所需的AWS IAM策略示例
--------
>对于使用结构任务,您需要具有以下权限的AWS帐户:
*创建快照::
{
"语句":[
{
"sid":"stmt1304003463574",
"操作":[
"ec2:createSnapshot"、
"ec2:createTags"、
"ec2:descibeInstances"、
"ec2:descibeRegions"、
"ec2:descibeSnapshots"、
"ec2:descibeTags"、
"ec2:descibeVolumes"
]、
"效果":"允许"、
"resource":"*"
}
]
}
*delete snapshot::
{
"statement":[
{
"sid":"stmt1306410750989",
"action":[
"ec2:describeRegions",
"ec2:describesnapshots",
"ec2:deleteSnapshot"
],
"effect":"allow"、
"resource":"*"
}
]
}
*重启实例:
{
"statement":[
{
"sid":"stmt1312204628195"、
"action":[
"ec2:重启实例"
、
"effect":"allow"、
"resource":"*"
},
{
"sid":"stmt1312276311113",
"action":[
"ec2:detachvolume"
],
"effect":"allow",
"resource":"*"
}
]
}
*rsync快照::
{
"statement":[
{
"effect":"allow",
"action":[
"ec2:attachvolume",
"ec2:createkeypair",
"ec2:createvolume",
"ec2:deleteKeyPair"、
"ec2:deleteVolume"、
"ec2:describeAvailabilityZones"、
"ec2:describeImages"、
"ec2:describeKeyPairs"、
"ec2:runInstances"、
"ec2:terminateInstances"
]、
"resource":"*"
}
]
}
备份脚本注意:实例和快照按标记"earmar"进行筛选特大号"价值
"生产"。这可以在"设置"中进行配置-请参阅上面的"预运行
配置"部分。
可以使用crontab将以下备份命令配置为每天运行:
/bin/sh
ve=/home/backup agent/.virtualenvs/backup
。$ve/bin/activate&;\
fab--keepalive=60-f$ve/lib/python2.6/site-packages/django_fabfile/backup.py\
backup_instances_by_tag\
trim_snapshots\
rsync_region:src_region_name=us-east-1,dst_region_name=eu-west-1\
rsync_region:src_region_name=us-west-1,dst_region_name=eu-west-1\
rsync_region:src_region_name=eu-west-1,dst_region_name=us-east-1
使用30个生产实例大约需要6小时来复制快照更新。第一次复制显然要花更多的时间。
运行测试
----
包有测试用例来确保所有正在测试的方法都保持整个程序逻辑。测试用例使用包"fudge"和"unittest"。测试文件(``'test*.py```)位于文件夹
``'/django_fabfile/tests/'```中。要从命令行运行测试,实现:
python-m unittest discover django_fabfile
recent changes
----
请参见:doc:`changelog`了解最新更新。
许可
-
该产品由odesk http://www.odesk.com/在
:下载:`gnu general public license version 3<;license.txt>;`除了带有附加的内联许可证信息的
:func:`django_fabfile.backup.\u trim_snapshots`。