image

package
v0.0.0-...-476269e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const APIPort = 9292

APIPort is the standard OpenStack Image port

Variables

View Source
var (
	// ErrNoImage is returned when an image is not found.
	ErrNoImage = errors.New("Image not found")

	// ErrImageSaving is returned when an image is being uploaded.
	ErrImageSaving = errors.New("Image being uploaded")

	// ErrBadUUID is returned when an invalid UUID is specified
	ErrBadUUID = errors.New("Bad UUID")

	// ErrAlreadyExists is returned when an attempt is made to add
	// an image with a UUID that already exists.
	ErrAlreadyExists = errors.New("Already Exists")

	// ErrDecodeImage is returned when there was an error on image decoding
	ErrDecodeImage = errors.New("Error on Image decode")

	// ErrForbiddenAccess is returned for only-privileged image operations
	ErrForbiddenAccess = errors.New("Forbidden Access")

	// ErrQuota is returned when the tenant exceeds its quota
	ErrQuota = errors.New("Tenant over quota")
)

Functions

func Routes

func Routes(config APIConfig, serviceClient *gophercloud.ServiceClient) *mux.Router

Routes provides gorilla mux routes for the supported endpoints.

Types

type APIConfig

type APIConfig struct {
	Port         int     // the https port of the block api service
	ImageService Service // the service interface
}

APIConfig contains information needed to start the block api service.

type APIHandler

type APIHandler struct {
	*Context
	Handler func(*Context, http.ResponseWriter, *http.Request) (APIResponse, error)
}

APIHandler is a custom handler for the image APIs. This custom handler allows us to more cleanly return an error and response, and pass some package level context into the handler.

func (APIHandler) ServeHTTP

