blob: cc3f6e2c75bda09dac43eeb77796e7e8fc2c0676 [file] [log] [blame]
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -07001package gophercloud
2
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -07003import (
4 "github.com/racker/perigee"
5)
6
7// See the CloudImagesProvider interface for details.
8func (gsp *genericServersProvider) ListImages() ([]Image, error) {
9 var is []Image
Samuel A. Falvo II9e64f6b2013-07-16 14:26:50 -070010 err := gsp.context.WithReauth(gsp.access, func() error {
11 url := gsp.endpoint + "/images"
12 return perigee.Get(url, perigee.Options{
13 CustomClient: gsp.context.httpClient,
14 Results: &struct{ Images *[]Image }{&is},
15 MoreHeaders: map[string]string{
16 "X-Auth-Token": gsp.access.AuthToken(),
17 },
18 })
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -070019 })
20 return is, err
21}
22
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -070023// ImageLink provides a reference to a image by either ID or by direct URL.
24// Some services use just the ID, others use just the URL.
25// This structure provides a common means of expressing both in a single field.
26type ImageLink struct {
27 Id string `json:"id"`
28 Links []Link `json:"links"`
29}
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -070030
31// Image is used for JSON (un)marshalling.
32// It provides a description of an OS image.
33//
34// The Id field contains the image's unique identifier.
35// For example, this identifier will be useful for specifying which operating system to install on a new server instance.
36//
37// The MinDisk and MinRam fields specify the minimum resources a server must provide to be able to install the image.
38//
39// The Name field provides a human-readable moniker for the OS image.
40//
41// The Progress and Status fields indicate image-creation status.
42// Any usable image will have 100% progress.
43//
44// The Updated field indicates the last time this image was changed.
45//
46// OsDcfDiskConfig indicates the server's boot volume configuration.
47// Valid values are:
48// AUTO
49// ----
50// The server is built with a single partition the size of the target flavor disk.
51// The file system is automatically adjusted to fit the entire partition.
52// This keeps things simple and automated.
53// AUTO is valid only for images and servers with a single partition that use the EXT3 file system.
54// This is the default setting for applicable Rackspace base images.
55//
56// MANUAL
57// ------
58// The server is built using whatever partition scheme and file system is in the source image.
59// If the target flavor disk is larger,
60// the remaining disk space is left unpartitioned.
61// This enables images to have non-EXT3 file systems, multiple partitions, and so on,
62// and enables you to manage the disk configuration.
63//
64type Image struct {
65 Created string `json:"created"`
66 Id string `json:"id"`
67 Links []Link `json:"links"`
68 MinDisk int `json:"minDisk"`
69 MinRam int `json:"minRam"`
70 Name string `json:"name"`
71 Progress int `json:"progress"`
72 Status string `json:"status"`
73 Updated string `json:"updated"`
74 OsDcfDiskConfig string `json:"OS-DCF:diskConfig"`
75}
76