hyper

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2016 License: Apache-2.0, Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Handler for Hyper containers.

Index

Constants

View Source
const (
	HYPER_PROTO       = "unix"
	HYPER_ADDR        = "/var/run/hyper.sock"
	HYPER_SCHEME      = "http"
	HYPER_MINVERSION  = "0.4.0"
	DEFAULT_IMAGE_TAG = "latest"

	KEY_ID             = "id"
	KEY_IMAGEID        = "imageId"
	KEY_IMAGENAME      = "imageName"
	KEY_ITEM           = "item"
	KEY_DNS            = "dns"
	KEY_MEMORY         = "memory"
	KEY_POD_ID         = "podId"
	KEY_POD_NAME       = "podName"
	KEY_RESOURCE       = "resource"
	KEY_VCPU           = "vcpu"
	KEY_TTY            = "tty"
	KEY_TYPE           = "type"
	KEY_VALUE          = "value"
	KEY_NAME           = "name"
	KEY_IMAGE          = "image"
	KEY_VOLUMES        = "volumes"
	KEY_CONTAINERS     = "containers"
	KEY_VOLUME_SOURCE  = "source"
	KEY_VOLUME_DRIVE   = "driver"
	KEY_ENVS           = "envs"
	KEY_CONTAINER_PORT = "containerPort"
	KEY_HOST_PORT      = "hostPort"
	KEY_PROTOCOL       = "protocol"
	KEY_PORTS          = "ports"
	KEY_MOUNTPATH      = "path"
	KEY_READONLY       = "readOnly"
	KEY_VOLUME         = "volume"
	KEY_COMMAND        = "command"
	KEY_WORKDIR        = "workdir"
	KEY_VM             = "vm"
	VOLUME_TYPE_VFS    = "vfs"
	TYPE_CONTAINER     = "container"
	TYPE_POD           = "pod"
)
View Source
const (
	StatusRunning = "running"
	StatusPending = "pending"
	StatusFailed  = "failed"
	StatusSuccess = "succeeded"
)
View Source
const (
	// HyperNamespace is namespace under which Hyper aliases are unique.
	HyperNamespace = "hyper"
)
View Source
const WatchInterval = 3 * time.Second

Variables

View Source
var (
	ErrConnectionRefused = errors.New("Cannot connect to the Hyper daemon. Is 'hyperd' running on this host?")
)

Functions

func MatchesContentType

func MatchesContentType(contentType, expectedType string) bool

func Register

func Register(factory info.MachineInfoFactory, fsInfo fs.FsInfo) error

Register root container before running this function!

Types

type AttachToContainerOptions

type AttachToContainerOptions struct {
	Container    string
	InputStream  io.Reader
	OutputStream io.Writer
	ErrorStream  io.Writer
}

type BlkioStatEntry

type BlkioStatEntry struct {
	Name   string            `json:"name"`
	Type   string            `json:"type"`
	Source string            `json:"source"`
	Major  uint64            `json:"major"`
	Minor  uint64            `json:"minor"`
	Stat   map[string]uint64 `json:"stat"`
}

BlkioStatEntry is one small entity to store a piece of Blkio stats

type BlkioStats

type BlkioStats struct {
	// number of bytes transferred to and from the block device
	IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"`
	IoServicedRecursive     []BlkioStatEntry `json:"io_serviced_recursive"`
	IoQueuedRecursive       []BlkioStatEntry `json:"io_queue_recursive"`
	IoServiceTimeRecursive  []BlkioStatEntry `json:"io_service_time_recursive"`
	IoWaitTimeRecursive     []BlkioStatEntry `json:"io_wait_time_recursive"`
	IoMergedRecursive       []BlkioStatEntry `json:"io_merged_recursive"`
	IoTimeRecursive         []BlkioStatEntry `json:"io_time_recursive"`
	SectorsRecursive        []BlkioStatEntry `json:"sectors_recursive"`
}

BlkioStats stores All IO service stats for data read and write

type Container

