Softlayer API:如何使用指定的数据盘进行图像捕获? [英] Softlayer API: How to do image capture with specify certain data disk?

查看:13
本文介绍了Softlayer API:如何使用指定的数据盘进行图像捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个磁盘为1、2、3、4的虚拟机,我想做一些图像操作:

I have a vm with disk 1,2,3,4, I want to do some image operations:

  • Q1:如何获取只包含系统盘和3盘的镜像?
  • Q2:如果我实现了 Q1 中描述的图像制作,我可以使用这个吗?映像安装或重新加载虚拟机?SL api 如何处理磁盘 3 中的图片?
  • Q3:我可以只为磁盘 3 制作快照映像吗?
  • Q4:如果我实现了 Q3 中描述的图像,我该如何使用它快照初始化磁盘?

推荐答案

在创建图像模板时,您可以在图像模板中指定所需的块设备,您可以使用 API 和门户来执行此操作.

at moment to create the image template you can specify the block devices that you want in the image template you can do that using the API and the portal.

>

这是一个使用 API 的示例

this is an example using the 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(或磁盘),为此您可以调用此方法:

You only need to get the block devices ID (or disks), for that you can call this method:

http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getBlockDevices

块设备有一些规则:

  1. 只能捕获磁盘类型的块设备.
  2. 交换类型的块设备不能不包含在要捕获的块设备列表中.(这是磁盘编号 1).
  3. 必须包含包含操作系统的块设备(这是磁盘编号 0).
  4. 图像中不能包含包含元数据的块设备.

当您使用此图像模板订购新设备时,您需要记住这一点:

When you are ordening a new device using this image template you need to keep in mind this:

  1. 如果您使用 placeOrder 方法,则需要确保添加了额外磁盘的价格.
  2. 如果您使用 createObject 方法,磁盘数量将从镜像模板中获取,因此无需指定额外的磁盘.

您也可以在重新加载时使用图像模板,但重新加载仅影响包含操作系统的磁盘.因此,如果您有一台包含 3 个磁盘的虚拟机并执行重新加载,则即使映像模板具有 3 个磁盘,也只有包含操作系统的磁盘会受到影响.

And also you can use the images templates in reloads, but the reload only afects to the disk wich contains the OS. so If you have a Vitrual machine which contains 3 disks and performs a reload only the disk which contains the OS is afected even if the image template has 3 disks.

如果您的订单由于磁盘容量不足或其他问题而出现错误,则在配置时会出现错误并且不会配置 VSI,可能会打开一张票,一些 softlayer 员工会通知您

In case there are errors in your order due to lack of disk capacity or other issues, at provisioning time there will be errors and the VSI will not be provisioned, likely a ticket will be opened and some softlayer employee will inform you about that.

问候

这篇关于Softlayer API:如何使用指定的数据盘进行图像捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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