python 用于订购VSI并指定安装后脚本URL的Python示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 用于订购VSI并指定安装后脚本URL的Python示例相关的知识,希望对你有一定的参考价值。

from __future__ import print_function
import SoftLayer
from SoftLayer.managers.vs import VSManager

def create_vsi():
    #Create a client to the SoftLayer_Account API service.
    #Note: currently set without the user ID and API key since
    #it will by default use the values set in the CLI
    #to use other values use SoftLayer.Client(sl_username, sl_api_key)
    client = SoftLayer.Client()
    vsi_mgr = VSManager(client)

    # uncomment to display create options
    # print(vsi_mgr.get_create_options())

    # common values
    datacenter = 'wdc07' # the data center code
    domain = 'example.com' # the domain name suffix for the host
    os_code = 'UBUNTU_LATEST_64' # the operating system code
    local_disk = True # local disk or SAN
    hourly = True # hourly or monthly billing
    dedicated = False # multi-tenant or single tenant
    private_vlan = '1892939' # VLAN for the server see VLAN list above
    public_vlan = '1892917'
    nic_speed = 1000 # speed of network device
    disks = [100] # size of the disks
    private = False # private networking only or include public internet networking as well
    ssh_keys = [975995, 972047] # the IDs of the ssh keys to load on the server - use slcli sshkey list
    post_uri = 'https://tinylab.info/apacheInstaller.sh'
    hostname = 'testing'
    cpus = 4
    memory = 8192
    tags = 'owner:ryan,project:poc,type:docker'

    result = vsi_mgr.create_instance(hostname=hostname, domain=domain,
                                     cpus=cpus, memory=memory, datacenter=datacenter,
                                     os_code=os_code, local_disk=local_disk,
                                     hourly=hourly, dedicated=dedicated,
                                     private_vlan=private_vlan, disks=disks,
                                     nic_speed=nic_speed, private=private,
                                     ssh_keys=ssh_keys, tags=tags)
    print(result)

if __name__ == '__main__':
    create_vsi()

以上是关于python 用于订购VSI并指定安装后脚本URL的Python示例的主要内容,如果未能解决你的问题,请参考以下文章

markdown 用于将VSI部署到专用主机的Terraform示例

python 获取VSI GPU

python 为VSI获取带宽

用于打开 URL 的 Shell 脚本

基于Python实现的ComicReaper漫画自动爬取脚本

Python 网络爬虫(新闻采集脚本)