type Container struct {
	Name            string           `json:"name"`
	ContainerID     string           `json:"containerID"`
	PodID           string           `json:"podID"`
	Image           string           `json:"image"`
	ImageID         string           `json:"imageID"`
	Commands        []string         `json:"commands"`
	Args            []string         `json:"args"`
	Workdir         string           `json:"workingDir"`
	Ports           []ContainerPort  `json:"ports"`
	Environment     []EnvironmentVar `json:"env"`
	Volume          []VolumeMount    `json:"volumeMounts"`
	ImagePullPolicy string           `json:"imagePullPolicy"`
}

Pod JSON Data Structure

type ContainerPort

type ContainerPort struct {
	Name          string `json:"name"`
	HostPort      int    `json:"hostPort"`
	ContainerPort int    `json:"containerPort"`
	Protocol      string `json:"protocol"`
	HostIP        string `json:"hostIP"`
}

Container JSON Data Structure

type ContainerStats

type ContainerStats struct {
	ContainerID string       `json:"id"`
	Cpu         CpuStats     `json:"cpu,omitempty"`
	Block       BlkioStats   `json:"block,omitempty"`
	Memory      MemoryStats  `json:"memory,omitempty"`
	Network     NetworkStats `json:"network,omitempty"`
	Filesystem  []FsStats    `json:"filesystem,omitempty"`
	Timestamp   time.Time    `json:"timestamp"`
}

type ContainerStatus

type ContainerStatus struct {
	Name        string        `json:"name"`
	ContainerID string        `json:"containerID"`
	Phase       string        `json:"phase"`
	Waiting     WaitingStatus `json:"waiting"`
	Running     RunningStatus `json:"running"`
	Terminated  TermStatus    `json:"terminated"`
}

type CpuStats

type CpuStats struct {
	Usage CpuUsage `json:"usage"`
	// Smoothed average of number of runnable threads x 1000.
	// We multiply by thousand to avoid using floats, but preserving precision.
	// Load is smoothed over the last 10 seconds. Instantaneous value can be read
	// from LoadStats.NrRunning.
	LoadAverage int32 `json:"load_average"`
}

All CPU usage metrics are cumulative from the creation of the container

type CpuUsage

type CpuUsage struct {
	// Total CPU usage.
	// Units: nanoseconds
	Total uint64 `json:"total"`

	// Per CPU/core usage of the container.
	// Unit: nanoseconds.
	PerCpu []uint64 `json:"per_cpu_usage,omitempty"`

	// Time spent in user space.
	// Unit: nanoseconds
	User uint64 `json:"user"`

	// Time spent in kernel space.
	// Unit: nanoseconds
	System uint64 `json:"system"`
}

CPU usage time statistics.

type EnvironmentVar

type EnvironmentVar struct {
	Env   string `json:"env"`
	Value string `json:"value"`
}

type ExecInContainerOptions

type ExecInContainerOptions struct {
	Container    string
	InputStream  io.Reader
	OutputStream io.Writer
	ErrorStream  io.Writer
	Commands     []string
}

type FsStats

type FsStats struct {
	// The block device name associated with the filesystem.
	Device string `json:"device,omitempty"`

	// Number of bytes that can be consumed by the container on this filesystem.
	Limit uint64 `json:"capacity"`

	// Number of bytes that is consumed by the container on this filesystem.
	Usage uint64 `json:"usage"`

	// Number of bytes available for non-root user.
	Available uint64 `json:"available"`

	// Number of reads completed
	// This is the total number of reads completed successfully.
	ReadsCompleted uint64 `json:"reads_completed"`

	// Number of reads merged
	// Reads and writes which are adjacent to each other may be merged for
	// efficiency.  Thus two 4K reads may become one 8K read before it is
	// ultimately handed to the disk, and so it will be counted (and queued)
	// as only one I/O.  This field lets you know how often this was done.
	ReadsMerged uint64 `json:"reads_merged"`

	// Number of sectors read
	// This is the total number of sectors read successfully.
	SectorsRead uint64 `json:"sectors_read"`

	// Number of milliseconds spent reading
	// This is the total number of milliseconds spent by all reads (as
	// measured from __make_request() to end_that_request_last()).
	ReadTime uint64 `json:"read_time"`

	// Number of writes completed
	// This is the total number of writes completed successfully.
	WritesCompleted uint64 `json:"writes_completed"`

	// Number of writes merged
	// See the description of reads merged.
	WritesMerged uint64 `json:"writes_merged"`

	// Number of sectors written
	// This is the total number of sectors written successfully.
	SectorsWritten uint64 `json:"sectors_written"`

	// Number of milliseconds spent writing
	// This is the total number of milliseconds spent by all writes (as
	// measured from __make_request() to end_that_request_last()).
	WriteTime uint64 `json:"write_time"`

	// Number of I/Os currently in progress
	// The only field that should go to zero. Incremented as requests are
	// given to appropriate struct request_queue and decremented as they finish.
	IoInProgress uint64 `json:"io_in_progress"`

	// Number of milliseconds spent doing I/Os
	// This field increases so long as field 9 is nonzero.
	IoTime uint64 `json:"io_time"`

	// weighted number of milliseconds spent doing I/Os
	// This field is incremented at each I/O start, I/O completion, I/O
	// merge, or read of these stats by the number of I/Os in progress
	// (field 9) times the number of milliseconds spent doing I/O since the
	// last update of this field.  This can provide an easy measure of both
	// I/O completion time and the backlog that may be accumulating.
	WeightedIoTime uint64 `json:"weighted_io_time"`
}

