我正在使用Softlayer Python Client API。我想通过API安装mongodb的实例。 我该怎么办?如何订购安装了MongoDB的实例
0
A
回答
0
要订购具有Mongo DB的虚拟客人,必须使用此物品的价格ID。 验证/将与现有的商品价格对任何产品的订单,最好的办法是查看下一个方法: http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getItemPrices
下一个脚本可用于订购与MongoDB的社区版虚拟客户。
"""
Order Virtual Guest with MongoDB Community Edition.
Important manual pages:
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
from pprint import pprint as pp
USERNAME = 'set me'
API_KEY = 'set me'
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
order = {
'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest',
'quantity': 1,
'virtualGuests': [
{'hostname': 'test-template', 'domain': 'example.com'}
],
'location': 168642, # San Jose 1
'packageId': 46, # CCI Package
'prices': [
{'id': 1640}, # 1 x 2.0 GHz Core
{'id': 1644}, # 1 GB RAM
{'id': 905}, # Reboot/Remote Console
{'id': 272}, # 10 Mbps Public & Private Networks
{'id':50231}, # 1000 GB Bandwidth
{'id': 21}, # 1 IP Address
{'id': 2202}, # 25 GB (SAN)
{'id':13945}, # CentOS 6.x - Minimal Install (64 bit)
{'id': 55}, # Host Ping Monitoring
{'id': 57}, # Email and Ticket Notifications
{'id': 58}, # Automated Notification Response
{'id': 420}, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
{'id': 418}, # Nessus Vulnerability Assessment & Reporting
{'id':20893} # MongoDB Community Edition
]
}
try:
# Replace verifyOrder for placeOrder
result = client['SoftLayer_Product_Order'].verifyOrder(order)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to verify/place order faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
您可以审查,以及下一个链接了解更多信息: http://sldn.softlayer.com/blog/bpotter/Going-Further-SoftLayer-API-Python-Client-Part-3
UPDATE
对象模板将是最好的方式来检索其他对象的数据,如已创建实例的物品价格ID。
您可以使用此面膜:
mask[billingItem[orderItem,children[orderItem]]]
或者这一块,这是更细化:
mask[billingItem[id,orderItem[itemPriceId],children[id,orderItem[itemPriceId]]]]
在Python中,你可以以这种方式使用这些面具:
"""
Get Virtual Guest and its itme price ids
Important manual pages:
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getObject
https://sldn.softlayer.com/article/object-masks
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
from pprint import pprint as pp
USERNAME = 'set me'
API_KEY = 'set me'
virtualGuestId = 25129311
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
objectMask = 'mask[billingItem[id,orderItem[itemPriceId],children[id,orderItem[itemPriceId]]]]'
try:
result = client['SoftLayer_Virtual_Guest'].getObject(id=virtualGuestId, mask=objectMask)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to get virtual guest faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
关于ssh密钥,您只需将此行添加到订单上述脚本的对象(使用mongo db命令虚拟客户端的对象)
'sshKeys': [{'sshKeyIds': [214147, 94206]}]
相关问题
- 1. 安装了mongodb
- 2. 如何订购的价值MongoDB的
- 3. 订购了LINQ
- 4. 静态块实例块java订购
- 5. 木偶订购乘客安装红宝石前安装
- 6. 如何安装Google回购?
- 7. 如何在EC2实例上安装Cron
- 8. 如何安装phpmyadmin到mysql实例
- 9. 如何在amazon实例上安装redmine?
- 10. 如何辨别谁购买了订阅
- 11. 如何订购包装LESS +远程FTP?
- 12. '订购'实体bean
- 13. 如何订购预购表
- 14. SQLEXPRESS安装实例名称
- 15. 安装TensorFlow在EC2实例
- 16. 无法订购点 - Graphviz了
- 17. 如何订购HashList?
- 18. 如何订购DataColumns?
- 19. 如何订购JSONArray?
- 20. Otto改装 - 订购不叫
- 21. 如何卸载手动安装的MongoDB
- 22. 如何创建支持多个实例的安装项目(多个安装)?
- 23. 如何在Amazon Linux AMI EC2实例上安装安全更新?
- 24. 如何订购的时间
- 25. 使用Castle Windsor安装程序工厂来订购安装程序
- 26. 使用PHP在MongoDB查询中订购
- 27. MongoDB Schema设计订购服务
- 28. 如何通过自定义订单来订购实体列表?
- 29. MongoDB实例(Windows)
- 30. 安装:Ubuntu的EC2实例上的Redmine
谢谢。代码片段非常有用。如何获得已预配置实例的价格ID? –
我把twicked你的代码片段,以适应我的设置。但是,无论我检查了什么,我都无法弄清楚添加ssh密钥的正确语法。这是我的最后尝试: –
顺序= { '的complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest', 'useHourlyPricing':真, '量':1, 'sshKeys':[{ 'sshKeyIds':[716119]}], 'virtualGuests':[{ '主机名':集箱, '域':设定我”, 'sshKeyCount':1, 'sshKeys':[716119] }], .....} –