github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ims/v2/images/CreateImageFromDisk.go (about)

     1  package images
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags"
     7  )
     8  
     9  // CreateImageFromDiskOpts Create a system disk image from a data disk.
    10  type CreateImageFromDiskOpts struct {
    11  	// Specifies the name of the system disk image.
    12  	Name string `json:"name" required:"true"`
    13  	// Specifies the data disk ID.
    14  	VolumeId string `json:"volume_id" required:"true"`
    15  	// Specifies the OS version.
    16  	//
    17  	// Set the parameter value based on Values of Related Parameters. Otherwise, the created system disk image may be unavailable.
    18  	//
    19  	// During the creation of a system disk image, if the OS can be detected from the data disk, the OS version in the data disk is used. In this case, the os_version value is invalid. If the OS can be detected from the data disk, the os_version value is used.
    20  	OsVersion string `json:"os_version" required:"true"`
    21  	// Specifies the image type.
    22  	//
    23  	// The value can be ECS, BMS, FusionCompute, or Ironic.
    24  	//
    25  	// ECS and FusionCompute: indicates an ECS image.
    26  	// BMS and Ironic: indicates a BMS image.
    27  	// The default value is ECS.
    28  	Type string `json:"type,omitempty"`
    29  	// Specifies the image description. This parameter is left blank by default. For details, see Image Attributes.
    30  	//
    31  	// The image description must meet the following requirements:
    32  	//
    33  	// Contains only letters and digits.
    34  	// Cannot contain carriage returns and angle brackets (< >).
    35  	// Cannot exceed 1024 characters.
    36  	Description string `json:"description,omitempty"`
    37  	// Specifies the minimum memory size (MB) required for running the image.
    38  	//
    39  	// The parameter value depends on the ECS specifications. The default value is 0.
    40  	MinRam int `json:"min_ram,omitempty"`
    41  	// Specifies the maximum memory size (MB) required for running the image.
    42  	//
    43  	// The parameter value depends on the ECS specifications. The default value is 0.
    44  	MaxRam int `json:"max_ram,omitempty"`
    45  	// Specifies tags of the image. This parameter is left blank by default.
    46  	//
    47  	// Use either tags or image_tags.
    48  	Tags []string `json:"tags,omitempty"`
    49  	// Specifies tags of the image. This parameter is left blank by default.
    50  	//
    51  	// Use either tags or image_tags.
    52  	ImageTags []tags.ResourceTag `json:"image_tags,omitempty"`
    53  }
    54  
    55  // CreateImageFromDisk Constraints (Creating a System Disk Image Using a Data Disk)
    56  // Before using a data disk to create a system disk image, ensure that an OS has been installed on the data disk and has been optimized. For details about the optimization, see "Optimizing a Windows Private Image" and "Optimizing a Linux Private Image" in the Image Management Service User Guide.
    57  // The system cannot verify that an OS has been installed on the data disk. Therefore, ensure that the value of os_version is valid when creating a system disk image from the data disk. For details, see Values of Related Parameters.
    58  func CreateImageFromDisk(client *golangsdk.ServiceClient, opts CreateImageFromDiskOpts) (*string, error) {
    59  	b, err := build.RequestBody(opts, "")
    60  	if err != nil {
    61  		return nil, err
    62  	}
    63  
    64  	return cloudImages(client, b)
    65  }