1

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

  • Q1: How can i capture the image only contain system disk and disk 3?
  • Q2: If I achieve the image production described in Q1, can I use this image install or reload a vm? How SL api to do with the disk 3 in the image ?
  • Q3: Can I make a snapshot image only for disk 3?
  • Q4: If I achieve the image described in Q3, how can I use this snapshot to init a disk ?
lippman
  • 33
  • 4
  • comment for Q2: If the vm I want to reload has not disk 2(or has disk 2 but the disk capacity is less than the image's disk 2), and I force to install the image (system disk + disk 2) into it, what will happen? – lippman Sep 12 '16 at 07:54

1 Answers1

1

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.

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))

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

There is some rules for the block devices:

  1. Only block devices of type disk can be captured.
  2. The block device of swap type cannot not be included in the list of block devices to capture.(this is is the disk number 1).
  3. The block device which contains the OS must be included (this is the disk number 0).
  4. The block devices which contain metadata cannot be included in the image.

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

  1. If you are using the placeOrder method you need to make sure that you are adding the prices for the extra disks.
  2. If you are using the createObject method, the number of disk will be taken from the image template, so it is not neccesary to specify the extra disks.

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.

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.

Regards

  • Thank you so much for your answer. It solved my great confusion. I would also like to confirm the Q3: sl api not support to make snapshot for data disk only? For example, I want to capture disk3 and copy this snapshot to other idc to init a new created disk. – lippman Sep 13 '16 at 02:16
  • The other one: “The block devices which contain metadata cannot be included in the image.” ------ What does metadata means? How can i confirm a block disk has contain metadata or not? Could you show me an example? Regards – lippman Sep 13 '16 at 03:01
  • Addition: For the image including os and disk 2,3. If I use this image to ordering a new device by using placeOrder( adding the prices for the extra disks 2,3.) or createObject. Then will get a vm with extra disk 2,3. My question is that are these extra disks 2,3 can be initialized by the data of disk2,3 in image template? – lippman Sep 13 '16 at 08:39
  • I told you, it is required to add the disk which contains the os, so already answer your questión about only take snapshot of the disk 3 (it is not possible), regarding the metada tha is up to you, those disks are especial and using the Api there is no way to know is it is a metadata disk, but the method will fail if you try to add it. Yep the disk 2 3 should have your data, – Nelson Raul Cabero Mendoza Sep 13 '16 at 10:47
  • Thank you for your kindly reply. Best regards~ – lippman Sep 14 '16 at 01:56