使用 rest api 在 softlayer 中使用静态 ip 启动虚拟机
Launch Virtual Machine with Static ip in softlayer using rest api
我需要一个如何在 softlayer 中使用静态 ip 启动虚拟机的解决方案,我在许多网站上搜索仍然没有得到任何答案 softlayer 支持静态 ip,想知道订购静态 ip 的方式是什么在软层中以及如何干扰虚拟机
非常感谢您的回答...
为了订购具有任何规格的虚拟客人,您应该获得正确的商品价格 ID,为此您可以 运行 下一个请求:
https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Package/46/getItemPrices.json
Method: GET
获得商品价格 ID 后,您可以使用它们来 verify/place 具有您想要的特征的订单,这里是订购具有静态 IPv4 的 VSI 的示例:
https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json
Method: POST
Body:
{
"parameters": [
{
"complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
"quantity": 1,
"virtualGuests": [
{"hostname": "test-template", "domain": "example.com"}
],
"location": 168642,
"packageId": 46,
"prices": [
{"id": 1640},
{"id": 1644},
{"id": 905},
{"id": 272},
{"id":50231},
{"id": 21},
{"id": 2202},
{"id":13945},
{"id": 55},
{"id": 57},
{"id": 58},
{"id": 420},
{"id": 418},
{"id": 22}
]
}
]
}
此外,您可以使用此 python 脚本,该脚本已记录并描述了静态 IPv4 的 REST 请求中使用的每个商品价格 ID:
注:脚本使用SLpython客户端https://github.com/softlayer/softlayer-python
"""
Order Virtual Guest with Static IPv4.
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. <sldn@softlayer.com>
"""
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': 22} # 4 Public IP Addresses
]
}
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))
这里有一个使用静态 IPv6 订购 VSI 的示例:
https:// $username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json
Method: POST
Body:
{
"parameters": [
{
"complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
"quantity": 1,
"virtualGuests": [
{"hostname": "test-template", "domain": "example.com"}
],
"location": 168642,
"packageId": 46,
"prices": [
{"id": 1640},
{"id": 1644},
{"id": 905},
{"id": 272},
{"id":50231},
{"id": 21},
{"id": 2202},
{"id":13945},
{"id": 55},
{"id": 57},
{"id": 58},
{"id": 420},
{"id": 418},
{"id": 17129},
{"id": 1481}
]
}
]
}
此外,您还可以使用此 python 脚本,该脚本已记录并描述了静态 IPv6 的 REST 请求中使用的每个商品价格 ID:
注:脚本使用SLpython客户端https://github.com/softlayer/softlayer-python
"""
Order Virtual Guest with Static IPv6.
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. <sldn@softlayer.com>
"""
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':17129}, # 1_IPV6_ADDRESS
{'id': 1481} # 64_BLOCK_STATIC_PUBLIC_IPV6_ADDRESSES ]
}
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))
我需要一个如何在 softlayer 中使用静态 ip 启动虚拟机的解决方案,我在许多网站上搜索仍然没有得到任何答案 softlayer 支持静态 ip,想知道订购静态 ip 的方式是什么在软层中以及如何干扰虚拟机
非常感谢您的回答...
为了订购具有任何规格的虚拟客人,您应该获得正确的商品价格 ID,为此您可以 运行 下一个请求:
https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Package/46/getItemPrices.json
Method: GET
获得商品价格 ID 后,您可以使用它们来 verify/place 具有您想要的特征的订单,这里是订购具有静态 IPv4 的 VSI 的示例:
https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json
Method: POST
Body:
{
"parameters": [
{
"complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
"quantity": 1,
"virtualGuests": [
{"hostname": "test-template", "domain": "example.com"}
],
"location": 168642,
"packageId": 46,
"prices": [
{"id": 1640},
{"id": 1644},
{"id": 905},
{"id": 272},
{"id":50231},
{"id": 21},
{"id": 2202},
{"id":13945},
{"id": 55},
{"id": 57},
{"id": 58},
{"id": 420},
{"id": 418},
{"id": 22}
]
}
]
}
此外,您可以使用此 python 脚本,该脚本已记录并描述了静态 IPv4 的 REST 请求中使用的每个商品价格 ID: 注:脚本使用SLpython客户端https://github.com/softlayer/softlayer-python
"""
Order Virtual Guest with Static IPv4.
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. <sldn@softlayer.com>
"""
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': 22} # 4 Public IP Addresses
]
}
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))
这里有一个使用静态 IPv6 订购 VSI 的示例:
https:// $username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json
Method: POST
Body:
{
"parameters": [
{
"complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
"quantity": 1,
"virtualGuests": [
{"hostname": "test-template", "domain": "example.com"}
],
"location": 168642,
"packageId": 46,
"prices": [
{"id": 1640},
{"id": 1644},
{"id": 905},
{"id": 272},
{"id":50231},
{"id": 21},
{"id": 2202},
{"id":13945},
{"id": 55},
{"id": 57},
{"id": 58},
{"id": 420},
{"id": 418},
{"id": 17129},
{"id": 1481}
]
}
]
}
此外,您还可以使用此 python 脚本,该脚本已记录并描述了静态 IPv6 的 REST 请求中使用的每个商品价格 ID: 注:脚本使用SLpython客户端https://github.com/softlayer/softlayer-python
"""
Order Virtual Guest with Static IPv6.
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. <sldn@softlayer.com>
"""
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':17129}, # 1_IPV6_ADDRESS
{'id': 1481} # 64_BLOCK_STATIC_PUBLIC_IPV6_ADDRESSES ]
}
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))