mdocker

package module
v0.0.0-...-547d9bb Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

README

mdocker

mdocker

Package mdocker is a mistify subagent that manages guest docker containers, exposed via JSON-RPC over HTTP.

HTTP API Endpoint
/_mistify_RPC_
    * GET - Run a specified method
Request Structure
{
    "method": "MDocker.RPC_METHOD",
    "params": [
        DATA_STRUCT
    ],
    "id": 0
}

Where RPC_METHOD is the desired method and DATA_STRUCTURE is one of the request structs defined in http://godoc.org/github.com/mistifyio/mistify-agent/rpc .

Response Structure
{
    "result": {
        KEY: RESPONSE_STRUCT
    },
    "error": null,
    "id": 0
}

Where KEY is a string (e.g. "snapshot") and DATA is one of the response structs defined in http://godoc.org/github.com/mistifyio/mistify-agent/rpc .

RPC Methods
ListContainers
GetContainer
DeleteContainer
SaveContainer
CreateContainer
StartContainer
StopContainer
RestartContainer
RebootContainer
PauseContainer
UnpauseContainer

ListImages
GetImages
LoadImage
DeleteImage

See the godocs and function signatures for each method's purpose and expected request/response structs.

Usage

type ErrorHTTPCode
type ErrorHTTPCode struct {
	Expected int
	Code     int
	Source   string
}

ErrorHTTPCode should be used for errors resulting from an http response code not matching the expected code

func (ErrorHTTPCode) Error
func (e ErrorHTTPCode) Error() string

Error returns a string error message

type MDocker
type MDocker struct {
}

MDocker is the Mistify Docker subagent service

func New
func New(endpoint, imageService, tlsCertPath string) (*MDocker, error)

New creates a new MDocker with a docker client

func (*MDocker) CreateContainer
func (md *MDocker) CreateContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

CreateContainer creates a new Docker container

func (*MDocker) DeleteContainer
func (md *MDocker) DeleteContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

DeleteContainer deletes a Docker container

func (*MDocker) DeleteImage
func (md *MDocker) DeleteImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error

DeleteImage deletes a Docker image

func (*MDocker) GetContainer
func (md *MDocker) GetContainer(h *http.Request, request *rpc.ContainerRequest, response *rpc.ContainerResponse) error

GetContainer retrieves information about a specific Docker container

func (*MDocker) GetImage
func (md *MDocker) GetImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error

GetImage retrieves information about a specific Docker image

func (*MDocker) GetInfo
func (md *MDocker) GetInfo(h *http.Request, request *struct{}, response *docker.DockerInfo) error

GetInfo provides general information about the system from Docker

func (*MDocker) ListContainers
func (md *MDocker) ListContainers(h *http.Request, request *rpc.ContainerRequest, response *rpc.ContainerResponse) error

ListContainers retrieves a list of Docker containers

