Help Center > > Developer Guide> Go> IMS Go SDK User Guide

IMS Go SDK User Guide

Updated at: Apr 04, 2019 GMT+08:00

Service Client

To interact with OpenStack APIs, transfer the identity credentials to the provider. After that, if you want to retrieve any information about the image service, you need to make a call to NewImageServiceV2 to create an image service client and then use required SDKs.

client, err := openstack.NewImageServiceV2(provider, gophercloud.EndpointOpts{
 Region: "RegionName",


An image is the OS of a VM and it is a series of files used to create or rebuild servers. By default, the carrier provides preset OS images, but you can also create customized images from the ECSs.

Create an image.

You can use Create to create an image.

import (    ""   ) 

func TestImagesCreateDestroyEmptyImage(t *testing.T) {
    protected := false
    visibility := images.ImageVisibilityPrivate
    createOpts := &images.CreateOpts{
           Name:            name,
           ContainerFormat:   "bare",
           DiskFormat:      "vhd",
           MinDisk:         40,
           MinRAM:          1024,
           Protected:       &protected,
           Visibility:      &visibility,
           Tags:            []string{"test","adsfi"},
           Properties: map[string]string{
                  "architecture": "x86_64",
    image, err := images.Create(client, createOpts).Extract()

Update an image.

func TestImagesUpdate(t *testing.T) {
    updateOpts := images.UpdateOpts{
               NewName: "alternateName",
    image, err := images.Update(client, "imageupdate_id", updateOpts).Extract()

List images.

func TestImagesListALL(t *testing.T) {
    listOpts := images.ListOpts{
         Visibility: images.ImageVisibilityPublic,
         Owner:      "owner_id",
         Status:     "active",
         Marker:    "marker_id",
         SortKey:    "name",
         SortDir:    "asc",

    // Retrieve a pager (i.e. a paginated collection)
    allPages, err := images.List(client, listOpts).AllPages()

    // Define an anonymous function to be executed on each page's iteration
    allImages, err := images.ExtractImages(allPages)

    for _, image := range allImages {
    // " image " will be a images.Image

Get details about a specific image.

func TestImagesGet(t *testing.T) {
    image, err := images.Get(client, "image_id").Extract()

Delete an image.

func DeleteImage(t *testing.T, client *gophercloud.ServiceClient, image *images.Image) {
    err := images.Delete(client, "image_id").ExtractErr()

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?

Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel