集成ssh的digitalocean api v2
poseidon的Python项目详细描述
用于管理数字海洋帐户的python库
DigitalOceanAPI允许您管理 使用传统http以简单的编程方式实现数字海洋云 请求。端点是直观和强大的,允许您轻松地 调用以检索信息或执行操作。
这个库从api的python包装器开始,旨在构建工具来 使管理、供应和部署到数字海洋变得更容易。
亮点
- 全功能:涵盖已发布的DigitalOcean API v2的API包装器
- 已测试:针对大多数api的集成测试覆盖率
- ssh集成:集成paramikolibrary,以便您可以ssh入站并发出命令
- 部署便利性:像apt、pip和git这样的方法更易于部署
示例
从github部署一个新的flask应用程序
importposeidonasPclient=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 propagateprintssh.ps()