util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: BSD-3-Clause Imports: 29 Imported by: 49

Documentation

Index

Constants

View Source
const (
	NBD_REQUEST_MAGIC             = 0x25609513
	NBD_REPLY_MAGIC               = 0x67446698
	NBD_OLD_STYLE_HANDSHAKE_MAGIC = 0x00420281861253
	NBD_NEW_STYLE_HANDSHAKE_MAGIC = 0x49484156454F5054
)
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 (
	ZfsBuilderImageName    = "osv-zfs-builder"
	LoaderImageName        = "osv-loader"
	VmlinuzLoaderName      = "osv-vmlinuz.bin"
	GitHubRepositoryApiUrl = "https://api.github.com"
)
View Source
const (
	BLOCK_SIZE = 512

	DIR_MODE  = 0x4000
	REG_MODE  = 0x8000
	LINK_MODE = 0xA000
)
View Source
const (
	DefaultRepositoryUrl = "https://mikelangelo-capstan.s3.amazonaws.com/"
)
View Source
const (
	OsvReleasesSuffix = "/repos/cloudius-systems/osv/releases"
)

Variables

This section is empty.

Functions

func ConfigDir

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

func ConvertImageToQCOW2(imagePath string) error

func CopyFile

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

func CopyLocalFile

func CopyLocalFile(dst, src string) error

func ExtendMap

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

func FileInfoHeader

func FileInfoHeader() string

func GenerateMAC

func GenerateMAC() (net.HardwareAddr, error)

Generate a MAC address.

func HomePath

func HomePath() string

func ID

func ID() string

func IsDirectIOSupported

func IsDirectIOSupported(path string) bool

func IsRemoteImage

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

func ListImagesRemote

func ListImagesRemote(repo_url string, search string) error

func NeedsUpdate

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

func ParseEnvironmentList

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

func ParseMemSize

func ParseMemSize(memory string) (int64, error)

func RawTerm

func RawTerm() error

func RemoveOrphanedInstances

func RemoveOrphanedInstances(verbose bool) error

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

func ResetTerm

func ResetTerm()

func ResizeImage

func ResizeImage(imagePath string, targetSize uint64) error

func SearchInstance

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

func SetCmdLine

func SetCmdLine(imagePath string, cmdLine string) error

func SetPartition

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

func StringInSlice

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

func VersionStringToInt

func VersionStringToInt(version string) (int, error)

VersionStringToInt converts 1.2.3 into 1002003 to make it comparable.

func WriteRofsImage

func WriteRofsImage(imagePath string, paths map[string]string, sourceRootPath string, verbose bool) error

Types

type Asset

type Asset struct {
	Name        string `json:"name"`
	Size        int    `json:"size"`
	DownloadUrl string `json:"browser_download_url"`
}

type CapstanSettings

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

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

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

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

type NbdFile

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

func NewNbdFile

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

func (*NbdFile) Close

func (file *NbdFile) Close() error

func (*NbdFile) Wait

func (file *NbdFile) Wait()

func (*NbdFile) Write

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

func (*NbdFile) WriteByte

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

func (*NbdFile) WriteInt

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

func (*NbdFile) WriteShort

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

type NbdReply

type NbdReply struct {
	Magic  uint32
	Error  uint32
	Handle uint64
}

type NbdRequest

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

func (*NbdRequest) ToWireFormat

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

type NbdSession

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

func (*NbdSession) Disconnect

func (session *NbdSession) Disconnect() error

func (*NbdSession) Flush

func (session *NbdSession) Flush() error

func (*NbdSession) Handshake

func (session *NbdSession) Handshake() error

func (*NbdSession) NewStyleHandshake

func (session *NbdSession) NewStyleHandshake(magic uint64) error

func (*NbdSession) OldStyleHandshake

func (session *NbdSession) OldStyleHandshake(magic uint64) error

func (*NbdSession) Read

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

func (*NbdSession) Recv

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

func (*NbdSession) Write

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

type Query

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

type Release

type Release struct {
	Id     int     `json:"id"`
	Name   string  `json:"name"`
	Tag    string  `json:"tag_name"`
	Assets []Asset `json:"assets"`
}

type RemotePackageDownloadInfo

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

type Repo

type Repo struct {
	URL         string
	Path        string
	DisableKvm  bool
	QemuAioType string
	UseS3       bool
	ReleaseTag  string
	GithubURL   string
}

func NewRepo

func NewRepo(url string) *Repo

func NewRepoFromCli

func NewRepoFromCli(c *cli.Context) *Repo

func (*Repo) CreateRofsImage

func (r *Repo) CreateRofsImage(loaderImage string, imageName string, rofsImagePath string) error

func (*Repo) DefaultImage

func (r *Repo) DefaultImage() string

func (*Repo) DownloadImage

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

func (*Repo) DownloadLoaderImage

func (r *Repo) DownloadLoaderImage(loaderImageName string, hypervisor string) (string, error)

func (*Repo) DownloadPackageRemote

func (r *Repo) DownloadPackageRemote(packageName string) error

func (*Repo) DownloadZfsBuilderImage

func (r *Repo) DownloadZfsBuilderImage(hypervisor string) (string, error)

func (*Repo) GetPackage

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

func (*Repo) GetPackageDependencies

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

func (*Repo) GetPackageTarReader

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

GetPackageTarReader returns tar reader for package with given name.

func (*Repo) GetVmlinuzLoaderPath

func (r *Repo) GetVmlinuzLoaderPath() (string, error)

func (*Repo) GetZfsBuilderImagePath

func (r *Repo) GetZfsBuilderImagePath() (string, error)

func (*Repo) ImageCachePath

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

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

func (*Repo) ImportPackage

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

func (*Repo) InitializeZfsImage

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

func (*Repo) ListImages

func (r *Repo) ListImages() string

func (*Repo) ListPackages

func (r *Repo) ListPackages() string

func (*Repo) ListPackagesRemote

func (r *Repo) ListPackagesRemote(search string) error

func (*Repo) LocalPackages

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

func (*Repo) PackageExists

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) PackageInfoRemote

func (r *Repo) PackageInfoRemote(packageName string) *core.Package

func (*Repo) PackageManifest

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

func (*Repo) PackagePath

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

func (*Repo) PackagesPath

func (r *Repo) PackagesPath() string

func (*Repo) PrintRepo

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

func (r *Repo) RepoPath() string

type RofsDirectoryEntry

type RofsDirectoryEntry struct {
	InodeNumber uint64
	Filename    string
}

type RofsFilesystem

type RofsFilesystem struct {
	SuperBlock             RofsSuperBlock
	DirectoryEntries       []*RofsDirectoryEntry
	Symlinks               []*RofsSymlink
	Inodes                 []*RofsInode
	DirectoryEntriesByPath map[string][]string
	CurrentBlock           int
}

type RofsInode

type RofsInode struct {
	Mode        uint64
	InodeNumber uint64
	DataOffset  uint64
	Count       uint64 // either file size in bytes or children count
}

type RofsSuperBlock

type RofsSuperBlock struct {
	Magic                    uint64
	Version                  uint64
	BlockSize                uint64
	StructureInfoFirstBlock  uint64
	StructureInfoBlocksCount uint64
	DirectoryEntriesCount    uint64
	SymlinksCount            uint64
	InodesCount              uint64
}

func ReadRofsSuperBlock

func ReadRofsSuperBlock(imageFile *os.File) (*RofsSuperBlock, error)
type RofsSymlink struct {
	Filename string
}

Jump to

Keyboard shortcuts

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