本文整理汇总了Python中dopy.manager.DoManager.new_droplet方法的典型用法代码示例。如果您正苦于以下问题:Python DoManager.new_droplet方法的具体用法?Python DoManager.new_droplet怎么用?Python DoManager.new_droplet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dopy.manager.DoManager
的用法示例。
在下文中一共展示了DoManager.new_droplet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DoManager
# 需要导入模块: from dopy.manager import DoManager [as 别名]
# 或者: from dopy.manager.DoManager import new_droplet [as 别名]
from dopy.manager import DoManager
import os
API_VERSION = 2
SIZE = '512mb'
REGION = 'nyc2'
PURPOSE = 'wordpress'
VERSION = '1'
IMAGE = 'ubuntu-14-04-x64'
USER_DATA = '''#cloud-config
users:
- name: ansible
ssh-authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOd/iTQUd6Hb/KTpDjjPJotOWHfTH71U5L7x9Y4y9bo7Zvtp/m1WZyR55Ut6uBfGHscD5WRNv6VFsRIHRRjiHP+pGkB4piSUNuOduEOL/FCzmytQLmg7mYZZRGHLYXIoFJV/kdXmjexXSySxJSSp5X5EcH/pLWcKhRK9HiX4IGOBZfNwxaL/VODxU989jNXuKPnF6XfuNVf9p7JYkc4zaDy4752pPCWU2oTfq6y5Ll0vqoSpb62gCUf94CYU5eQddIeZEutTi2UiuqbsA7sEvsZpp/iXXvkaCAWMNRY6VMy5AUavDpNk4tZ/ITcieCWYdfDPCBDcfXwgANlVorHGaR [email protected]
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: sudo
shell: /bin/bash
runcmd:
- sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
- sed -i -e '$aAllowUsers ansible' /etc/ssh/sshd_config
- restart ssh
'''
do = DoManager(None, os.environ['DO_API_TOKEN'], API_VERSION)
results = do.new_droplet('{0}-{1}-{2}'.format(REGION, PURPOSE, VERSION), SIZE, IMAGE, REGION, user_data=USER_DATA)
for i in results.keys():
print('{0}: {1}'.format(i, results[i]))