datastore

package
v0.0.0-...-add28f9 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ceph

type Ceph struct {
	ImageTempDir string
	BlockDriver  storage.CephDriver
}

Ceph implements the DataStore interface for Ceph RBD based storage

func (*Ceph) Delete

func (c *Ceph) Delete(ID string) error

Delete removes an image from ceph after deleting the snapshot.

func (*Ceph) GetImageSize

func (c *Ceph) GetImageSize(ID string) (uint64, error)

GetImageSize returns the size, in bytes, of the block device

func (*Ceph) Write

func (c *Ceph) Write(ID string, body io.Reader) error

Write copies an image onto the fileystem into a tempory location and uploads it into ceph, snapshots.

type DataStore

type DataStore interface {
	Init(RawDataStore, MetaDataStore) error
	CreateImage(Image) error
	GetAllImages() ([]Image, error)
	GetImage(string) (Image, error)
	UpdateImage(Image) error
	DeleteImage(string) error
	UploadImage(string, io.Reader) error
}

DataStore is the image data storage interface.

type Image

type Image struct {
	ID         string
	State      State
	TenantID   string
	Name       string
	CreateTime time.Time
	Type       Type
	Size       uint64
}

Image contains the information that ciao will store about the image

func (Image) Visibility

func (i Image) Visibility() image.Visibility

Visibility returns the image visibility

type ImageMap

type ImageMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ImageMap provide Image empty struct generator and mutex control

func (*ImageMap) Add

func (i *ImageMap) Add(k string, v interface{}) error

Add adds a value to the map with the specified key

func (*ImageMap) Name

func (i *ImageMap) Name() string

Name provides the name of the map

func (*ImageMap) NewElement

func (i *ImageMap) NewElement() interface{}

NewElement generates a new Image struct

func (*ImageMap) NewTable

func (i *ImageMap) NewTable()

NewTable creates a new map

type ImageStore

type ImageStore struct {
	ImageMap
	// contains filtered or unexported fields
}

ImageStore is an image metadata cache.

func (*ImageStore) CreateImage

func (s *ImageStore) CreateImage(i Image) error

CreateImage will add an image to the datastore.

func (*ImageStore) DeleteImage

func (s *ImageStore) DeleteImage(ID string) error

DeleteImage will delete an existing image.

func (*ImageStore) GetAllImages

func (s *ImageStore) GetAllImages() ([]Image, error)

GetAllImages gets returns all the known images.

func (*ImageStore) GetImage

func (s *ImageStore) GetImage(ID string) (Image, error)

GetImage returns the image specified by the ID string.

func (*ImageStore) Init

func (s *ImageStore) Init(rawDs RawDataStore, metaDs MetaDataStore) error

Init initializes the datastore struct and must be called before anything.

func (*ImageStore) UpdateImage

func (s *ImageStore) UpdateImage(i Image) error

UpdateImage will modify an existing image.

func (*ImageStore) UploadImage

func (s *ImageStore) UploadImage(ID string, body io.Reader) error

UploadImage will read an image, save it and update the image cache.

type MetaDataStore

type MetaDataStore interface {
	Write(Image) error
	Delete(ID string) error
	Get(ID string) (Image, error)
	GetAll() ([]Image, error)
}

MetaDataStore is the metadata storing interface that's used by image cache implementation.

type MetaDs

type MetaDs struct {
	database.DbProvider
	DbDir  string
	DbFile string
}

MetaDs implements the DataStore interface for persistent data

func (*MetaDs) Delete

func (m *MetaDs) Delete(id string) error

Delete is the metadata delete implementation.

func (*MetaDs) Get

func (m *MetaDs) Get(ID string) (Image, error)

Get is the metadata get implementation.

func (*MetaDs) GetAll

func (m *MetaDs) GetAll() (images []Image, err error)

GetAll is the metadata get all images implementation.

func (*MetaDs) Write

func (m *MetaDs) Write(i Image) error

Write is the metadata write implementation.

type Noop

type Noop struct {
}

Noop is a Datastore implementation that does nothing. Use it only for development and testing purposes, data will not be persistent with the Noop Datastore interface.

func (*Noop) Delete

func (n *Noop) Delete(id string) error

Delete is the noop image metadata delete implementation. It drops data.

func (*Noop) Get

func (n *Noop) Get(id string) (Image, error)

Get is the noop image metadata get an image implementation. It drops data.

func (*Noop) GetAll

func (n *Noop) GetAll() ([]Image, error)

GetAll is the noop image metadata get all images implementation. It drops data.

func (*Noop) GetImageSize

func (n *Noop) GetImageSize(ID string) (uint64, error)

GetImageSize is the noop image implementation of image size querying

func (*Noop) Write

func (n *Noop) Write(i Image) error

Write is the noop image metadata write implementation. It drops data.

type Posix

type Posix struct {
	MountPoint string
}

Posix implements the DataStore interface for posix filesystems

func (*Posix) Delete

func (p *Posix) Delete(ID string) error

Delete removes an image from the posix filesystem

func (*Posix) GetImageSize

func (p *Posix) GetImageSize(ID string) (uint64, error)

GetImageSize obtains the image size from the underlying filesystem

func (*Posix) Write

func (p *Posix) Write(ID string, body io.Reader) (err error)

Write copies an image into the posix filesystem.

type RawDataStore

type RawDataStore interface {
	Write(ID string, body io.Reader) error
	Delete(ID string) error
	GetImageSize(ID string) (uint64, error)
}

RawDataStore is the raw data storage interface that's used by the image cache implementation.

type State

type State string

State represents the state of the image.

const (
	// Created means that an empty image has been created
	Created State = "created"

	// Saving means the image is being saved
	Saving State = "saving"

	// Active means that the image is created, uploaded and ready to use.
	Active State = "active"

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

func (State) Status

func (state State) Status() image.Status

Status translate an image state to an openstack image status.

type Type

type Type string

Type represents the valid image types.

const (
	// Raw is the raw image format.
	Raw Type = "raw"

	// QCow is the qcow2 format.
	QCow Type = "qcow2"

	// ISO is the iso format.
	ISO Type = "iso"
)

Jump to

Keyboard shortcuts

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