Documentation ¶
Overview ¶
Package rpc defines the JSON-RPC over HTTP types the Agent uses to communicate with sub-agents. It also contains various helpers for writing sub-agents.
Index ¶
- Constants
- type Client
- type Codec
- type ContainerRequest
- type ContainerResponse
- type GuestMetricsRequest
- type GuestMetricsResponse
- type GuestRequest
- type GuestResponse
- type Image
- type ImageRequest
- type ImageResponse
- type Server
- type Snapshot
- type SnapshotRequest
- type SnapshotResponse
- type Volume
- type VolumeRequest
- type VolumeResponse
Constants ¶
const (
// RPCPath is the URI endpoint that the Agent posts to for sub-agent communication.
RPCPath = "/_mistify_RPC_"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
URL string
}
Client is a simple JSON-RPC over HTTP client used by the agent.
func (*Client) DoRaw ¶
func (c *Client) DoRaw(request interface{}, rw http.ResponseWriter)
DoRaw calls a service and proxies the response
type Codec ¶
Codec is a wrapper for the json.Codec
func (*Codec) NewRequest ¶
func (c *Codec) NewRequest(r *http.Request) rpc.CodecRequest
NewRequest creates a new request from the codec
type ContainerRequest ¶
type ContainerRequest struct { ID string `json:"id"` // Container ID Opts interface{} `json:"opts"` // Generic Options. Will need converting }
ContainerRequest is a container request to the Docker sub-agent
func (*ContainerRequest) GetOpts ¶
func (creq *ContainerRequest) GetOpts() interface{}
GetOpts returns the Opts property
type ContainerResponse ¶
type ContainerResponse struct {
Containers []*docker.Container `json:"containers"` // Slice of one or more containers
}
ContainerResponse is a container response from the Docker sub-agent
type GuestMetricsRequest ¶
type GuestMetricsRequest struct { Guest *client.Guest `json:"guest"` // Guest Type string `json:"type"` // type of metric desired Args map[string]string `json:"args,omitempty"` // Opaque, optional arguments }
GuestMetricsRequest is a request for guest metrics
type GuestMetricsResponse ¶
type GuestMetricsResponse struct { Guest *client.Guest `json:"guest"` // Guest - in general this should not be modified Type string `json:"type"` // Type of metrics returned Disk map[string]*client.GuestDiskMetrics `json:"disk,omitempty"` // Disk metrics Nic map[string]*client.GuestNicMetrics `json:"nic,omitempty"` // Network Interface metrics CPU []*client.GuestCPUMetrics `json:"cpu,omitempty"` // CPU metrics }
GuestMetricsResponse is a response of guest metrics
type GuestRequest ¶
type GuestRequest struct { Guest *client.Guest `json:"guest"` // Guest Action string `json:"action"` // Action Args map[string]string `json:"args,omitempty"` // Opaque, optional arguments }
GuestRequest is a request to a sub-agent
type GuestResponse ¶
type GuestResponse struct { Guest *client.Guest `json:"guest"` // Guest, possibly modified Message string `json:"message,omitempty"` // Any informational message Retry int `json:"retry,omitempty"` // instruct the agent to retry after this many second. Not yet implemented }
GuestResponse is a response from a sub-agent
type Image ¶
type Image struct { ID string `json:"id"` // Unique ID Type string `json:"type"` // Image Type ("container", etc.") Volume string `json:"volume,omitempty"` // Imported ZVOL Snapshot string `json:"snapshot,omitempty"` // ZVOL Snapshot Size uint64 `json:"size"` // Size in MB Status string `json:"status,omitempty"` // current status of the Image: pending, complete, etc }
Image represents an image used for creating VM disks or containers
type ImageRequest ¶
type ImageRequest struct { ID string `json:"id"` // Image ID Type string `json:"type"` // Image Type ("container", etc.) Dest string `json:"dest"` // Destination for clones, etc Source string `json:"source"` // Source for fetches. Generally a URL }
ImageRequest is an image request to the Storage or Container sub-agent
type ImageResponse ¶
type ImageResponse struct {
Images []*Image `json:"images"` //Image slice for gets and lists. An empty slice is generally used for "not found"
}
ImageResponse is an image response from the Storage or Container sub-agent
type Server ¶
type Server struct { RPCServer *rpc.Server HTTPServer *http.Server Router *mux.Router Chain alice.Chain }
Server is a basic JSON-RPC over HTTP server.
func NewServer ¶
NewServer creates an JSON-RPC HTTP server bound to 127.0.0.1. This answers RPC requests on the Mistify RPC Path. This server logs to STDOUT and also presents pprof on /debug/pprof/
func (*Server) HandleFunc ¶
HandleFunc is a helper for registering a handler function for a given path
func (*Server) ListenAndServe ¶
ListenAndServe is a helper for starting the HTTP service. This generally does not return.
func (*Server) RegisterService ¶
RegisterService is a helper for registering a new RPC service
type SnapshotRequest ¶
type SnapshotRequest struct { ID string `json:"id"` // Volume ID Dest string `json:"dest"` // Destination for clones, creates, etc Recursive bool `json:"recursive"` // Recursively create snapshots for all guest disks DestroyMoreRecent bool `json:"destroyMoreRecent"` // Destroy more recent snapshots when rolling back }
SnapshotRequest is a snapshot request for the Storage sub-agent
type SnapshotResponse ¶
type SnapshotResponse struct {
Snapshots []*Snapshot `json:"snapshots"` // Snapshot slice for gets and lists. An empty slice is generally used for "not found"
}
SnapshotResponse is a snapshot response for the Storage sub-agent
type Volume ¶
type Volume struct { ID string `json:"id"` // Unique ID Size uint64 `json:"size"` // Size in MB Device string `json:"device"` // Device in /dev to use }
Volume represents a ZFS ZVOL
type VolumeRequest ¶
type VolumeRequest struct { ID string `json:"id"` // Volume ID Size uint64 `json:"size"` // Size in MB }
VolumeRequest is a volume request to the Storage sub-agent. Currently, only create and delete are used.
type VolumeResponse ¶
type VolumeResponse struct {
Volumes []*Volume `json:"volumes"` //Volume slice for gets and lists. An empty slice is generally used for "not found"
}
VolumeResponse is a volume response from the Storage sub-agent