type HyperClient

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

func NewHyperClient

func NewHyperClient() *HyperClient

func (*HyperClient) GetContainer

func (client *HyperClient) GetContainer(name string) (*Container, error)

func (*HyperClient) GetPod

func (client *HyperClient) GetPod(name string) (*PodInfo, error)

func (*HyperClient) GetPodStats

func (client *HyperClient) GetPodStats(podID string) (*PodStats, error)

func (*HyperClient) Info

func (client *HyperClient) Info() (map[string]interface{}, error)

func (*HyperClient) ListContainers

func (client *HyperClient) ListContainers() ([]HyperContainer, error)

func (*HyperClient) ListImages

func (client *HyperClient) ListImages() ([]HyperImage, error)

func (*HyperClient) ListPods

func (client *HyperClient) ListPods() ([]HyperPod, error)

func (*HyperClient) ListPodsByVM

func (client *HyperClient) ListPodsByVM(vm string) ([]HyperPod, error)

func (*HyperClient) Version

func (client *HyperClient) Version() (string, error)

type HyperContainer

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

type HyperImage

type HyperImage struct {
	Repository  string
	Tag         string
	ImageID     string
	CreatedAt   int64
	VirtualSize int64
}

type HyperPod

type HyperPod struct {
	PodID   string
	PodName string
	VmName  string
	Status  string
	PodInfo PodInfo
}

type HyperService

type HyperService struct {
	ServiceIP   string                `json:"serviceip"`
	ServicePort int                   `json:"serviceport"`
	Protocol    string                `json:"protocol"`
	Hosts       []HyperServiceBackend `json:"hosts"`
}

type HyperServiceBackend

type HyperServiceBackend struct {
	HostIP   string `json:"hostip"`
	HostPort int    `json:"hostport"`
}

type InterfaceStats

type InterfaceStats struct {
	// The name of the interface.
	Name string `json:"name"`
	// Cumulative count of bytes received.
	RxBytes uint64 `json:"rx_bytes"`
	// Cumulative count of packets received.
	RxPackets uint64 `json:"rx_packets"`
	// Cumulative count of receive errors encountered.
	RxErrors uint64 `json:"rx_errors"`
	// Cumulative count of packets dropped while receiving.
	RxDropped uint64 `json:"rx_dropped"`
	// Cumulative count of bytes transmitted.
	TxBytes uint64 `json:"tx_bytes"`
	// Cumulative count of packets transmitted.
	TxPackets uint64 `json:"tx_packets"`
	// Cumulative count of transmit errors encountered.
	TxErrors uint64 `json:"tx_errors"`
	// Cumulative count of packets dropped while transmitting.
	TxDropped uint64 `json:"tx_dropped"`
}

type MemoryStats

type MemoryStats struct {
	// Current memory usage, this includes all memory regardless of when it was
	// accessed.
	// Units: Bytes.
	Usage uint64 `json:"usage"`

	// The amount of working set memory, this includes recently accessed memory,
	// dirty memory, and kernel memory. Working set is <= "usage".
	// Units: Bytes.
	WorkingSet uint64 `json:"working_set"`

	Failcnt uint64 `json:"failcnt"`

	ContainerData    MemoryStatsMemoryData `json:"container_data,omitempty"`
	HierarchicalData MemoryStatsMemoryData `json:"hierarchical_data,omitempty"`
}

