Documentation ¶
Overview ¶
Package proxmox implements the VMProvider and ContainerProvider methods It makes requests to the Proxmox VE on behalf of Raijin
Index ¶
- func ErrorJSON(err error) string
- func GenerateMAC() (net.HardwareAddr, error)
- func HashPassword(password string) string
- func MustDecodeJSON(body io.Reader, target interface{})
- func MustGetInt(r *http.Request, name string) int
- func MustGetString(r *http.Request, name string) string
- func MustMarshalJSON(input interface{}) []byte
- func MustReadAll(r io.Reader) string
- type AuthResponse
- type AuthTicketResponse
- type Client
- func (c *Client) ContainerAdd(container *Resource) error
- func (c *Client) ContainerConfig(params *ContainerConfigRequest) (*ContainerConfig, error)
- func (c *Client) ContainerCreate(params *ContainerCreateRequest) error
- func (c *Client) ContainerDelete(node string, vmid int) error
- func (c *Client) ContainerResume(params *ContainerVMStatusRequest) error
- func (c *Client) ContainerShutdown(params *ContainerVMStatusRequest) error
- func (c *Client) ContainerStart(params *ContainerVMStatusRequest) error
- func (c *Client) ContainerStop(params *ContainerVMStatusRequest) error
- func (c *Client) ContainerUpdate(container *Resource) error
- func (c *Client) ISOList(node string) ([]string, error)
- func (c *Client) NextID() (int, error)
- func (c *Client) NodeStatus(node string) (*NodeStatus, error)
- func (c *Client) PickNode() (string, error)
- func (c *Client) ResourceList() (Resources, error)
- func (c *Client) SignIn() error
- func (c *Client) StorageCreate(vmid, size string) error
- func (c *Client) TemplateList(node string) ([]*Template, error)
- func (c *Client) VerifyTicket() (bool, error)
- type ContainerConfig
- type ContainerConfigRequest
- type ContainerConfigResponse
- type ContainerCreateRequest
- type ContainerVMStatusRequest
- type Error
- type ISO
- type ISOListResponse
- type NextIDResponse
- type NodeStatus
- type NodeStatusResponse
- type ParsedTemplate
- type RaijinTemplate
- type Resource
- type Resources
- type ResourcesResponse
- type Service
- type Template
- type TemplateListResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateMAC ¶
func GenerateMAC() (net.HardwareAddr, error)
GenerateMAC is pulled from https://stackoverflow.com/questions/21018729/generate-mac-address-in-go
func HashPassword ¶
HashPassword encrypts a plaintext string and returns the hashed version
func MustDecodeJSON ¶
MustDecodeJSON receives a pointer to struct, and updates the struct values with the values from the JSON in the http request
func MustGetInt ¶
MustGetInt will get an integer from ninjarouter URL or panic
func MustGetString ¶
MustGetString will get an string from ninjarouter URL or panic
func MustMarshalJSON ¶
func MustMarshalJSON(input interface{}) []byte
MustMarshalJSON will return a byte array representation of a struct
func MustReadAll ¶
MustReadAll will read the response body as a string
Types ¶
type AuthResponse ¶
AuthResponse is the response from the Proxmox API container the CSRF token and ticket for authenticated requests
type AuthTicketResponse ¶
type AuthTicketResponse struct { Data struct { Ticket string `json:"ticket"` Username string `json:"username"` CSRFPreventionToken string `json:"CSRFPreventionToken"` } `json:"data"` }
AuthTicketResponse is the response from the Proxmox API after a successful auth
type Client ¶
Client contains the state for the proxmox client
func (*Client) ContainerAdd ¶
ContainerAdd runs the Add action for the Proxmox containers
func (*Client) ContainerConfig ¶
func (c *Client) ContainerConfig(params *ContainerConfigRequest) (*ContainerConfig, error)
ContainerConfig returns the container config
func (*Client) ContainerCreate ¶
func (c *Client) ContainerCreate(params *ContainerCreateRequest) error
ContainerCreate runs the Create action for the Proxmox containers
func (*Client) ContainerDelete ¶
ContainerDelete runs the Delete action for the Proxmox containers
func (*Client) ContainerResume ¶
func (c *Client) ContainerResume(params *ContainerVMStatusRequest) error
ContainerResume will start the container
func (*Client) ContainerShutdown ¶
func (c *Client) ContainerShutdown(params *ContainerVMStatusRequest) error
ContainerShutdown will shutdown the container
func (*Client) ContainerStart ¶
func (c *Client) ContainerStart(params *ContainerVMStatusRequest) error
ContainerStart will start the container
func (*Client) ContainerStop ¶
func (c *Client) ContainerStop(params *ContainerVMStatusRequest) error
ContainerStop will stop the container
func (*Client) ContainerUpdate ¶
ContainerUpdate runs the Update action for the Proxmox containers
func (*Client) NodeStatus ¶
func (c *Client) NodeStatus(node string) (*NodeStatus, error)
NodeStatus returns the Node's RAM, CPU and storage
func (*Client) ResourceList ¶
ResourceList runs the List action for the Proxmox resources
func (*Client) StorageCreate ¶
StorageCreate will create a storage for a VM
func (*Client) TemplateList ¶
TemplateList returns a list of templates
func (*Client) VerifyTicket ¶
VerifyTicket confirms that the currently held ticket in the client is valid
type ContainerConfig ¶
type ContainerConfig struct { Memory int `json:"memory"` Cpulimit string `json:"cpulimit"` Digest string `json:"digest"` Cores int `json:"cores"` Ostype string `json:"ostype"` Rootfs string `json:"rootfs"` Hostname string `json:"hostname"` Arch string `json:"arch"` Description string `json:"description"` Swap int `json:"swap"` Net0 string `json:"net0"` }
ContainerConfig is the response from the Proxmox API for a VM's configuration
type ContainerConfigRequest ¶
ContainerConfigRequest is a request to the Proxmox API for a VM's configuration
type ContainerConfigResponse ¶
type ContainerConfigResponse struct {
Data *ContainerConfig `json:"data"`
}
ContainerConfigResponse is the response from the Proxmox API for a VM's configuration
type ContainerCreateRequest ¶
type ContainerCreateRequest struct { MAC string Template *ParsedTemplate Node string VMID int CPUCores int Memory int StorageCapacity int StorageID string SSHPublicKey string Password string HostName string IPAddress string }
ContainerCreateRequest is a request to the Proxmox API to create a container
type ContainerVMStatusRequest ¶
ContainerVMStatusRequest is the request for the Proxmox API to modify a container or VM's status
type Error ¶
type Error struct {
Message string
}
Error is a struct with which we can marshal into JSON for a HTTP response
type ISO ¶
type ISO struct { Content string `json:"content"` Volid string `json:"volid"` Format string `json:"format"` Size int `json:"size"` }
ISO is the response from the proxmox API for ISO content in a storage
type ISOListResponse ¶
type ISOListResponse struct {
Data []*ISO `json:"data"`
}
ISOListResponse is a list of ISOs from the Proxmox API
type NextIDResponse ¶
type NextIDResponse struct {
Data string `json:"data"`
}
NextIDResponse is the next available VMID from the Proxmox API
type NodeStatus ¶
type NodeStatus struct { CPU int `json:"cpu"` Cpuinfo struct { Cpus int `json:"cpus"` Hvm int `json:"hvm"` Mhz string `json:"mhz"` Model string `json:"model"` Sockets int `json:"sockets"` UserHz int `json:"user_hz"` } `json:"cpuinfo"` Idle int `json:"idle"` Ksm struct { Shared int `json:"shared"` } `json:"ksm"` Kversion string `json:"kversion"` Loadavg []string `json:"loadavg"` Memory struct { Free int64 `json:"free"` Total int64 `json:"total"` Used int `json:"used"` } `json:"memory"` Pveversion string `json:"pveversion"` Rootfs struct { Avail int64 `json:"avail"` Free int64 `json:"free"` Total int64 `json:"total"` Used int64 `json:"used"` } `json:"rootfs"` Swap struct { Free int64 `json:"free"` Total int64 `json:"total"` Used int `json:"used"` } `json:"swap"` Uptime int `json:"uptime"` Wait int `json:"wait"` }
NodeStatus is the response from the Proxmox API
type NodeStatusResponse ¶
type NodeStatusResponse struct {
Data *NodeStatus `json:"data"`
}
NodeStatusResponse is the response from the Proxmox API for a node's status
type ParsedTemplate ¶
type ParsedTemplate struct { OS string OSVersion string Name string OSVersion2 string Arch string Extension string }
ParsedTemplate is the result of magical regex on a filepath to get template info
func (*ParsedTemplate) String ¶
func (pt *ParsedTemplate) String() string
String returns a string version of the template struct
type RaijinTemplate ¶
type RaijinTemplate struct { OS string `json:"os"` OSVersion string `json:"osVersion"` Name string `json:"Name"` OSVersion2 string `json:"osVersion2"` Arch string `json:"arch"` Extension string `json:"extension"` }
RaijinTemplate is the values needed to create a container based on a template
func ParseTemplate ¶
func ParseTemplate(templateStr string) (*RaijinTemplate, error)
ParseTemplate will convert a proxmox template string into a struct
type Resource ¶
type Resource struct { CPU float64 `json:"cpu,omitempty"` Disk int `json:"disk,omitempty"` Diskread int `json:"diskread,omitempty"` Diskwrite int `json:"diskwrite,omitempty"` ID string `json:"id"` Maxcpu int `json:"maxcpu,omitempty"` Maxdisk int64 `json:"maxdisk,omitempty"` Maxmem int `json:"maxmem,omitempty"` Mem int `json:"mem,omitempty"` Name string `json:"name,omitempty"` Netin int `json:"netin,omitempty"` Netout int `json:"netout,omitempty"` Node string `json:"node"` Status string `json:"status,omitempty"` Template int `json:"template,omitempty"` Type string `json:"type"` Uptime int `json:"uptime,omitempty"` Vmid int `json:"vmid,omitempty"` Level string `json:"level,omitempty"` Storage string `json:"storage,omitempty"` }
Resource is a VM, container or storage on proxmox
type Resources ¶
type Resources []*Resource
Resources is a list of resources from the Proxmox API
func (Resources) Containers ¶
Containers returns a slice of containers from the Proxmox API
func (Resources) GetNodeFromVMID ¶
GetNodeFromVMID will return a VM's node
type ResourcesResponse ¶
type ResourcesResponse struct {
Data []*Resource `json:"data"`
}
ResourcesResponse is a list of Resources from the Proxmox API
type Service ¶
type Service interface { SignIn() error VerifyTicket() (bool, error) ResourceList() (Resources, error) PickNode() (string, error) ContainerCreate(*ContainerCreateRequest) error ContainerStop(*ContainerVMStatusRequest) error ContainerStart(*ContainerVMStatusRequest) error ContainerShutdown(*ContainerVMStatusRequest) error ContainerResume(*ContainerVMStatusRequest) error ContainerDelete(node string, vmid int) error ContainerConfig(*ContainerConfigRequest) (*ContainerConfig, error) TemplateList(node string) ([]*Template, error) ISOList(node string) ([]string, error) NextID() (int, error) }
Service contains the methods that the proxmox client provides
type Template ¶
type Template struct { Content string `json:"content"` Volid string `json:"volid"` Format string `json:"format"` Size int `json:"size"` }
Template is the values needed to create a container based on a template
type TemplateListResponse ¶
type TemplateListResponse struct {
Data []*Template `json:"data"`
}
TemplateListResponse is a list of Templates