imagectl

package
v0.0.0-...-f8634c0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2016 License: MIT Imports: 17 Imported by: 0

README

imagectl - image manager for systemd-machined

imagectl is a image manager, built for managing machined's images (the /var/lib/machines directory).

Features

  • Seamless integration with systemd
  • machinectl start/stop and all other machine commands (but NOT image / image transfer commands)
  • systemctl start/stop/... systemd-nspawn@...service
  • Without any changes in machined and systemd-nspawn@.service.
  • Layered images (using overlayfs)
  • Instant creation of new images using existing ones as a base
  • Tagging

Usage

Usage: imagectl COMMAND [arg...]
       imagectl [ -h | --help | -v | --version ]

Image manager for systemd-machined.

Image Commands:
   new, create NAME [BASE_NAME]     Create a new image
        tag TAG NAME                Create an alias for the image
    ro, set-read-only NAME [BOOL]   Mark or unmark image read-only
        set-ready NAME [BOOL]       Assemble or disassemble layered image
    rm, remove NAME...              Remove an image
    ls, list                        Show available container and VM images

machinectl (list-images, read-only) and docker (images) image management command names are also supported.

Installation

$ mkdir imagectl-build
$ GOPATH=`pwd`/imagectl-build go get github.com/LEW21/siren/imagectl/cmd/imagectl

Imagectl will be compiled as a single static binary called imagectl, saved in the imagectl-build/bin/ directory. You can copy it wherever you want.

License

MIT license.

Requirements

  • Linux 4.0
  • NO btrfs on /var/lib/image-layers (Non-empty directory removal is bugged on overlayfs over btrfs. Use a good fs instead - eg. ext4.)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoolValues = map[string]bool{
	"1":     true,
	"y":     true,
	"yes":   true,
	"true":  true,
	"Y":     true,
	"YES":   true,
	"TRUE":  true,
	"0":     false,
	"n":     false,
	"no":    false,
	"false": false,
	"N":     false,
	"NO":    false,
	"FALSE": false,
}
View Source
var CmdCreate = Command{[]string{"new"}, "create", []string{"NAME"}, []string{"BASE_NAME"}, "Create a new image", cmdCreate}
View Source
var CmdList = Command{[]string{"ls", "list-images", "images"}, "list", nil, nil, "Show available container and VM images", cmdList}

machinectl list-images / docker images

View Source
var CmdRebase = Command{nil, "rebase", []string{"NAME", "NEW_BASE"}, nil, "Change the base image of an image", cmdRebase}
View Source
var CmdRemove = Command{[]string{"rm"}, "remove", []string{"NAME..."}, nil, "Remove an image", cmdRemove}
View Source
var CmdSetReadOnly = Command{[]string{"ro", "read-only"}, "set-read-only", []string{"NAME"}, []string{"BOOL"}, "Mark or unmark image read-only", cmdSetReadOnly}
View Source
var CmdSetReady = Command{nil, "set-ready", []string{"NAME"}, []string{"BOOL"}, "Assemble or disassemble layered image", cmdSetReady}
View Source
var CmdTag = Command{nil, "tag", []string{"TAG", "NAME"}, nil, "Create an alias for the image", cmdTag}
View Source
var ErrBaseDoesNotExist = errors.New("base image does not exist") // for CreateImage()
View Source
var ErrBaseWritable = errors.New("base image is writable") // for CreateImage()
View Source
var ErrImageAlive = errors.New("image is alive") // for hard actions
View Source
var ErrImageExists = errors.New("image already exists") // for CreateImage()
View Source
var ErrImpossible = errors.New("impossible") // for SetReady(true)
View Source
var ErrNoSuchImage = errors.New("org.freedesktop.machine1.NoSuchImage") // for GetImage() and Update
View Source
var ErrNotATag = errors.New("not a tag")

Functions

func ImageCommand

func ImageCommand(i Image, name string, arg ...string) *exec.Cmd

func ImageRealPath

func ImageRealPath(i Image, path string) string

func IsImageAlive

func IsImageAlive(md *machine1.Conn, name string) (bool, error)

func PrintHelp

func PrintHelp(desc string, commandGroups []CommandGroup)

func PrintInvalidCommand

func PrintInvalidCommand(name string)

func ReadTag

func ReadTag(tag string) (target string, err error)

func RunCommand

func RunCommand(args []string, commandGroups []CommandGroup) int

func Tag

func Tag(tag string, image Image) error

func UnTag

func UnTag(tag string) (target string, err error)

Types

type Column

type Column struct {
	Name string
	Get  func(interface{}) (string, color.Attribute)
}

type Command

type Command struct {
	Shortcuts   []string
	Name        string
	ReqArgs     []string
	OptArgs     []string
	Description string
	Executor    func(args []string) int
}

func (Command) ArgsDescription

func (c Command) ArgsDescription() string

func (Command) CheckArgs

func (c Command) CheckArgs(args []string) bool

func (Command) Run

func (c Command) Run(args []string) int

type CommandGroup

type CommandGroup struct {
	Name     string
	Commands []Command
}

type Image

type Image interface {
	// org.freedesktop.machine1.Image properties (subset)
	Name() string
	Path() string
	Type() string
	ReadOnly() bool

	// Custom properties
	Ready() bool // Is ready to use? (In case of layered images: is it mounted?)
	Alive() bool // Is our image used as a machined's container?

	// Soft actions
	Update() error // Reload all properties

	// Hard actions
	Remove() error
	SetReadOnly(bool) error
	SetReady(bool) error
	Optimize(statusCb func(string), errorCb func(error))

	// Utilities
	RealPath(path string) string
	Command(name string, arg ...string) *exec.Cmd
}

