我有一个带磁盘1,2,3,4的虚拟机,我想做一些图像操作:
答案 0 :(得分:1)
在创建图像模板时,您可以使用API和门户网站在图像模板中指定所需的块设备。
这是使用API的示例
"""
Create image template.
The script creates a standard image template, it makes
a call to the SoftLayer_Virtual_Guest::createArchiveTransaction method
sending the IDs of the disks in the request.
For more information please see below.
Important manual pages:
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createArchiveTransaction
https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Block_Device
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'
# The virtual guest ID you want to create a template
virtualGuestId = 4058502
# The name of the image template
groupName = 'my image name'
# An optional note for the image template
note = 'an optional note'
"""
Build a skeleton SoftLayer_Virtual_Guest_Block_Device object
containing the disks you want to the image.
In this case we are going take an image template of 2 disks
from the virtual machine.
"""
blockDevices = [
{
"id": 4667098,
"complexType": "SoftLayer_Virtual_Guest_Block_Device"
},
{
"id": 4667094,
"complexType": "SoftLayer_Virtual_Guest_Block_Device"
}
]
# Declare a new API service object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
try:
# Creating the transaction for the image template
response = client['SoftLayer_Virtual_Guest'].createArchiveTransaction(groupName, blockDevices, note, id=virtualGuestId)
print(response)
except SoftLayer.SoftLayerAPIError as e:
"""
# If there was an error returned from the SoftLayer API then bomb out with the
# error message.
"""
print("Unable to create the image template. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
您只需要获取块设备ID(或磁盘),因为您可以调用此方法:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getBlockDevices
块设备有一些规则:
使用此图片模板设置新设备时,需要记住:
此外,您还可以在重新加载时使用图像模板,但重新加载仅对包含操作系统的磁盘产生影响。因此,如果您的Vitrual计算机包含3个磁盘并执行重新加载,则即使图像模板有3个磁盘,也只会影响包含该操作系统的磁盘。
如果由于磁盘容量不足或其他问题导致您的订单出现错误,在配置时会出现错误并且不会配置VSI,可能会打开故障单并且一些softlayer员工会通知您这一点。
此致