migration

package
v0.0.0-...-2608902 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportModel

func ExportModel(st StateExporter) ([]byte, error)

ExportModel creates a description.Model representation of the active model for StateExporter (typically a *state.State), and returns the serialized version. It provides the symmetric functionality to ImportModel.

func ImportModel

func ImportModel(st *state.State, bytes []byte) (*state.Model, *state.State, error)

ImportModel deserializes a model description from the bytes, transforms the model config based on information from the controller model, and then imports that as a new database model.

func Precheck

func Precheck(backend PrecheckBackend) error

Precheck checks the database state to make sure that the preconditions for model migration are met.

func UploadBinaries

func UploadBinaries(config UploadBinariesConfig) error

UploadBinaries will send binaries stored in the source blobstore to the target controller.

Types

type CharmUploader

type CharmUploader interface {
	UploadCharm(*charm.URL, io.ReadSeeker) (*charm.URL, error)
}

CharmUploader defines a simple single method interface that is used to upload a charm to the target controller

type PrecheckBackend

type PrecheckBackend interface {
	NeedsCleanup() (bool, error)
}

PrecheckBackend is implemented by *state.State but defined as an interface for easier testing.

type StateExporter

type StateExporter interface {
	// Export generates an abstract representation of a model.
	Export() (description.Model, error)
}

StateExporter describes interface on state required to export a model.

type ToolsUploader

type ToolsUploader interface {
	UploadTools(io.ReadSeeker, version.Binary, ...string) (tools.List, error)
}

ToolsUploader defines a simple single method interface that is used to upload tools to the target controller

type UploadBackend

type UploadBackend interface {
	Charm(*charm.URL) (*state.Charm, error)
	ModelUUID() string
	MongoSession() *mgo.Session
	ToolsStorage() (binarystorage.StorageCloser, error)
}

UploadBackend define the methods on *state.State that are needed for uploading the tools and charms from the current controller to a different controller.

type UploadBinariesConfig

type UploadBinariesConfig struct {
	State  UploadBackend
	Model  description.Model
	Target api.Connection

	GetCharmUploader func(api.Connection) CharmUploader
	GetToolsUploader func(api.Connection) ToolsUploader

	GetStateStorage     func(UploadBackend) storage.Storage
	GetCharmStoragePath func(UploadBackend, *charm.URL) (string, error)
}

UploadBinariesConfig provides all the configuration that the UploadBinaries function needs to operate. The functions are configurable for testing purposes. To construct the config with the default functions, use `NewUploadBinariesConfig`.

func NewUploadBinariesConfig

func NewUploadBinariesConfig(backend UploadBackend, model description.Model, target api.Connection) UploadBinariesConfig

NewUploadBinariesConfig constructs a `UploadBinariesConfig` with the default functions to get the uploaders for the target api connection, and functions used to get the charm data out of the database.

func (*UploadBinariesConfig) Validate

func (c *UploadBinariesConfig) Validate() error

Validate makes sure that all the config values are non-nil.

Jump to

Keyboard shortcuts

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