Documentation ¶
Index ¶
- Constants
- Variables
- func Routes(config APIConfig) *mux.Router
- type APIConfig
- type APIHandler
- type APIResponse
- type AbsoluteLimits
- type Attachment
- type Choice
- type Choices
- type Context
- type Limit
- type Limits
- type Link
- type ListVolume
- type ListVolumes
- type ListVolumesDetail
- type MediaType
- type MetaData
- type RequestedVolume
- type Service
- type ShowVolumeDetails
- type Version
- type VersionStatus
- type Versions
- type Volume
- type VolumeCreateRequest
- type VolumeDetail
- type VolumeResponse
- type VolumeStatus
Constants ¶
const APIPort = 8776
APIPort is the standard OpenStack Volume port
const ( // ReplicationDisabled indicates that replication is not enabled. ReplicationDisabled string = "disabled" )
Variables ¶
var ( ErrQuota = errors.New("Tenant over quota") ErrTenantNotFound = errors.New("Tenant not found") ErrVolumeNotFound = errors.New("Volume not found") ErrInstanceNotFound = errors.New("Instance not found") ErrVolumeNotAvailable = errors.New("Volume not available") ErrVolumeOwner = errors.New("You are not volume owner") ErrInstanceOwner = errors.New("You are not instance owner") ErrInstanceNotAvailable = errors.New("Instance not available") ErrVolumeNotAttached = errors.New("Volume not attached") )
These errors can be returned by the Service interface
Functions ¶
Types ¶
type APIConfig ¶
type APIConfig struct { Port int // the https port of the block api service VolService 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 block 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 AbsoluteLimits ¶
type AbsoluteLimits struct { TotalSnapshotsUsed int `json:"totalSnapshotsUsed"` MaxTotalBackups int `json:"maxTotalBackups"` MaxTotalVolumeGigabytes int `json:"maxTotalVolumeGigabytes"` MaxTotalSnapshots int `json:"maxTotalSnapshots"` MaxTotalBackupGigabytes int `json:"maxTotalBackupGigabytes"` TotalBackupGigabytesUsed int `json:"totalBackupGigabytesUsed"` MaxTotalVolumes int `json:"maxTotalVolumes"` TotalVolumesUsed int `json:"totalVolumesUsed"` TotalBackupsUsed int `json:"totalBackupsUsed"` TotalGigabytesUsed int `json:"totalGigabytesUsed"` }
AbsoluteLimits implements the block api absolute limits object. http://developer.openstack.org/api-ref-blockstorage-v2.html#showAbsoluteLimits Note that an absolute limit value of -1 indicates that the limit is infinite.
type Attachment ¶
type Attachment struct { ServerUUID string `json:"server_id"` AttachmentUUID string `json:"attachment_id"` HostName *string `json:"host_name"` VolumeUUID string `json:"volume_id"` Device string `json:"device"` DeviceUUID string `json:"id"` }
Attachment contains instance attachment information. If this volume is attached to a server, the attachment contains information about the attachment.
type Choice ¶
type Choice struct { Status VersionStatus `json:"status"` MediaTypes []MediaType `json:"media-types"` ID string `json:"id"` Links []Link `json:"links"` }
Choice is used to indicate the api choices that are supported.
type Choices ¶
type Choices struct {
Choices []Choice `json:"choices"`
}
Choices is used to create the choices json strings.
type Context ¶
type Context struct { Service // contains filtered or unexported fields }
Context contains data and interfaces that the block api will need. TBD: do we really need this, or is just a service interface sufficient?
type Limit ¶
type Limit struct { Rate []string `json:"rate"` Absolute AbsoluteLimits `json:"absolute"` }
Limit implements the limit object. http://developer.openstack.org/api-ref-blockstorage-v2.html#showAbsoluteLimits
type Limits ¶
type Limits struct {
Limits Limit `json:"limits"`
}
Limits implements the limits object. http://developer.openstack.org/api-ref-blockstorage-v2.html#showAbsoluteLimits
type Link ¶
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 ListVolume ¶
type ListVolume struct { ID string `json:"id"` Links []Link `json:"links"` Name string `json:"name"` }
ListVolume is the contains volume information for the listVolume endpoint. http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumes
type ListVolumes ¶
type ListVolumes struct {
Volumes []ListVolume `json:"volumes"`
}
ListVolumes is the json response for the listVolume endpoint. http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumes
type ListVolumesDetail ¶
type ListVolumesDetail struct {
Volumes []VolumeDetail `json:"volumes"`
}
ListVolumesDetail is the json response for the listVolumeDetails endpoint. http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumesDetail
type MetaData ¶
type MetaData interface{}
MetaData is defined as a set of arbitrary key value structs.
type RequestedVolume ¶
type RequestedVolume struct { Size int `json:"size"` AvailabilityZone string `json:"availability_zone"` SourceVolID *string `json:"source_volid"` Description *string `json:"description"` MultiAttach bool `json:"multiattach"` SnapshotID *string `json:"snapshot_id"` Name *string `json:"name"` ImageRef *string `json:"imageRef"` VolumeType *string `json:"volume_type"` MetaData MetaData `json:"metadata"` SourceReplica *string `json:"source_replica"` ConsistencyGroupID *string `json:"consistencygroup_id"` }
RequestedVolume contains information about a volume to be created. http://developer.openstack.org/api-ref-blockstorage-v2.html#createVolume
type Service ¶
type Service interface { GetAbsoluteLimits(tenant string) (AbsoluteLimits, error) CreateVolume(tenant string, req RequestedVolume) (Volume, error) DeleteVolume(tenant string, volume string) error AttachVolume(tenant string, volume string, instance string, mountpoint string) error DetachVolume(tenant string, volume string, attachment string) error ListVolumes(tenant string) ([]ListVolume, error) ListVolumesDetail(tenant string) ([]VolumeDetail, error) ShowVolumeDetails(tenant string, volume string) (VolumeDetail, error) }
Service contains the required interface to the block service. The caller who is starting the api service needs to provide this interface.
type ShowVolumeDetails ¶
type ShowVolumeDetails struct {
Volume VolumeDetail `json:"volume"`
}
ShowVolumeDetails is the json response for the showVolumeDetail endpoint. http://developer.openstack.org/api-ref-blockstorage-v2.html#showVolume
type Version ¶
type Version struct { Status VersionStatus `json:"status"` Updated string `json:"updated"` Links []Link `json:"links"` MinVersion string `json:"min_version"` Version string `json:"version"` MediaTypes []MediaType `json:"media-types"` ID string `json:"id"` }
Version contains information about the api version that is supported.
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 is used to create the version api strings.
type Volume ¶
type Volume struct { Status VolumeStatus `json:"status"` MigrationStatus *string `json:"migration_status"` UserID string `json:"user_id"` Attachments []Attachment `json:"attachments"` Links []Link `json:"links"` AvailabilityZone *string `json:"availability_zone"` Bootable string `json:"bootable"` Encrypted bool `json:"encrypted"` CreatedAt *time.Time `json:"created_at"` Description *string `json:"description"` UpdatedAt *time.Time `json:"updated_at"` VolumeType *string `json:"volume_type"` Name *string `json:"name"` ReplicationStatus string `json:"replication_status"` ConsistencyGroupID *string `json:"consistencygroup_id"` SourceVolID *string `json:"source_volid"` SnapshotID *string `json:"snapshot_id"` MultiAttach bool `json:"multiattach"` MetaData MetaData `json:"metadata"` ID string `json:"id"` Size int `json:"size"` }
Volume contains information about a volume that has been created or updated. http://developer.openstack.org/api-ref-blockstorage-v2.html#createVolume http://developer.openstack.org/api-ref-blockstorage-v2.html#updateVolume
type VolumeCreateRequest ¶
type VolumeCreateRequest struct {
Volume RequestedVolume `json:"volume"`
}
VolumeCreateRequest is the json request for the createVolume endpoint. http://developer.openstack.org/api-ref-blockstorage-v2.html#createVolume
type VolumeDetail ¶
type VolumeDetail struct { MigrationStatus *string `json:"migration_status"` Attachments []Attachment `json:"attachments"` Links []Link `json:"links"` AvailabilityZone *string `json:"availability_zone"` OSVolHostAttr string `json:"os-vol-host-attr:host"` Encrypted bool `json:"encrypted"` UpdatedAt *time.Time `json:"updated_at"` OSVolReplicationExStatus string `json:"os-volume-replication:extended_status,omitempty"` ReplicationStatus string `json:"replication_status"` SnapshotID *string `json:"snapshot_id"` ID string `json:"id"` Size int `json:"size"` UserID string `json:"user_id"` OSVolTenantAttr string `json:"os-vol-tenant-attr:tenant_id"` OSVolMigStatusAttrStatus *string `json:"os-vol-mig-status-attr:migstat"` MetaData MetaData `json:"metadata"` Status VolumeStatus `json:"status"` Description *string `json:"description"` MultiAttach bool `json:"multiattach"` OSVolReplicationDriver string `json:"os-volume-replication:driver_data,omitempty"` SourceVolID *string `json:"source_volid"` ConsistencyGroupID *string `json:"consistencygroup_id"` OSVolMigStatusAttrNameID *string `json:"os-vol-mig-status-attr:name_id"` Name *string `json:"name"` Bootable string `json:"bootable"` CreatedAt *time.Time `json:"created_at"` VolumeType *string `json:"volume_type"` }
VolumeDetail contains volume information for the listVolumeDetails endpoint. http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumesDetail
type VolumeResponse ¶
type VolumeResponse struct {
Volume Volume `json:"volume"`
}
VolumeResponse is the json response for the createVolume, and updateVolume endpoint. http://developer.openstack.org/api-ref-blockstorage-v2.html#createVolume http://developer.openstack.org/api-ref-blockstorage-v2.html#updateVolume
type VolumeStatus ¶
type VolumeStatus string
VolumeStatus is the status of create, list, update, or delete volumes. http://developer.openstack.org/api-ref-blockstorage-v2.html#volumes-v2-volumes
const ( // Creating indicates that a volume is being created. Creating VolumeStatus = "creating" // Available indicates that a volume is ready to be used. Available VolumeStatus = "available" // Attaching indicates that a volume is being attached. Attaching VolumeStatus = "attaching" // InUse indicates that a volume is attached to an instance. InUse VolumeStatus = "in-use" // Deleting indicates that a volume is being deleted. Deleting VolumeStatus = "deleting" // Error indicates that a volume creation error occurred. Error VolumeStatus = "error" // ErrorDeleting indicates that a volume deletion error occurred. ErrorDeleting VolumeStatus = "error_deleting" // BackingUp indicates that the volume is being backed up. BackingUp VolumeStatus = "backing-up" // RestoringBackup indicates that a backup is being restored // to the volume. RestoringBackup VolumeStatus = "restoring-backup" // ErrorRestoring indicates that a backup restoration error occurred. ErrorRestoring VolumeStatus = "error_restoring" // ErrorExtending indicates that an error occurred // while attempting to extend a volume. ErrorExtending VolumeStatus = "error_extending" )