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