github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ims/v2/images/CreateImageFromOBS.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 // CreateImageFromOBSOpts Create a system disk image from an external image file uploaded to an OBS bucket. 10 type CreateImageFromOBSOpts struct { 11 // Specifies the name of the system disk image. For detailed description, see Image Attributes. 12 Name string `json:"name" required:"true"` 13 // Specifies the image description. For detailed description, see Image Attributes. The value contains a maximum of 1024 characters and consists of only letters and digits. Carriage returns and angle brackets (< >) are not allowed. This parameter is left blank by default. 14 Description string `json:"description,omitempty"` 15 // Specifies the OS type. The value can be Linux, Windows, or Other. 16 OsType string `json:"os_type,omitempty"` 17 // Specifies the OS version. 18 // 19 // This parameter is valid if an external image file uploaded to the OBS bucket is used to create an image. For its value, see Values of Related Parameters. 20 // 21 // NOTE: 22 // This parameter is mandatory when the value of is_quick_import is true, that is, a system disk image is imported using the quick import method. 23 OsVersion string `json:"os_version,omitempty"` 24 // Specifies the URL of the external image file in the OBS bucket. 25 // 26 // This parameter is mandatory if an external image file in the OBS bucket is used to create an image. The format is OBS bucket name:Image file name. 27 // 28 // To obtain an OBS bucket name: 29 // Log in to the management console and choose Storage > Object Storage Service. 30 // All OBS buckets are displayed in the list. 31 // 32 // Filter the OBS buckets by region and locate the target bucket in the current region. 33 // To obtain an OBS image file name: 34 // Log in to the management console and choose Storage > Object Storage Service. 35 // All OBS buckets are displayed in the list. 36 // 37 // Filter the OBS buckets by region and locate the target bucket in the current region. 38 // Click the name of the target bucket to go to the bucket details page. 39 // In the navigation pane on the left, choose Objects to display objects in the OBS bucket and then locate the external image file used to create an image. 40 // NOTE: 41 // The storage class of the OBS bucket must be Standard. 42 ImageUrl string `json:"image_url" required:"true"` 43 // Specifies the minimum size of the system disk in the unit of GB. 44 // 45 // This parameter is mandatory if an external image file in the OBS bucket is used to create an image. The value ranges from 1 GB to 1024 GB. 46 MinDisk int `json:"min_disk" required:"true"` 47 // Specifies whether automatic configuration is enabled. 48 // The value can be true or false. 49 50 // If automatic configuration is required, set the value to true. Otherwise, set the value to false The default value is false. 51 // For details about automatic configuration, see Creating a Linux System Disk Image from an External Image File > Registering an External Image File as a Private Image (Linux) in Image Management Service User Guide. 52 IsConfig bool `json:"is_config,omitempty"` 53 // Specifies the master key used for encrypting an image. For its value, see the Key Management Service User Guide. 54 CmkId string `json:"cmk_id,omitempty"` 55 // Specifies tags of the image. This parameter is left blank by default. 56 // Use either tags or image_tags. 57 Tags []string `json:"tags,omitempty"` 58 // Specifies tags of the image. This parameter is left blank by default. 59 // Use either tags or image_tags. 60 ImageTags []tags.ResourceTag `json:"image_tags,omitempty"` 61 // Specifies the maximum memory of the image in the unit of MB. 62 MaxRam int `json:"max_ram,omitempty"` 63 // Specifies the minimum memory of the image in the unit of MB. The default value is 0, indicating that the memory is not restricted. 64 MinRam int `json:"min_ram,omitempty"` 65 // Specifies the data disk information to be imported. 66 // An external image file can contain a maximum of three data disks. In this case, one system disk and three data disks will be created. 67 // NOTE: 68 // If a data disk image file is used to create a data disk image, the OS type of the data disk image must be the same as that of the system disk image. 69 // If other parameters (such as name, description, and tags) in Table 2 are set, the system uses the values in data_images. 70 DataImages []OBSDataImage `json:"data_images,omitempty"` 71 // Specifies whether to use the quick import method to import a system disk image. 72 // For details about the restrictions on quick import of image files, see Importing an Image File Quickly. 73 IsQuickImport bool `json:"is_quick_import,omitempty"` 74 // Specifies the image type. 75 // The value can be ECS, BMS, FusionCompute, or Ironic. The default value is ECS. 76 // ECS and FusionCompute: indicate an ECS image. 77 // BMS and Ironic: indicate a BMS image.the image type, the value can be ECS,BMS,FusionCompute, or Ironic 78 Type string `json:"type,omitempty"` 79 } 80 81 type OBSDataImage struct { 82 // Specifies the image name. 83 Name string `json:"name,omitempty"` 84 // Specifies the enterprise project that the image belongs to. The value is left blank by default. 85 // 86 // The value contains a maximum of 1024 characters and consists of only letters and digits. Carriage returns and angle brackets (< >) are not allowed. 87 Description string `json:"description,omitempty"` 88 // Specifies the URL of the external image file in the OBS bucket. 89 // 90 // The format is OBS bucket name:Image file name. 91 // 92 // To obtain an OBS bucket name: 93 // Log in to the management console and choose Storage > Object Storage Service. 94 // All OBS buckets are displayed in the list. 95 // 96 // Filter the OBS buckets by region and locate the target bucket in the current region. 97 // To obtain an OBS image file name: 98 // Log in to the management console and choose Storage > Object Storage Service. 99 // All OBS buckets are displayed in the list. 100 // 101 // Filter the OBS buckets by region and locate the target bucket in the current region. 102 // Click the name of the target bucket to go to the bucket details page. 103 // In the navigation pane on the left, choose Objects to display objects in the OBS bucket and then locate the external image file used to create an image. 104 // NOTE: 105 // The storage class of the OBS bucket must be Standard. 106 ImageUrl string `json:"image_url" required:"true"` 107 // Specifies the data disk ID. 108 VolumeId string `json:"volume_id"` 109 // Specifies the minimum size of the data disk. 110 // Unit: GB 111 // Value range: 1–2048 112 MinDisk int `json:"min_disk" required:"true"` 113 // Specifies whether an image file is imported quickly to create a data disk image. 114 IsQuickImport bool `json:"is_quick_import,omitempty"` 115 // Specifies tags of the image. This parameter is left blank by default. 116 // Use either tags or image_tags. 117 Tags []string `json:"tags,omitempty"` 118 // Specifies tags of the image. This parameter is left blank by default. 119 // Use either tags or image_tags. 120 ImageTags []tags.ResourceTag `json:"image_tags,omitempty"` 121 } 122 123 func CreateImageFromOBS(client *golangsdk.ServiceClient, opts CreateImageFromOBSOpts) (*string, error) { 124 b, err := build.RequestBody(opts, "") 125 if err != nil { 126 return nil, err 127 } 128 129 return cloudImages(client, b) 130 }