agent

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(c HTTPClient) *Client

func (*Client) Create

func (c *Client) Create(ctx context.Context, req CreateRequest) (map[string]interface{}, error)

Create Execute QEMU Guest Agent commands.

func (*Client) Exec

func (c *Client) Exec(ctx context.Context, req ExecRequest) (ExecResponse, error)

Exec Executes the given command in the vm via the guest-agent and returns an object with the pid.

func (*Client) ExecStatus

func (c *Client) ExecStatus(ctx context.Context, req ExecStatusRequest) (ExecStatusResponse, error)

ExecStatus Gets the status of the given pid started by the guest-agent

func (*Client) FileRead

func (c *Client) FileRead(ctx context.Context, req FileReadRequest) (FileReadResponse, error)

FileRead Reads the given file via guest agent. Is limited to 16777216 bytes.

func (*Client) FileWrite

func (c *Client) FileWrite(ctx context.Context, req FileWriteRequest) error

FileWrite Writes the given file via guest agent.

func (*Client) FsfreezeFreeze

func (c *Client) FsfreezeFreeze(ctx context.Context, req FsfreezeFreezeRequest) (map[string]interface{}, error)

FsfreezeFreeze Execute fsfreeze-freeze.

func (*Client) FsfreezeStatus

func (c *Client) FsfreezeStatus(ctx context.Context, req FsfreezeStatusRequest) (map[string]interface{}, error)

FsfreezeStatus Execute fsfreeze-status.

func (*Client) FsfreezeThaw

func (c *Client) FsfreezeThaw(ctx context.Context, req FsfreezeThawRequest) (map[string]interface{}, error)

FsfreezeThaw Execute fsfreeze-thaw.

func (*Client) Fstrim

func (c *Client) Fstrim(ctx context.Context, req FstrimRequest) (map[string]interface{}, error)

Fstrim Execute fstrim.

func (*Client) GetFsinfo

func (c *Client) GetFsinfo(ctx context.Context, req GetFsinfoRequest) (map[string]interface{}, error)

GetFsinfo Execute get-fsinfo.

func (*Client) GetHostName

func (c *Client) GetHostName(ctx context.Context, req GetHostNameRequest) (map[string]interface{}, error)

GetHostName Execute get-host-name.

func (*Client) GetMemoryBlockInfo

func (c *Client) GetMemoryBlockInfo(ctx context.Context, req GetMemoryBlockInfoRequest) (map[string]interface{}, error)

GetMemoryBlockInfo Execute get-memory-block-info.

func (*Client) GetMemoryBlocks

func (c *Client) GetMemoryBlocks(ctx context.Context, req GetMemoryBlocksRequest) (map[string]interface{}, error)

GetMemoryBlocks Execute get-memory-blocks.

func (*Client) GetOsinfo

func (c *Client) GetOsinfo(ctx context.Context, req GetOsinfoRequest) (map[string]interface{}, error)

GetOsinfo Execute get-osinfo.

func (*Client) GetTime

func (c *Client) GetTime(ctx context.Context, req GetTimeRequest) (map[string]interface{}, error)

GetTime Execute get-time.

func (*Client) GetTimezone

func (c *Client) GetTimezone(ctx context.Context, req GetTimezoneRequest) (map[string]interface{}, error)

GetTimezone Execute get-timezone.

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, req GetUsersRequest) (map[string]interface{}, error)

GetUsers Execute get-users.

func (*Client) GetVcpus

func (c *Client) GetVcpus(ctx context.Context, req GetVcpusRequest) (map[string]interface{}, error)

GetVcpus Execute get-vcpus.

func (*Client) Index

func (c *Client) Index(ctx context.Context, req IndexRequest) ([]map[string]interface{}, error)

Index QEMU Guest Agent command index.

func (*Client) Info

func (c *Client) Info(ctx context.Context, req InfoRequest) (map[string]interface{}, error)

Info Execute info.

func (*Client) NetworkGetInterfaces

func (c *Client) NetworkGetInterfaces(ctx context.Context, req NetworkGetInterfacesRequest) (map[string]interface{}, error)

NetworkGetInterfaces Execute network-get-interfaces.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context, req PingRequest) (map[string]interface{}, error)

Ping Execute ping.

func (*Client) SetUserPassword

func (c *Client) SetUserPassword(ctx context.Context, req SetUserPasswordRequest) (map[string]interface{}, error)

SetUserPassword Sets the password for the given user to the given password

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context, req ShutdownRequest) (map[string]interface{}, error)

Shutdown Execute shutdown.

func (*Client) SuspendDisk

func (c *Client) SuspendDisk(ctx context.Context, req SuspendDiskRequest) (map[string]interface{}, error)

SuspendDisk Execute suspend-disk.

func (*Client) SuspendHybrid

func (c *Client) SuspendHybrid(ctx context.Context, req SuspendHybridRequest) (map[string]interface{}, error)

SuspendHybrid Execute suspend-hybrid.

func (*Client) SuspendRam

func (c *Client) SuspendRam(ctx context.Context, req SuspendRamRequest) (map[string]interface{}, error)

SuspendRam Execute suspend-ram.

type Command added in v0.0.15