func (h APIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP satisfies the http Handler interface. It wraps our api response in json as well.

type APIResponse

type APIResponse struct {
	// contains filtered or unexported fields
}

APIResponse is returned from the API handlers.

type ContainerFormat

type ContainerFormat string

ContainerFormat defines the acceptable container format strings.

const (
	// Bare is the only format we support right now.
	Bare ContainerFormat = "bare"
)

type Context

type Context struct {
	Service
	*gophercloud.ServiceClient
	// contains filtered or unexported fields
}

Context contains data and interfaces that the image api will need. TBD: do we really need this, or is just a service interface sufficient?

type CreateImageRequest

type CreateImageRequest struct {
	Name            string          `json:"name,omitempty"`
	ID              string          `json:"id,omitempty"`
	Visibility      Visibility      `json:"visibility,omitempty"`
	Tags            []string        `json:"tags,omitempty"`
	ContainerFormat ContainerFormat `json:"container_format,omitempty"`
	DiskFormat      DiskFormat      `json:"disk_format,omitempty"`
	MinDisk         int             `json:"min_disk,omitempty"`
	MinRAM          int             `json:"min_ram,omitempty"`
	Protected       bool            `json:"protected,omitempty"`
	Properties      interface{}     `json:"properties,omitempty"`
}

CreateImageRequest contains information for a create image request. http://developer.openstack.org/api-ref/image/v2/index.html#create-an-image

type DefaultResponse

type DefaultResponse struct {
	Status          Status           `json:"status"`
	ContainerFormat *ContainerFormat `json:"container_format"`
	MinRAM          *int             `json:"min_ram"`
	UpdatedAt       *time.Time       `json:"updated_at,omitempty"`
	Owner           *string          `json:"owner"`
	MinDisk         *int             `json:"min_disk"`
	Tags            []string         `json:"tags"`
	Locations       []string         `json:"locations"`
	Visibility      Visibility       `json:"visibility"`
	ID              string           `json:"id"`
	Size            *int             `json:"size"`
	VirtualSize     *int             `json:"virtual_size"`
	Name            *string          `json:"name"`
	CheckSum        *string          `json:"checksum"`
	CreatedAt       time.Time        `json:"created_at"`
	DiskFormat      DiskFormat       `json:"disk_format"`
	Properties      interface{}      `json:"properties"`
	Protected       bool             `json:"protected"`
	Self            string           `json:"self"`
	File            string           `json:"file"`
	Schema          string           `json:"schema"`
}

DefaultResponse contains information about an image http://developer.openstack.org/api-ref/image/v2/index.html#create-an-image

type DiskFormat

type DiskFormat string

DiskFormat defines the valid values for the disk_format string

const (
	// Raw
	Raw DiskFormat = "raw"

	// QCow
	QCow DiskFormat = "qcow2"

	// ISO
	ISO DiskFormat = "iso"
)

we support the following disk formats

type ErrorImage

type ErrorImage error

ErrorImage defines all possible image handling errors

type InternalImage

type InternalImage string

InternalImage defines the types of CIAO internal images (e.g. cnci)

const (
	// CNCI is the type of image for CIAO per-tenant networking managenent
	CNCI InternalImage = "cnci"
)
type Link struct {
	Href string `json:"href"`
	Type string `json:"type,omitempty"`
	Rel  string `json:"rel,omitempty"`
}

Link is used by the API to create the link json strings.

type ListImagesResponse

type ListImagesResponse struct {
	Images []DefaultResponse `json:"images"`
	Schema string            `json:"schema"`
	First  string            `json:"first"`
}

ListImagesResponse contains the list of all images that have been created. http://developer.openstack.org/api-ref/image/v2/index.html#show-images

type NoContentImageResponse

type NoContentImageResponse struct {
	ImageID string `json:"image_id"`
}

NoContentImageResponse contains the UUID of the image which content got uploaded or deleted http://developer.openstack.org/api-ref/image/v2/index.html#upload-binary-image-data

type Service

type Service interface {
	CreateImage(string, CreateImageRequest) (DefaultResponse, error)
	UploadImage(string, string, io.Reader) (NoContentImageResponse, error)
	ListImages(string) ([]DefaultResponse, error)
	GetImage(string, string) (DefaultResponse, error)
	DeleteImage(string, string) (NoContentImageResponse, error)
}

Service is the interface that the api requires in order to get information needed to implement the image endpoints.

type Status

type Status string

Status defines the possible states for an image

const (
	// Queued means that the image service reserved an image ID
	// for the image but did not yet upload any image data.
	Queued Status = "queued"

	// Saving means that the image service is currently uploading
	// the raw data for the image.
	Saving Status = "saving"

	// Active means that the image is active and fully available
	// in the image service.
	Active Status = "active"

	// Killed means that an image data upload error occurred.
	Killed Status = "killed"

	// Deleted means that the image service retains information
	// about the image but the image is no longer available for use.
	Deleted Status = "deleted"

	// PendingDelete is similar to the deleted status.
	// An image in this state is not recoverable.
	PendingDelete Status = "pending_delete"
)

type Version

type Version struct {
	Status VersionStatus `json:"status"`
	ID     string        `json:"id"`
	Links  []Link        `json:"links"`
}

Version is used by the API to create the version json strings

type VersionStatus

type VersionStatus string

VersionStatus defines whether a reported version is supported or not.

const (
	// Deprecated indicates the api deprecates the spec version.
	Deprecated VersionStatus = "DEPRECATED"

	// Supported indicates a spec version is supported by the api
	Supported VersionStatus = "SUPPORTED"

	// Current indicates the current spec version of the api
	// TBD: can this be eliminated? do we need both supported & current?
	Current VersionStatus = "CURRENT"
)

type Versions

type Versions struct {
	Versions []Version `json:"versions"`
}

Versions creates multiple version json strings

type Visibility

type Visibility string

Visibility defines whether an image is per tenant or public.

const (
	// Public indicates that the image can be used by anyone.
	Public Visibility = "public"

	// Private indicates that the image is only available to a tenant.
	Private Visibility = "private"

	// Internal indicates that an image is only for Ciao internal usage.
	Internal Visibility = "internal"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL