util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2018 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NBD_REQUEST_MAGIC = 0x25609513
	NBD_REPLY_MAGIC   = 0x67446698
)
View Source
const (
	NBD_CMD_READ  = 0
	NBD_CMD_WRITE = 1
	NBD_CMD_DISC  = 2
	NBD_CMD_FLUSH = 3
	NBD_CMD_TRIM  = 4
)
View Source
const (
	NBD_FLAG_HAS_FLAGS  = (1 << 0)
	NBD_FLAG_SEND_FLUSH = (1 << 2)
)
View Source
const (
	DefaultRepositoryUrl = "https://mikelangelo-capstan.s3.amazonaws.com/"
)

Variables

This section is empty.

Functions

func ConfigDir added in v0.2.0

func ConfigDir() string

func Connect

func Connect(network, path string) (net.Conn, error)

func ConnectAndWait

func ConnectAndWait(network, path string) (net.Conn, error)

func ConvertImageToQCOW2 added in v0.2.0

func ConvertImageToQCOW2(imagePath string) error

func CopyFile

func CopyFile(src, dst string) *exec.Cmd

func CopyLocalFile added in v0.2.0

func CopyLocalFile(dst, src string) error

func ExtendMap added in v0.3.0

func ExtendMap(m map[string]string, additional map[string]string)

func FileInfoHeader

func FileInfoHeader() string

func GenerateMAC added in v0.1.3

func GenerateMAC() (net.HardwareAddr, error)

Generate a MAC address.

func HomePath

func HomePath() string

func ID

func ID() string

func IsDirectIOSupported added in v0.1.3

func IsDirectIOSupported(path string) bool

func IsRemoteImage

func IsRemoteImage(repo_url, name string) (bool, error)

func IsRemotePackage added in v0.2.0

func IsRemotePackage(repo_url, name string) (bool, error)

IsRemotePackage checks that the given package is available in the remote repository. In order to confirm the package really exists, both manifest and the actual package content must exist in remote repository.

func ListImagesRemote

func ListImagesRemote(repo_url string, search string) error

func ListPackagesRemote added in v0.2.0

func ListPackagesRemote(repo_url string, search string) error

func NeedsUpdate added in v0.3.0

func NeedsUpdate(localPkg, remotePkg *core.Package, compareCreated bool) (bool, error)

func ParseEnvironmentList added in v0.2.1

func ParseEnvironmentList(envList []string) (map[string]string, error)

func ParseMemSize

func ParseMemSize(memory string) (int64, error)

func RawTerm

func RawTerm() error

func RemotePackageInfo added in v0.2.0

func RemotePackageInfo(repo_url string, path string) *core.Package

RemotePackageInfo downloads the given manifest files and tries to parse it. core.Package struct is returned if it succeeds, otherwise nil.

func RemoveOrphanedInstances added in v0.2.0

func RemoveOrphanedInstances(verbose bool) error

RemoveOrphanedInstances removes directories of instances that were not persisted with --persist.

func ResetTerm

func ResetTerm()

func ResizeImage added in v0.2.0

func ResizeImage(imagePath string, targetSize uint64) error

func SearchInstance

func SearchInstance(name string) (instanceName, instancePlatform string)

func SetCmdLine added in v0.2.0

func SetCmdLine(imagePath string, cmdLine string) error

func SetPartition added in v0.2.0

func SetPartition(image string, partition int, start uint64, size uint64) error

func StringInSlice added in v0.3.0

func StringInSlice(a string, list []string) bool

func VersionStringToInt added in v0.3.0

func VersionStringToInt(version string) (int, error)

VersionStringToInt converts 1.2.3 into 1002003 to make it comparable.

Types

type CapstanSettings added in v0.2.0

type CapstanSettings struct {
	RepoUrl     string `yaml:"repo_url"`
	DisableKvm  bool   `yaml:"disable_kvm"`
	QemuAioType string `yaml:"qemu_aio_type"`
}

type Contents

type Contents struct {
	Key          string
	LastModified string
	Size         int
	StorageClass string
}

type FileInfo

type FileInfo struct {
	Namespace   string
	Name        string
	Description string
	Version     string
	Created     core.YamlTime `yaml:"created"`
	Platform    string
}

func ParseIndexYaml added in v0.3.0

func ParseIndexYaml(path, ns, name string) (*FileInfo, error)

func RemoteFileInfo

func RemoteFileInfo(repo_url string, path string) *FileInfo

func (*FileInfo) String

func (f *FileInfo) String() string

type FilesInfo

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

type ImageInfo added in v0.1.3

type ImageInfo struct {
	FormatVersion string `yaml:"format_version"`
	Version       string
	Created       string
	Description   string
	Build         string
}

type NbdFile added in v0.2.0

type NbdFile struct {
	Cmd     *exec.Cmd
	Session *NbdSession
}

func NewNbdFile added in v0.2.0

func NewNbdFile(imagePath string) (*NbdFile, error)

func (*NbdFile) Close added in v0.2.0

func (file *NbdFile) Close() error

func (*NbdFile) Wait added in v0.2.0

func (file *NbdFile) Wait()

func (*NbdFile) Write added in v0.2.0

func (file *NbdFile) Write(offset uint64, data []byte) error

func (*NbdFile) WriteByte added in v0.2.0

func (file *NbdFile) WriteByte(offset uint64, b byte) error

func (*NbdFile) WriteInt added in v0.2.0

func (file *NbdFile) WriteInt(offset uint64, i uint32) error

func (*NbdFile) WriteShort added in v0.2.0

func (file *NbdFile) WriteShort(offset uint64, s uint16) error

type NbdReply added in v0.2.0

type NbdReply struct {
	Magic  uint32
	Error  uint32
	Handle uint64
}

type NbdRequest added in v0.2.0

type NbdRequest struct {
	Magic  uint32
	Type   uint32
	Handle uint64
	From   uint64
	Len    uint32
}

func (*NbdRequest) ToWireFormat added in v0.2.0

func (msg *NbdRequest) ToWireFormat() []byte

type NbdSession added in v0.2.0

type NbdSession struct {
	Conn   net.Conn
	Handle uint64
	Size   uint64
	Flags  uint32
	Req    *NbdRequest
}

func (*NbdSession) Disconnect added in v0.2.0

func (session *NbdSession) Disconnect() error

func (*NbdSession) Flush added in v0.2.0

func (session *NbdSession) Flush() error

func (*NbdSession) Handshake added in v0.2.0

func (session *NbdSession) Handshake() error

func (*NbdSession) Read added in v0.2.0

func (session *NbdSession) Read(offset uint64, length uint32) ([]byte, error)

func (*NbdSession) Recv added in v0.2.0

func (session *NbdSession) Recv() ([]byte, error)

func (*NbdSession) Write added in v0.2.0

func (session *NbdSession) Write(from uint64, data []byte) error

type Query

type Query struct {
	ContentsList []Contents `xml:"Contents"`
}

func QueryRemote

func QueryRemote(repo_url string) (*Query, error)

type Repo

type Repo struct {
	URL         string
	Path        string
	DisableKvm  bool
	QemuAioType string
}

func NewRepo

func NewRepo(url string) *Repo

func (*Repo) DefaultImage

func (r *Repo) DefaultImage() string

func (*Repo) DownloadImage

func (r *Repo) DownloadImage(repo_url, hypervisor string, path string) error

func (*Repo) DownloadPackage added in v0.2.0

func (r *Repo) DownloadPackage(repo_url, packageName string) error

DownloadPackage downloads a package from the S3 repository into local.

func (*Repo) GetPackage added in v0.2.0

func (r *Repo) GetPackage(pkgname string) (io.ReadSeeker, error)

func (*Repo) GetPackageDependencies added in v0.2.0

func (r *Repo) GetPackageDependencies(pkg core.Package, downloadMissing bool) ([]core.Package, error)

func (*Repo) GetPackageTarReader added in v0.3.0

func (r *Repo) GetPackageTarReader(pkgname string) (*tar.Reader, error)

GetPackageTarReader returns tar reader for package with given name.

func (*Repo) ImageCachePath added in v0.2.0

func (r *Repo) ImageCachePath(hypervisor string, image string) string

func (*Repo) ImageExists

func (r *Repo) ImageExists(hypervisor, image string) bool

func (*Repo) ImagePath

func (r *Repo) ImagePath(hypervisor string, image string) string

func (*Repo) ImportImage added in v0.1.3

func (r *Repo) ImportImage(imageName string, file string, version string, created string, description string, build string) error

func (*Repo) ImportPackage added in v0.2.0

func (r *Repo) ImportPackage(pkg core.Package, packagePath string) error

func (*Repo) InitializeImage added in v0.2.0

func (r *Repo) InitializeImage(loaderImage string, imageName string, imageSize int64) error

func (*Repo) ListImages

func (r *Repo) ListImages() string

func (*Repo) ListPackages added in v0.2.0

func (r *Repo) ListPackages() string

func (*Repo) LocalPackages added in v0.3.0

func (r *Repo) LocalPackages(search string) ([]*core.Package, error)

func (*Repo) PackageExists added in v0.2.0

func (r *Repo) PackageExists(packageName string) bool

PackageExists will check that both package manifest and package file are present in the local package repository.

func (*Repo) PackageManifest added in v0.2.0

func (r *Repo) PackageManifest(packageName string) string

func (*Repo) PackagePath added in v0.2.0

func (r *Repo) PackagePath(packageName string) string

func (*Repo) PackagesPath added in v0.2.0

func (r *Repo) PackagesPath() string

func (*Repo) PrintRepo added in v0.2.0

func (r *Repo) PrintRepo()

func (*Repo) PullImage

func (r *Repo) PullImage(image string) error

func (*Repo) RemoveImage

func (r *Repo) RemoveImage(image string) error

func (*Repo) RepoPath added in v0.2.0

func (r *Repo) RepoPath() string

Jump to

Keyboard shortcuts

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