我们如何在SoftLayer中任意命名(或重命名)新引用?

时间:2017-02-06 06:18:29

标签: python ibm-cloud ibm-cloud-infrastructure

我成功地发了一个引号,但它是由initiate参数自动命名的。 你有什么方法可以命名或重命名吗? 我使用python和SoftLayer API。

ProductSoftLayer_Product_Order::placeQuote | SoftLayer Development Network

#import package
import SoftLayer
import json

# account info
client = SoftLayer.create_client_from_env()

order = {
'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest', 
'quantity': 1,
    'virtualGuests': [
      {
        'hostname': 'test', 
        'domain': 'example.com',
      }
],
'location': 449604, # Tokyo
'packageId': 46,  # VSI
'useHourlyPricing': False,
'prices': [
           {'id':26125},  # 1 x 2.0 GHz Core
           {'id':32597},  # 1 GB RAM
           {'id':23070},  # Reboot / Remote Console
           {'id':26737},  # 100 Mbps Public & Private Networks
           {'id':50369},  # 250 GB Bandwidth
           {'id':34807},  # 1 IP Address
           {'id':26466},  # 100 GB (LOCAL) First Disk
           {'id':175779},  # Windows Server 2012 R2 Standard Edition (64 bit)
           {'id':27023},  # Host Ping Monitoring
           {'id':32500},  # Email and Ticket Notifications
           {'id':32627},  # Automated Notification Response
           {'id':33483},  # Unlimited SSL VPN Users & 1 PPTP VPN User per account
           {'id':35310}   # Vulnerability Assessments & Management
]
}   

    # placeQuote
placeQuote = client['Product_Order'].placeQuote(order)

1 个答案:

答案 0 :(得分:0)

请务必看一下:

"""
Create a quote.
This script creates a quote based in the information provided into the
SoftLayer_Container_Product_Order_Virtual_Guest object passing that object to
SoftLayer_Product_Order::placeQuote method.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeQuote/
@License: http://sldn.softlayer.com/article/License
@Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
# So we can talk to the SoftLayer API:
import SoftLayer

# For nice debug output:
import pprint
"""
Your SoftLayer API username and key.
Generate an API key at the SoftLayer Customer Portal.
"""
API_USERNAME = 'set-me'
API_KEY = 'set-me'

order = {
    "orderContainers": [
        {
            "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
            "packageId": 46,
            "location": "HONGKONG02",
            "quantity": 1,
            "virtualGuests": [
                {
                    "hostname": "test",
                    "domain": "test.com"
                }
            ],
            "prices": [
                {"id": 1640},
                {"id": 1644},
                {"id": 13938},
                {"id": 2202},
                {"id": 248},
                {"id": 273},
                {"id": 2302},
                {"id": 55},
                {"id": 58},
                {"id": 420},
                {"id": 418},
                {"id": 21},
                {"id": 57},
                {"id": 905}
            ],
            "primaryDiskPartitionId": 1,
            "useHourlyPricing": False
        }
    ],
    "quoteName": "testQuote",
    "sendQuoteEmailFlag": True
}

client = SoftLayer.Client(username=API_USERNAME, api_key=API_KEY)

try:
    result = client['Product_Order'].placeQuote(order)
    pprint.pprint(result)
except SoftLayer.SoftLayerAPIError as e:
    print("Error placing the quote, faultCode=%s, faultString=%s"
          % (e.faultCode, e.faultString))
    exit(1)

对于您需要使用容器的订单,在这种情况下,您的容器是'SoftLayer_Container_Product_Order_Virtual_Guest',并且该容器具有名为“quoteName”的属性,您只需填写该属性。

此致