type MemoryStatsMemoryData

type MemoryStatsMemoryData struct {
	Pgfault    uint64 `json:"pgfault"`
	Pgmajfault uint64 `json:"pgmajfault"`
}

type NetworkStats

type NetworkStats struct {
	Interfaces []InterfaceStats `json:"interfaces,omitempty"`
	// TCP connection stats (Established, Listen...)
	Tcp TcpStat `json:"tcp"`
	// TCP6 connection stats (Established, Listen...)
	Tcp6 TcpStat `json:"tcp6"`
}

type PodInfo

type PodInfo struct {
	Kind       string    `json:"kind"`
	ApiVersion string    `json:"apiVersion"`
	Vm         string    `json:"vm"`
	Spec       PodSpec   `json:"spec"`
	Status     PodStatus `json:"status"`
}

type PodSpec

type PodSpec struct {
	Volumes    []PodVolume       `json:"volumes"`
	Containers []Container       `json:"containers"`
	Labels     map[string]string `json:"labels"`
	Vcpu       int               `json:"vcpu"`
	Memory     int               `json:"memory"`
}

type PodStats

type PodStats struct {
	Cpu        CpuStats     `json:"cpu,omitempty"`
	Block      BlkioStats   `json:"block,omitempty"`
	Memory     MemoryStats  `json:"memory,omitempty"`
	Network    NetworkStats `json:"network,omitempty"`
	Filesystem []FsStats    `json:"filesystem,omitempty"`
	Timestamp  time.Time    `json:"timestamp"`

	ContainersStats []ContainerStats `json:"container_stats"`
}

type PodStatus

type PodStatus struct {
	Phase     string            `json:"phase"`
	Message   string            `json:"message"`
	Reason    string            `json:"reason"`
	HostIP    string            `json:"hostIP"`
	PodIP     []string          `json:"podIP"`
	StartTime string            `json:"startTime"`
	Status    []ContainerStatus `json:"containerStatus"`
}

type PodVolume

type PodVolume struct {
	Name     string          `json:"name"`
	HostPath string          `json:"source"`
	Driver   string          `json:"driver"`
	Rbd      RBDVolumeSource `json:"rbd"`
}

type RBDVolumeSource

type RBDVolumeSource struct {
	Monitors []string `json:"monitors"`
	Image    string   `json:"image"`
	FsType   string   `json:"fsType"`
	Pool     string   `json:"pool"`
	User     string   `json:"user"`
	Keyring  string   `json:"keyring"`
	ReadOnly bool     `json:"readOnly"`
}

type RunningStatus

type RunningStatus struct {
	StartedAt string `json:"startedAt"`
}

type TcpStat

type TcpStat struct {
	//Count of TCP connections in state "Established"
	Established uint64
	//Count of TCP connections in state "Syn_Sent"
	SynSent uint64
	//Count of TCP connections in state "Syn_Recv"
	SynRecv uint64
	//Count of TCP connections in state "Fin_Wait1"
	FinWait1 uint64
	//Count of TCP connections in state "Fin_Wait2"
	FinWait2 uint64
	//Count of TCP connections in state "Time_Wait
	TimeWait uint64
	//Count of TCP connections in state "Close"
	Close uint64
	//Count of TCP connections in state "Close_Wait"
	CloseWait uint64
	//Count of TCP connections in state "Listen_Ack"
	LastAck uint64
	//Count of TCP connections in state "Listen"
	Listen uint64
	//Count of TCP connections in state "Closing"
	Closing uint64
}

type TermStatus

type TermStatus struct {
	ExitCode   int    `json:"exitCode"`
	Reason     string `json:"reason"`
	Message    string `json:"message"`
	StartedAt  string `json:"startedAt"`
	FinishedAt string `json:"finishedAt"`
}

type VolumeMount

type VolumeMount struct {
	Name      string `json:"name"`
	ReadOnly  bool   `json:"readOnly"`
	MountPath string `json:"mountPath"`
}

type WaitingStatus

type WaitingStatus struct {
	Reason string `json:"reason"`
}

Jump to

Keyboard shortcuts

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