type Command string
const (
	Command_FSFREEZE_FREEZE        Command = "fsfreeze-freeze"
	Command_FSFREEZE_STATUS        Command = "fsfreeze-status"
	Command_FSFREEZE_THAW          Command = "fsfreeze-thaw"
	Command_FSTRIM                 Command = "fstrim"
	Command_GET_FSINFO             Command = "get-fsinfo"
	Command_GET_HOST_NAME          Command = "get-host-name"
	Command_GET_MEMORY_BLOCK_INFO  Command = "get-memory-block-info"
	Command_GET_MEMORY_BLOCKS      Command = "get-memory-blocks"
	Command_GET_OSINFO             Command = "get-osinfo"
	Command_GET_TIME               Command = "get-time"
	Command_GET_TIMEZONE           Command = "get-timezone"
	Command_GET_USERS              Command = "get-users"
	Command_GET_VCPUS              Command = "get-vcpus"
	Command_INFO                   Command = "info"
	Command_NETWORK_GET_INTERFACES Command = "network-get-interfaces"
	Command_PING                   Command = "ping"
	Command_SHUTDOWN               Command = "shutdown"
	Command_SUSPEND_DISK           Command = "suspend-disk"
	Command_SUSPEND_HYBRID         Command = "suspend-hybrid"
	Command_SUSPEND_RAM            Command = "suspend-ram"
)

func PtrCommand added in v0.0.15

func PtrCommand(i Command) *Command

type CreateRequest

type CreateRequest struct {
	Command Command `url:"command" json:"command"` // The QGA command.
	Node    string  `url:"node" json:"node"`       // The cluster node name.
	Vmid    int     `url:"vmid" json:"vmid"`       // The (unique) ID of the VM.

}

type ExecRequest

type ExecRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

	// The following parameters are optional
	Command   *string `url:"command,omitempty" json:"command,omitempty"`       // The command as a list of program + arguments
	InputData *string `url:"input-data,omitempty" json:"input-data,omitempty"` // Data to pass as 'input-data' to the guest. Usually treated as STDIN to 'command'.
}

type ExecResponse

type ExecResponse struct {
	Pid int `url:"pid" json:"pid"` // The PID of the process started by the guest-agent.

}

type ExecStatusRequest

type ExecStatusRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Pid  int    `url:"pid" json:"pid"`   // The PID to query
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type ExecStatusResponse

type ExecStatusResponse struct {
	Exited util.PVEBool `url:"exited" json:"exited"` // Tells if the given command has exited yet.

	// The following parameters are optional
	ErrData      *string       `url:"err-data,omitempty" json:"err-data,omitempty"`           // stderr of the process
	ErrTruncated *util.PVEBool `url:"err-truncated,omitempty" json:"err-truncated,omitempty"` // true if stderr was not fully captured
	Exitcode     *int          `url:"exitcode,omitempty" json:"exitcode,omitempty"`           // process exit code if it was normally terminated.
	OutData      *string       `url:"out-data,omitempty" json:"out-data,omitempty"`           // stdout of the process
	OutTruncated *util.PVEBool `url:"out-truncated,omitempty" json:"out-truncated,omitempty"` // true if stdout was not fully captured
	Signal       *int          `url:"signal,omitempty" json:"signal,omitempty"`               // signal number or exception code if the process was abnormally terminated.
}

type FileReadRequest

type FileReadRequest struct {
	File string `url:"file" json:"file"` // The path to the file
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type FileReadResponse

type FileReadResponse struct {
	Content string `url:"content" json:"content"` // The content of the file, maximum 16777216

	// The following parameters are optional
	Truncated *util.PVEBool `url:"truncated,omitempty" json:"truncated,omitempty"` // If set to 1, the output is truncated and not complete
}

Returns an object with a `content` property.

type FileWriteRequest

type FileWriteRequest struct {
	Content string `url:"content" json:"content"` // The content to write into the file.
	File    string `url:"file" json:"file"`       // The path to the file.
	Node    string `url:"node" json:"node"`       // The cluster node name.
	Vmid    int    `url:"vmid" json:"vmid"`       // The (unique) ID of the VM.

	// The following parameters are optional
	Encode *util.PVEBool `url:"encode,omitempty" json:"encode,omitempty"` // If set, the content will be encoded as base64 (required by QEMU).Otherwise the content needs to be encoded beforehand - defaults to true.
}

type FsfreezeFreezeRequest

type FsfreezeFreezeRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type FsfreezeStatusRequest

type FsfreezeStatusRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type FsfreezeThawRequest

type FsfreezeThawRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type FstrimRequest

type FstrimRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetFsinfoRequest

type GetFsinfoRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetHostNameRequest

type GetHostNameRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetMemoryBlockInfoRequest

type GetMemoryBlockInfoRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetMemoryBlocksRequest

type GetMemoryBlocksRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetOsinfoRequest

type GetOsinfoRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetTimeRequest

type GetTimeRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetTimezoneRequest

type GetTimezoneRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetUsersRequest

type GetUsersRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type GetVcpusRequest

type GetVcpusRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type HTTPClient

type HTTPClient interface {
	Do(context.Context, string, string, interface{}, interface{}) error
}

type IndexRequest

type IndexRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type InfoRequest

type InfoRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type NetworkGetInterfacesRequest

type NetworkGetInterfacesRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type PingRequest

type PingRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type SetUserPasswordRequest

type SetUserPasswordRequest struct {
	Node     string `url:"node" json:"node"`         // The cluster node name.
	Password string `url:"password" json:"password"` // The new password.
	Username string `url:"username" json:"username"` // The user to set the password for.
	Vmid     int    `url:"vmid" json:"vmid"`         // The (unique) ID of the VM.

	// The following parameters are optional
	Crypted *util.PVEBool `url:"crypted,omitempty" json:"crypted,omitempty"` // set to 1 if the password has already been passed through crypt()
}

type ShutdownRequest

type ShutdownRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type SuspendDiskRequest

type SuspendDiskRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type SuspendHybridRequest

type SuspendHybridRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

type SuspendRamRequest

type SuspendRamRequest struct {
	Node string `url:"node" json:"node"` // The cluster node name.
	Vmid int    `url:"vmid" json:"vmid"` // The (unique) ID of the VM.

}

Jump to

Keyboard shortcuts

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