service

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VMJobStatus = VMJobStatusMap{}

Functions

func GenerateAgentToken

func GenerateAgentToken() string

GenerateAgentToken TODO: consider how to generate vm token

func GetObjectPath

func GetObjectPath(subFolder, name string) string

func ListVMLabels

func ListVMLabels(projectKey string, logger *zap.SugaredLogger) ([]string, error)

func OfflineVM

func OfflineVM(idString, user string, logger *zap.SugaredLogger) error

Types

type AgentAccessCmd

type AgentAccessCmd struct {
	AMD64 map[string]string `json:"amd64"`
	ARM64 map[string]string `json:"arm64"`
}

type AgentAccessCmds

type AgentAccessCmds struct {
	LinuxPlatform *AgentAccessCmd `json:"linux_platform,omitempty"`
	MacOSPlatform *AgentAccessCmd `json:"macos_platform,omitempty"`
	WinPlatform   *AgentAccessCmd `json:"windows_platform,omitempty"`
}

func GenerateAgentAccessCmds

func GenerateAgentAccessCmds(vm *commonmodels.PrivateKey) (*AgentAccessCmds, error)

func GetAgentAccessCmd

func GetAgentAccessCmd(vmID string, logger *zap.SugaredLogger) (*AgentAccessCmds, error)

type AgentBriefListResp

type AgentBriefListResp struct {
	Name         string `json:"name"`
	Label        string `json:"label"`
	Status       string `json:"status"`
	Error        string `json:"error"`
	Platform     string `json:"platform"`
	Architecture string `json:"architecture"`
	IP           string `json:"ip"`
}

func ListVMs

func ListVMs(logger *zap.SugaredLogger) ([]*AgentBriefListResp, error)

type AgentDetails

type AgentDetails struct {
	Name             string   `json:"name"`
	Description      string   `json:"description"`
	Provider         string   `json:"provider"`
	Tags             []string `json:"tags"`
	VMIP             string   `json:"ip"`
	VMPort           int      `json:"port"`
	VMUser           string   `json:"user"`
	LoginHost        bool     `json:"login_host"`
	SSHPrivateKey    string   `json:"ssh_private_key"`
	ScheduleWorkflow bool     `json:"schedule_workflow"`
	Workspace        string   `json:"workspace"`
	TaskConcurrency  int      `json:"task_concurrency"`
	Status           string   `json:"status"`
	Error            string   `json:"error"`
	Platform         string   `json:"platform"`
	Architecture     string   `json:"architecture"`
}

type CreateVMRequest

type CreateVMRequest struct {
	Name             string   `json:"name"`
	Description      string   `json:"description"`
	Provider         string   `json:"provider"`
	Tags             []string `json:"tags"`
	VMIP             string   `json:"ip"`
	VMPort           int      `json:"port"`
	VMUser           string   `json:"user"`
	LoginHost        bool     `json:"login_host"`
	SSHPrivateKey    string   `json:"ssh_private_key"`
	ScheduleWorkflow bool     `json:"schedule_workflow"`
	Workspace        string   `json:"workspace"`
	TaskConcurrency  int      `json:"task_concurrency"`
}

func (*CreateVMRequest) Validate

func (args *CreateVMRequest) Validate() error

type HeartbeatParameters

type HeartbeatParameters struct {
	MemTotal      uint64 `json:"mem_total"`
	UsedMem       uint64 `json:"used_mem"`
	DiskSpace     uint64 `json:"disk_space"`
	FreeDiskSpace uint64 `json:"free_disk_space"`
	VMname        string `json:"vm_name"`
}

type HeartbeatRequest

type HeartbeatRequest struct {
	Token      string               `json:"token"`
	Parameters *HeartbeatParameters `json:"parameters"`
}

type HeartbeatResponse

type HeartbeatResponse struct {
	NeedOffline            bool         `json:"need_offline"`
	NeedUpdateAgentVersion bool         `json:"need_update_agent_version"`
	AgentVersion           string       `json:"agent_version"`
	ScheduleWorkflow       bool         `json:"schedule_workflow"`
	WorkDir                string       `json:"work_dir"`
	Concurrency            int          `json:"concurrency"`
	CacheType              string       `json:"cache_type"`
	CachePath              string       `json:"cache_path"`
	Object                 ObjectConfig `json:"object"`
	ServerURL              string       `json:"server_url"`
	VmName                 string       `json:"vm_name"`
	Description            string       `json:"description"`
	ZadigVersion           string       `json:"zadig_version"`
}

func Heartbeat

func Heartbeat(args *HeartbeatRequest, logger *zap.SugaredLogger) (*HeartbeatResponse, error)

type ObjectConfig

type ObjectConfig struct {
}

type PollingJobArgs

type PollingJobArgs struct {
	Token string `json:"token"`
}

type PollingJobResp

