github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ims/v1/images/CreateWholeImageFromECS.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  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/ims/v1/others"
     8  )
     9  
    10  // CreateWholeImageFromECSOpts Parameters for creating a full-ECS image using an ECS
    11  type CreateWholeImageFromECSOpts struct {
    12  	// Specifies the image name. For detailed description, see Image Attributes.
    13  	Name string `json:"name" required:"true"`
    14  	// Provides supplementary information about the image. For detailed description, see Image Attributes.
    15  	Description string `json:"description,omitempty"`
    16  	// Lists the image tags. The value is left blank by default.
    17  	// Use either tags or image_tags.
    18  	Tags []string `json:"tags,omitempty"`
    19  	// Lists the image tags. The value is left blank by default.
    20  	// Use either tags or image_tags.
    21  	ImageTags []tags.ResourceTag `json:"image_tags,omitempty"`
    22  	// Specifies the ECS ID. This parameter is required when an ECS is used to create a full-ECS image.
    23  	//
    24  	// To obtain the ECS ID, perform the following operations:
    25  	//
    26  	// Log in to management console.
    27  	//
    28  	// Under Computing, click Elastic Cloud Server.
    29  	//
    30  	// In the ECS list, click the name of the ECS and view its ID.
    31  	InstanceId string `json:"instance_id" required:"true"`
    32  	// Specifies the maximum memory of the image in the unit of MB. This parameter is not configured by default.
    33  	MaxRam int `json:"max_ram,omitempty"`
    34  	// Specifies the minimum memory of the image in the unit of MB. The default value is 0.
    35  	MinRam int `json:"min_ram,omitempty"`
    36  	// Specifies the ID of the vault to which an ECS is to be added or has been added.
    37  	//
    38  	// To create a full-ECS image from an ECS, create a backup from the ECS and then use the backup to create a full-ECS image. If a CBR backup is created, vault_id is mandatory. If a CSBS backup is created, vault_id is optional.
    39  	//
    40  	// You can obtain the vault ID from the CBR console or section "Querying the Vault List" in Cloud Backup and Recovery API Reference.
    41  	VaultId string `json:"vault_id,omitempty"`
    42  }
    43  
    44  func CreateWholeImageFromECS(client *golangsdk.ServiceClient, opts CreateWholeImageFromECSOpts) (*string, error) {
    45  	b, err := build.RequestBody(opts, "")
    46  	if err != nil {
    47  		return nil, err
    48  	}
    49  
    50  	return wholeImages(client, b)
    51  }
    52  
    53  func wholeImages(client *golangsdk.ServiceClient, b *build.Body) (*string, error) {
    54  	// POST /v1/cloudimages/wholeimages/action
    55  	raw, err := client.Post(client.ServiceURL("cloudimages", "wholeimages", "action"), b, nil, &golangsdk.RequestOpts{
    56  		OkCodes: []int{200},
    57  	})
    58  	return others.ExtractJobId(err, raw)
    59  }