Documentation ¶
Index ¶
- Constants
- Variables
- func MakePoolName(namespace, name string) string
- func MarshalUserData(u *UserData) ([]byte, error)
- func NewURL(node, id string) string
- func ParseURL(s string) (node, id string, err error)
- type APTConfig
- type APTSource
- type Client
- type ClientOption
- type File
- type IPConfig
- type IPConfigs
- type NTP
- type Nameserver
- type NetworkDevice
- type NetworkDevices
- type Node
- type NodeClient
- func (c *NodeClient) FindServer(ctx context.Context, name, id string) (s *Server, err error)
- func (c *NodeClient) FindServerByID(ctx context.Context, id string) (s *Server, err error)
- func (c *NodeClient) FindServerByName(ctx context.Context, name string) (s *Server, err error)
- func (c *NodeClient) FindServerByURL(ctx context.Context, url string) (s *Server, err error)
- func (c *NodeClient) List(ctx context.Context) (nl NodeList, err error)
- func (c *NodeClient) ListServers(ctx context.Context, n *Node) (sl ServerList, err error)
- type NodeList
- type NodeStatus
- type OnTaskChange
- type PoolClient
- type Resources
- type Server
- type ServerClient
- func (c *ServerClient) CreateFromTemplate(ctx context.Context, opts ServerTemplateOpts) (t *Task, url string, err error)
- func (c *ServerClient) Delete(ctx context.Context, s *Server, f OnTaskChange) (t *Task, err error)
- func (c *ServerClient) GetByURL(ctx context.Context, url string) (s *Server, err error)
- func (c *ServerClient) GetStatus(ctx context.Context, s *Server, lock *string) (err error)
- func (c *ServerClient) NextID(ctx context.Context) (id string, err error)
- func (c *ServerClient) Reboot(ctx context.Context, s *Server) (t *Task, err error)
- func (c *ServerClient) Reset(ctx context.Context, s *Server) (t *Task, err error)
- func (c *ServerClient) Resume(ctx context.Context, s *Server) (t *Task, err error)
- func (c *ServerClient) Shutdown(ctx context.Context, s *Server) (t *Task, err error)
- func (c *ServerClient) Start(ctx context.Context, s *Server) (t *Task, err error)
- func (c *ServerClient) Stop(ctx context.Context, s *Server) (t *Task, err error)
- func (c *ServerClient) Suspend(ctx context.Context, s *Server) (t *Task, err error)
- func (c *ServerClient) Update(ctx context.Context, s *Server) (err error)
- type ServerList
- type ServerStatus
- type ServerTemplateOpts
- type Task
- type TaskClient
- type User
- type UserData
Constants ¶
View Source
const ( TaskTimeout = 300 TaskStatusCheckInterval = 2 TaskExitStatusOK = "OK" TaskStatusRunning = "running" TaskStatusStopped = "stopped" )
View Source
const PVEScheme = "pve"
Variables ¶
View Source
var ( ErrPoolExists = errors.New("pool already exists") ErrPoolNotExists = errors.New("pool does not exist") )
View Source
var ErrInvalidPVEURL = errors.New("invalid pve url scheme")
View Source
var ErrServerNotFound = errors.New("server not found")
View Source
var HTTPErr = errors.New("http error")
Functions ¶
func MakePoolName ¶
func MarshalUserData ¶
Types ¶
type Client ¶
type Client struct { sync.Mutex Server ServerClient Task TaskClient Pool PoolClient Node NodeClient // contains filtered or unexported fields }
func NewClient ¶
func NewClient(options ...ClientOption) *Client
type ClientOption ¶
type ClientOption func(*Client)
func WithCredentials ¶
func WithCredentials(username, password string) ClientOption
func WithDebugWriter ¶
func WithDebugWriter(debugWriter io.Writer) ClientOption
func WithEndpoint ¶
func WithEndpoint(endpoint string) ClientOption
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
func WithInsecureClient ¶
func WithInsecureClient(insecure bool) ClientOption
type IPConfig ¶
type Nameserver ¶
type Nameserver []string
func (Nameserver) String ¶
func (n Nameserver) String() string
type NetworkDevice ¶
func (*NetworkDevice) String ¶
func (n *NetworkDevice) String() string
type NetworkDevices ¶
type NetworkDevices []*NetworkDevice
func (NetworkDevices) Get ¶
func (c NetworkDevices) Get(index int) *NetworkDevice
type Node ¶
type Node struct { Name string `json:"node"` Status NodeStatus `json:"status"` }
type NodeClient ¶
type NodeClient struct {
// contains filtered or unexported fields
}
func (*NodeClient) FindServer ¶
func (*NodeClient) FindServerByID ¶
func (*NodeClient) FindServerByName ¶
func (*NodeClient) FindServerByURL ¶
func (*NodeClient) ListServers ¶
func (c *NodeClient) ListServers(ctx context.Context, n *Node) (sl ServerList, err error)
type NodeStatus ¶
type NodeStatus string
const ( NodeStatusOnline NodeStatus = "online" NodeStatusOffline NodeStatus = "offline" NodeStatusUnknown NodeStatus = "unknown" )
type OnTaskChange ¶
type OnTaskChange func(t *Task)
type PoolClient ¶
type PoolClient struct {
// contains filtered or unexported fields
}
type Server ¶
type Server struct { ID string `json:"vmid"` Name string `json:"name"` Node string Status ServerStatus `json:"status"` Resources Resources NetDevices NetworkDevices IPConfig IPConfigs Nameserver Nameserver SearchDomain string UserData *UserData }
func (*Server) InstanceID ¶
type ServerClient ¶
type ServerClient struct {
// contains filtered or unexported fields
}
func (*ServerClient) CreateFromTemplate ¶
func (c *ServerClient) CreateFromTemplate(ctx context.Context, opts ServerTemplateOpts) (t *Task, url string, err error)
func (*ServerClient) Delete ¶
func (c *ServerClient) Delete(ctx context.Context, s *Server, f OnTaskChange) (t *Task, err error)
func (*ServerClient) NextID ¶
func (c *ServerClient) NextID(ctx context.Context) (id string, err error)
type ServerList ¶
type ServerList []*Server
type ServerStatus ¶
type ServerStatus string
const ( ServerStatusInitializing ServerStatus = "initializing" ServerStatusStarting ServerStatus = "starting" ServerStatusStopping ServerStatus = "stopping" ServerStatusRebooting ServerStatus = "rebooting" ServerStatusRunning ServerStatus = "running" ServerStatusStopped ServerStatus = "stopped" ServerStatusDeleting ServerStatus = "deleting" ServerStatusUnknown ServerStatus = "unknown" ServerStatusBackup ServerStatus = "backup" ServerStatusMigrating ServerStatus = "migrating" ServerStatusSnapshoting ServerStatus = "snapshoting" ServerStatusRollback ServerStatus = "rollback" ServerStatusSespending ServerStatus = "suspending" ServerStatusSespended ServerStatus = "suspended" ServerStatusResuming ServerStatus = "resuming" )
func ServerStatusFromLock ¶
func ServerStatusFromLock(status, lock string) ServerStatus
func ServerStatusFromTask ¶
func ServerStatusFromTask(t *Task) ServerStatus
type ServerTemplateOpts ¶
type ServerTemplateOpts struct { Name string TemplateURL string Pool string TargetStorage string TargetNode string }
func (ServerTemplateOpts) Validate ¶
func (o ServerTemplateOpts) Validate() error
type TaskClient ¶
type TaskClient struct {
// contains filtered or unexported fields
}
func (*TaskClient) MustGet ¶
func (c *TaskClient) MustGet(ctx context.Context, taskid string) (t *Task)
func (*TaskClient) Wait ¶
func (c *TaskClient) Wait(ctx context.Context, t *Task, f OnTaskChange) error
type User ¶
type User struct { Name string `yaml:"name"` Gecos *string `yaml:"gecos,omitempty"` Groups *string `yaml:"groups,omitempty"` HomeDir *string `yaml:"homedir,omitempty"` Inactive *bool `yaml:"inactive,omitempty"` Shell *string `yaml:"shell,omitempty"` Passwd *string `yaml:"passwd,omitempty"` PrimaryGroup *string `yaml:"primary_group,omitempty"` LockPassword *bool `yaml:"lock_passwd,omitempty"` Sudo *string `yaml:"sudo,omitempty"` SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys,omitempty"` }
type UserData ¶
type UserData struct { Hostname string `yaml:"hostname"` ManageEtcHosts bool `yaml:"manage_etc_hosts,omitempty"` SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys,omitempty"` PackageUpdate bool `yaml:"package_update,omitempty"` PackageUpgrade bool `yaml:"package_upgrade,omitempty"` APT APTConfig `yaml:"apt,omitempty"` NTP NTP `yaml:"ntp,omitempty"` Users []User `yaml:"users,omitempty"` Packages [][]string `yaml:"packages,omitempty"` Runcmd []string `yaml:"runcmd,omitempty"` FinalMessage string `yaml:"final_message,omitempty"` WriteFiles []File `yaml:"write_files,omitempty"` }
func UnmarshalUserData ¶
Click to show internal directories.
Click to hide internal directories.