type PollingJobResp struct {
	ID            string `json:"id"`
	ProjectName   string `json:"project_name"`
	WorkflowName  string `json:"workflow_name"`
	TaskID        int64  `json:"task_id"`
	JobOriginName string `json:"job_origin_name"`
	JobName       string `json:"job_name"`
	JobType       string `json:"job_type"`
	Status        string `json:"status"`
	JobCtx        string `json:"job_ctx"`
}

func PollingAgentJob

func PollingAgentJob(token string, retry int, logger *zap.SugaredLogger) (*PollingJobResp, error)

type RecoveryAgentCmd

type RecoveryAgentCmd struct {
	RecoveryCmd map[string]string `json:"recovery_cmd"`
}

func RecoveryVM

func RecoveryVM(idString, user string, logger *zap.SugaredLogger) (*RecoveryAgentCmd, error)

type RegisterAgentParameters

type RegisterAgentParameters struct {
	IP            string `json:"ip"`
	OS            string `json:"os"`
	Arch          string `json:"arch"`
	CurrentUser   string `json:"current_user"`
	MemTotal      uint64 `json:"mem_total"`
	UsedMem       uint64 `json:"used_mem"`
	CpuNum        int    `json:"cpu_num"`
	DiskSpace     uint64 `json:"disk_space"`
	FreeDiskSpace uint64 `json:"free_disk_space"`
	HostName      string `json:"host_name"`
	AgentVersion  string `json:"agent_version"`
	WorkDir       string `json:"work_dir"`
}

type RegisterAgentRequest

type RegisterAgentRequest struct {
	Token      string                   `json:"token"`
	Parameters *RegisterAgentParameters `json:"parameters"`
}

func (*RegisterAgentRequest) Validate

func (args *RegisterAgentRequest) Validate() error

type RegisterAgentResponse

type RegisterAgentResponse struct {
	Token            string `json:"token"`
	Description      string `json:"description"`
	VmName           string `json:"vm_name"`
	ScheduleWorkflow bool   `json:"schedule_workflow"`
	TaskConcurrency  int    `json:"task_concurrency"`
	AgentVersion     string `json:"agent_version"`
	ZadigVersion     string `json:"zadig_version"`
	WorkDir          string `json:"work_dir"`
}

func RegisterAgent

func RegisterAgent(args *RegisterAgentRequest, logger *zap.SugaredLogger) (*RegisterAgentResponse, error)

type ReportAgentJobResp

type ReportAgentJobResp struct {
	JobID     string `json:"job_id"`
	JobStatus string `json:"job_status"`
}

func ReportAgentJob

func ReportAgentJob(args *ReportJobArgs, logger *zap.SugaredLogger) (*ReportAgentJobResp, error)

type ReportJobArgs

type ReportJobArgs struct {
	Seq       int    `json:"seq"`
	Token     string `json:"token"`
	JobID     string `json:"job_id"`
	JobStatus string `json:"job_status"`
	JobLog    string `json:"job_log"`
	JobError  string `json:"job_error"`
	JobOutput []byte `json:"job_output"`
}

type UpgradeAgentCmd

type UpgradeAgentCmd struct {
	UpgradeCmd map[string]string `json:"upgrade_cmd"`
	Upgrade    bool              `json:"upgrade"`
}

func UpgradeAgent

func UpgradeAgent(idString, user string, logger *zap.SugaredLogger) (*UpgradeAgentCmd, error)

type VMJobGetterMap

type VMJobGetterMap struct {
	M         sync.Mutex
	GetterMap map[string]struct{}
}

func (*VMJobGetterMap) AddGetter

func (m *VMJobGetterMap) AddGetter(jobID string) bool

func (*VMJobGetterMap) RemoveGetter

func (m *VMJobGetterMap) RemoveGetter(jobID string)

type VMJobStatusMap

type VMJobStatusMap struct {
}

func (*VMJobStatusMap) Delete

func (v *VMJobStatusMap) Delete(key string)

func (*VMJobStatusMap) Exists

func (v *VMJobStatusMap) Exists(key string) bool

func (*VMJobStatusMap) Set

func (v *VMJobStatusMap) Set(key string)

type VerifyAgentParameters

type VerifyAgentParameters struct {
	IP   string `json:"ip"`
	OS   string `json:"os"`
	Arch string `json:"arch"`
}

type VerifyAgentRequest

type VerifyAgentRequest struct {
	Token      string                 `json:"token"`
	Parameters *VerifyAgentParameters `json:"parameters"`
}

type VerifyAgentResponse

type VerifyAgentResponse struct {
	Verified bool `json:"verified"`
}

func VerifyAgent

func VerifyAgent(args *VerifyAgentRequest, logger *zap.SugaredLogger) (*VerifyAgentResponse, error)

Jump to

Keyboard shortcuts

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