将SSH密钥添加到裸机的Softlayer JSON顺序中 [英] Adding SSH keys to Softlayer JSON order for Bare metal

查看:88
本文介绍了将SSH密钥添加到裸机的Softlayer JSON顺序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在softlayer中添加要添加到json裸机订单中的ssh密钥.通过GUI,它将在订单末尾添加,然后单击提交".

I was wondering how to add ssh keys that are within softlayer to be added to a json bare metal order. Through the GUI, it would be added at the end of the order before you click submit

很想知道是否只是:

productOrder = { "quantity": 1, "location": 1234, "packageId": 1234, "sshKeyIds": 1234, "hardware": [ ...

productOrder = { "quantity": 1, "location": 1234, "packageId": 1234, "sshKeyIds": 1234, "hardware": [ ...

我做了一个verifyOrder(),但不确定是否正确

I did a verifyOrder() but not sure if it's correct

推荐答案

如果使用的是:

If you are using: SoftLayer_Product_Order::placeOrder method, take a look the following example:

"""
Order a new server with SSH Keys

Important manual pages:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware_Server
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer


# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'


productOrder = {
    'quantity': 1,
    'location': "DALLAS09",
    'packageId': 255,
    'hardware': [
                 {
                  'hostname': 'rcvtest-11',  # The hostname of the server you wish to order.
                  'domain': 'example.org'  # The domain name of the server you wish to order.
                  }
                 ],
    'prices': [
               {'id': 50357},  
               {'id': 50041},  
               {'id': 876},  
               {'id': 55},  
               {'id': 57},  
               {'id': 44988},  
               {'id': 273},  
               {'id': 21},  
               {'id': 50387},  
               {'id': 906},  
               {'id': 58},  
               {'id': 50397},  
               {'id': 420},  
               {'id': 418}  
               ],
        'sshKeys': [{'sshKeyIds': [214147, 94206]}]

}

# Create a SoftLayer API client object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)

try:
    """
    verifyOrder() will check your order for errors. Replace this with a call
    to placeOrder() when you're ready to order. Both calls return a receipt
    object that you can use for your records.

    Once your order is placed it'll go through SoftLayer's approval and
    provisioning process. When it's done you'll have a new
    SoftLayer_Hardware_Server object and server ready to use.
    """
    receipt = client['Product_Order'].verifyOrder(productOrder)
    print(receipt)
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to place a server order faultCode=%s, faultString=%s"
          % (e.faultCode, e.faultString))
    exit(1)

我希望它会有所帮助,让我知道任何疑问或意见

I hope it helps, let me know any doubt or comments

这篇关于将SSH密钥添加到裸机的Softlayer JSON顺序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