type ImageCtl

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

func New

func New() (*ImageCtl, error)

func (*ImageCtl) CreateImage

func (ictl *ImageCtl) CreateImage(name string, base Image) (Image, error)

func (*ImageCtl) GetImage

func (ictl *ImageCtl) GetImage(name string) (Image, error)

func (*ImageCtl) ListImages

func (ictl *ImageCtl) ListImages() ([]Image, error)

type ImageGetter

type ImageGetter func(string) (Image, error)

type LayeredImage

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

func (*LayeredImage) Alive

func (i *LayeredImage) Alive() bool

func (LayeredImage) BaseLayers

func (i LayeredImage) BaseLayers() []string

func (*LayeredImage) Command

func (i *LayeredImage) Command(name string, arg ...string) *exec.Cmd

func (LayeredImage) LayerFSRoot

func (i LayeredImage) LayerFSRoot() string

func (LayeredImage) LayerPath

func (i LayeredImage) LayerPath(path string) string

func (LayeredImage) LayerRoot

func (i LayeredImage) LayerRoot() string

func (*LayeredImage) Name

func (i *LayeredImage) Name() string

func (*LayeredImage) Optimize

func (i *LayeredImage) Optimize(statusCb func(string), errorCb func(error))

func (*LayeredImage) Path

func (i *LayeredImage) Path() string

func (*LayeredImage) ReadOnly

func (i *LayeredImage) ReadOnly() bool

func (*LayeredImage) Ready

func (i *LayeredImage) Ready() bool

func (*LayeredImage) RealPath

func (i *LayeredImage) RealPath(path string) string

func (*LayeredImage) Rebase

func (i *LayeredImage) Rebase(newBase Image) error

func (*LayeredImage) Remove

func (i *LayeredImage) Remove() error

func (*LayeredImage) SetReadOnly

func (i *LayeredImage) SetReadOnly(readOnly bool) error

func (*LayeredImage) SetReady

func (i *LayeredImage) SetReady(ready bool) error

func (*LayeredImage) Type

func (i *LayeredImage) Type() string

func (*LayeredImage) Update

func (i *LayeredImage) Update() error

type LayeredImageCtl

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

func NewLayeredImageCtl

func NewLayeredImageCtl(md *machine1.Conn, getAnyImage ImageGetter) (LayeredImageCtl, error)

func (LayeredImageCtl) CreateImage

func (lictl LayeredImageCtl) CreateImage(name string, base Image) (LayeredImage, error)

func (LayeredImageCtl) GetImage

func (lictl LayeredImageCtl) GetImage(name string) (LayeredImage, error)

func (LayeredImageCtl) ListImages

func (lictl LayeredImageCtl) ListImages() ([]LayeredImage, error)

type MachineCtl

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

func NewMachineCtl

func NewMachineCtl() (MachineCtl, error)

func (MachineCtl) CreateImage

func (mctl MachineCtl) CreateImage(name string, base Image) (MdImage, error)

func (MachineCtl) GetImage

func (mctl MachineCtl) GetImage(name string) (MdImage, error)

func (MachineCtl) ListImages

func (mctl MachineCtl) ListImages() ([]MdImage, error)

type MdImage

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

func (*MdImage) Alive

func (i *MdImage) Alive() bool

func (*MdImage) Command

func (i *MdImage) Command(name string, arg ...string) *exec.Cmd

func (*MdImage) Name

func (i *MdImage) Name() string

func (*MdImage) Optimize

func (i *MdImage) Optimize(statusCb func(string), errorCb func(error))

func (*MdImage) Path

func (i *MdImage) Path() string

func (*MdImage) ReadOnly

func (i *MdImage) ReadOnly() bool

func (*MdImage) Ready

func (i *MdImage) Ready() bool

func (*MdImage) RealPath

func (i *MdImage) RealPath(path string) string

func (*MdImage) Remove

func (i *MdImage) Remove() error

func (*MdImage) SetReadOnly

func (i *MdImage) SetReadOnly(readOnly bool) error

func (*MdImage) SetReady

func (i *MdImage) SetReady(ready bool) error

func (*MdImage) Type

func (i *MdImage) Type() string

func (*MdImage) Update

func (i *MdImage) Update() error

type StdImage

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

func (*StdImage) Alive

func (i *StdImage) Alive() bool

func (*StdImage) Command

func (i *StdImage) Command(name string, arg ...string) *exec.Cmd

func (*StdImage) Name

func (i *StdImage) Name() string

func (*StdImage) Optimize

func (i *StdImage) Optimize(statusCb func(string), errorCb func(error))

func (*StdImage) Path

func (i *StdImage) Path() string

func (*StdImage) ReadOnly

func (i *StdImage) ReadOnly() bool

func (*StdImage) Ready

func (i *StdImage) Ready() bool

func (*StdImage) RealPath

func (i *StdImage) RealPath(path string) string

func (*StdImage) Remove

func (i *StdImage) Remove() error

func (*StdImage) SetReadOnly

func (i *StdImage) SetReadOnly(readOnly bool) error

func (*StdImage) SetReady

func (i *StdImage) SetReady(ready bool) error

func (*StdImage) Type

func (i *StdImage) Type() string

func (*StdImage) Update

func (i *StdImage) Update() error

Directories

Path Synopsis
cmd
Integration with the systemd machined API.
Integration with the systemd machined API.

Jump to

Keyboard shortcuts

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