當前位置: 首頁>>代碼示例>>Python>>正文


Python DoManager.new_droplet方法代碼示例

本文整理匯總了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]))
開發者ID:graham-m-dunn,項目名稱:ansible-lamp,代碼行數:32,代碼來源:create-host.py


注:本文中的dopy.manager.DoManager.new_droplet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。