DigitalOcean API v2与SSH集成
项目描述
Python库,用于管理您的Digital Ocean账户
DigitalOcean API允许您使用常规HTTP请求以简单、程序化的方式管理DigitalOcean云中的Droplets和资源。端点是直观且强大的,允许您轻松调用以检索信息或执行操作。
这个库从API的Python包装器开始,旨在构建工具,以使其更容易管理、提供和部署到Digital Ocean。
亮点
功能全面:API包装器覆盖已发布的DigitalOcean API v2
经过测试:对API的大部分内容进行了集成测试
SSH集成:集成了paramiko库,您可以使用SSH登录并发出命令
部署便利性:如apt、pip和git等方法,便于部署
示例
从github部署新的Flask应用
import poseidon as P
client = P.connect()
ssh_key_id = client.keys.list()[0]['id']
droplet = client.droplets.create('example.changshe.io', 'sfo1', '512mb',
'ubuntu-14-04-x64', ssh_keys=[ssh_key_id])
domain = client.domains.create('example.changshe.io', droplet.ip_address)
records = client.domains.records(domain['name'])
records.create('A', data=droplet.ip_address)
ssh = droplet.connect()
ssh.apt('git python-pip')
ssh.git(username='changhiskhan', repo='hello_world')
ssh.chdir('hello_world')
ssh.pip_r('requirements.txt')
ssh.nohup('python app.py') # DNS takes a while to propagate
print ssh.ps()