func (*MDocker) ListImages
func (md *MDocker) ListImages(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error

ListImages retrieves a list of Docker images

func (*MDocker) LoadImage
func (md *MDocker) LoadImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error

LoadImage downloads a new container image from the image service and imports it into Docker

func (*MDocker) PauseContainer
func (md *MDocker) PauseContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

PauseContainer pauses a Docker container

func (*MDocker) RebootContainer
func (md *MDocker) RebootContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

RebootContainer restarts a Docker container

func (*MDocker) RequestOpts
func (md *MDocker) RequestOpts(req RPCRequest, opts interface{}) error

RequestOpts extracts the request opts into an appropriate struct Nested structs stored in interface{} don't convert directly, so use JSON as an intermediate

func (*MDocker) RestartContainer
func (md *MDocker) RestartContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

RestartContainer restarts a Docker container

func (*MDocker) RunHTTP
func (md *MDocker) RunHTTP(port uint) (*graceful.Server, error)

RunHTTP creates and runs the RPC HTTP server

func (*MDocker) SaveContainer
func (md *MDocker) SaveContainer(h *http.Request, request *rpc.ContainerRequest, response *rpc.ImageResponse) error

SaveContainer saves a Docker container

func (*MDocker) StartContainer
func (md *MDocker) StartContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

StartContainer starts a Docker container

func (*MDocker) StopContainer
func (md *MDocker) StopContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

StopContainer stops a Docker container or kills it after a timeout

func (*MDocker) UnpauseContainer
func (md *MDocker) UnpauseContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

UnpauseContainer restarts a Docker container

type RPCRequest
type RPCRequest interface {
	GetOpts() interface{}
}

RPCRequest is an interface for incoming RPC requests

-- Generated with godocdown

Documentation

Overview

Package mdocker is a mistify subagent that manages guest docker containers, exposed via JSON-RPC over HTTP.

HTTP API Endpoint

/_mistify_RPC_
    * GET - Run a specified method

Request Structure

{
    "method": "MDocker.RPC_METHOD",
    "params": [
        DATA_STRUCT
    ],
    "id": 0
}

Where RPC_METHOD is the desired method and DATA_STRUCTURE is one of the request structs defined in http://godoc.org/github.com/mistifyio/mistify-agent/rpc .

Response Structure

{
    "result": {
        KEY: RESPONSE_STRUCT
    },
    "error": null,
    "id": 0
}

Where KEY is a string (e.g. "snapshot") and DATA is one of the response structs defined in http://godoc.org/github.com/mistifyio/mistify-agent/rpc .

RPC Methods

ListContainers
GetContainer
DeleteContainer
SaveContainer
CreateContainer
StartContainer
StopContainer
RestartContainer
RebootContainer
PauseContainer
UnpauseContainer

ListImages
GetImages
LoadImage
DeleteImage

See the godocs and function signatures for each method's purpose and expected request/response structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHTTPCode

type ErrorHTTPCode struct {
	Expected int
	Code     int
	Source   string
}

ErrorHTTPCode should be used for errors resulting from an http response code not matching the expected code

func (ErrorHTTPCode) Error

func (e ErrorHTTPCode) Error() string

Error returns a string error message

type MDocker

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

MDocker is the Mistify Docker subagent service

func New

func New(endpoint, imageService, tlsCertPath string) (*MDocker, error)

New creates a new MDocker with a docker client

func (*MDocker) CreateContainer

func (md *MDocker) CreateContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

CreateContainer creates a new Docker container

func (*MDocker) DeleteContainer

func (md *MDocker) DeleteContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

DeleteContainer deletes a Docker container

func (*MDocker) DeleteImage

func (md *MDocker) DeleteImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error

DeleteImage deletes a Docker image

func (*MDocker) GetContainer

func (md *MDocker) GetContainer(h *http.Request, request *rpc.ContainerRequest, response *rpc.ContainerResponse) error

GetContainer retrieves information about a specific Docker container

func (*MDocker) GetImage

func (md *MDocker) GetImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error

GetImage retrieves information about a specific Docker image

func (*MDocker) GetInfo

func (md *MDocker) GetInfo(h *http.Request, request *struct{}, response *docker.DockerInfo) error

GetInfo provides general information about the system from Docker

func (*MDocker) ListContainers

func (md *MDocker) ListContainers(h *http.Request, request *rpc.ContainerRequest, response *rpc.ContainerResponse) error

ListContainers retrieves a list of Docker containers

func (*MDocker) ListImages

func (md *MDocker) ListImages(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error

ListImages retrieves a list of Docker images

func (*MDocker) LoadImage

func (md *MDocker) LoadImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error

LoadImage downloads a new container image from the image service and imports it into Docker

func (*MDocker) PauseContainer

func (md *MDocker) PauseContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

PauseContainer pauses a Docker container

func (*MDocker) RebootContainer

func (md *MDocker) RebootContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

RebootContainer restarts a Docker container

func (*MDocker) RequestOpts

func (md *MDocker) RequestOpts(req RPCRequest, opts interface{}) error

RequestOpts extracts the request opts into an appropriate struct Nested structs stored in interface{} don't convert directly, so use JSON as an intermediate

func (*MDocker) RestartContainer

func (md *MDocker) RestartContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

RestartContainer restarts a Docker container

func (*MDocker) RunHTTP

func (md *MDocker) RunHTTP(port uint) (*graceful.Server, error)

RunHTTP creates and runs the RPC HTTP server

func (*MDocker) SaveContainer

func (md *MDocker) SaveContainer(h *http.Request, request *rpc.ContainerRequest, response *rpc.ImageResponse) error

SaveContainer saves a Docker container

func (*MDocker) StartContainer

func (md *MDocker) StartContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

StartContainer starts a Docker container

func (*MDocker) StopContainer

func (md *MDocker) StopContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

StopContainer stops a Docker container or kills it after a timeout

func (*MDocker) UnpauseContainer

func (md *MDocker) UnpauseContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error

UnpauseContainer restarts a Docker container

type RPCRequest

type RPCRequest interface {
	GetOpts() interface{}
}

RPCRequest is an interface for incoming RPC requests

Directories

Path Synopsis
cmd
mistify-agent-docker
mistify-agent-docker runs the subagent and HTTP API.
mistify-agent-docker runs the subagent and HTTP API.

Jump to

Keyboard shortcuts

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