本文整理匯總了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]))