Documentation ¶
Index ¶
- Constants
- Variables
- func EncryptMsg(data []byte) ([]byte, error)
- func GetArchInfo() (string, error)
- func GetHardwareId(includeDiskInfo bool) string
- func GetOSVersionInfo(filePath string) (map[string]string, error)
- func GetRandomBytes(length uint32) ([]byte, error)
- func IsForceUpdate(tp UpdateTp) bool
- func PKCS7Encode(text []byte, blockSize int) []byte
- func Substr(str string, start int, length int) string
- func UpdateTokenConfigFile(includeDiskInfo bool) string
- type CEVInfo
- type CVEMeta
- type MsgPostStatus
- type Policy
- type PreInstalledPkgMeta
- type ProjectInfo
- type SystemInfo
- type UpdateLogMeta
- type UpdatePlatformManager
- func (m *UpdatePlatformManager) CreateJobPostMsgInfo(uuid string, updateType system.UpdateType)
- func (m *UpdatePlatformManager) GenUpdatePolicyByToken(updateInRelease bool) error
- func (m *UpdatePlatformManager) GetCVEUpdateLogs(pkgs []string) map[string]CEVInfo
- func (m *UpdatePlatformManager) GetRules() []dut.RuleInfo
- func (m *UpdatePlatformManager) GetSystemMeta() map[string]system.PackageInfo
- func (m *UpdatePlatformManager) GetUpdateTarget() string
- func (m *UpdatePlatformManager) PostStatusMessage(body string)
- func (m *UpdatePlatformManager) PostSystemUpgradeMessage(uuid string)
- func (m *UpdatePlatformManager) PostUpdateLogFiles(files []string)
- func (m *UpdatePlatformManager) RecoverVersionLink()
- func (m *UpdatePlatformManager) ReplaceVersionCache()
- func (m *UpdatePlatformManager) RetryPostHistory()
- func (m *UpdatePlatformManager) SaveJobPostMsgByUUID(uuid string, upgradeStatus UpgradeResult, Description string)
- func (m *UpdatePlatformManager) UpdateAllPlatformDataSync() error
- func (m *UpdatePlatformManager) UpdateBaseline()
- func (m *UpdatePlatformManager) UpdateBaselineCache()
- type UpdateTp
- type UpgradePostMsg
- type UpgradeResult
- type Version
Constants ¶
View Source
const ( CacheVersion = "/var/lib/lastore/os-version.b" KeyNow string = "now" // 立即更新 KeyShutdown string = "shutdown" // 关机更新 KeyLayout string = "15:04" )
需要注意cache文件的同步时机,所有数据应该不会从os-version和os-baseline获取
View Source
const ( ReleaseVersion = 1 UnstableVersion = 2 )
View Source
const ( GetVersion requestType = iota GetUpdateLog GetTargetPkgLists // 系统软件包清单 GetCurrentPkgLists GetPkgCVEs // CVE 信息 PostProcess PostResult )
View Source
const ( OemNotCustomState = "0" OemCustomState = "1" )
View Source
const (
BlockSize = 32
)
Variables ¶
View Source
var CVEs map[string]CEVInfo // 保存全局cves信息,方便查询
View Source
var Urls = map[requestType]requestContent{ GetVersion: { "/api/v1/version", "GET", }, GetTargetPkgLists: { "/api/v1/package", "GET", }, GetCurrentPkgLists: { "/api/v1/package", "GET", }, GetUpdateLog: { "/api/v1/systemupdatelogs", "GET", }, GetPkgCVEs: { "/api/v1/cve/sync", "GET", }, PostProcess: { "/api/v1/process", "POST", }, PostResult: { "/api/v1/update/status", "POST", }, }
Functions ¶
func EncryptMsg ¶
func GetArchInfo ¶
func GetHardwareId ¶
func GetRandomBytes ¶
GetRandomBytes 根据需要长度,生成随机字符
func IsForceUpdate ¶
func PKCS7Encode ¶
PKCS7Encode 对需要加密的明文进行填充补位 * @param text 需要进行填充补位操作的明文 * @return 补齐明文字符串
func UpdateTokenConfigFile ¶
UpdateTokenConfigFile 更新 99lastore-token.conf 文件的内容
Types ¶
type CEVInfo ¶
type CEVInfo struct { SyncTime string `json:"synctime"` // "CVE类型" CveId string `json:"cveId"` // "CVE编号" Source string `json:"source"` // "包名" FixedVersion string `json:"fixedVersion"` // "修复版本" Archs string `json:"archs"` // "架构信息" Score string `json:"score"` // "评分" Status string `json:"status"` // "修复状态" VulCategory string `json:"vulCategory"` // "漏洞类型" VulName string `json:"vulName"` // "漏洞名称" VulLevel string `json:"vulLevel"` // "⻛险等级" PubTime string `json:"pubTime"` // "CVE公开时间" Binary string `json:"binary"` // "二进制包" Description string `json:"description"` // "漏洞描述" CveDescription string `json:"cveDescription"` // "漏洞描述(英文)" }
type MsgPostStatus ¶
type MsgPostStatus string
MsgPostStatus 更新结果上报状态
const ( NotReady MsgPostStatus = "not ready" WaitPost MsgPostStatus = "wait post" PostSuccess MsgPostStatus = "post success" PostFailure MsgPostStatus = "post failure" )
type PreInstalledPkgMeta ¶
type ProjectInfo ¶
type ProjectInfo struct {
Id string `json:"id"`
}
type SystemInfo ¶
type UpdateLogMeta ¶
type UpdateLogMeta struct { Baseline string `json:"baseline"` ShowVersion string `json:"showVersion"` CnLog string `json:"cnLog"` EnLog string `json:"enLog"` LogType int `json:"logType"` IsUnstable int `json:"isUnstable"` SystemVersion string `json:"systemVersion"` PublishTime time.Time `json:"publishTime"` }
type UpdatePlatformManager ¶
type UpdatePlatformManager struct { PreCheck string // 更新前检查脚本 MidCheck string // 更新中检查脚本 PostCheck string // 更新后检查脚本 TargetCorePkgs map[string]system.PackageInfo // 必须安装软件包信息清单 对应dut的core list BaselinePkgs map[string]system.PackageInfo // 当前版本的核心软件包清单 对应dut的baseline SelectPkgs map[string]system.PackageInfo // 可选软件包清单 FreezePkgs map[string]system.PackageInfo // 禁止升级包清单 PurgePkgs map[string]system.PackageInfo // 删除软件包清单 SystemUpdateLogs []UpdateLogMeta // 更新注记 Token string Tp UpdateTp // 更新策略类型:1.非强制更新,2.强制更新/立即更新,3.强制更新/关机或重启时更新,4.强制更新/指定时间更新 UpdateTime time.Time // 更新时间(指定时间更新时的时间) UpdateNowForce bool // 立即更新 // contains filtered or unexported fields }
func NewUpdatePlatformManager ¶
func NewUpdatePlatformManager(c *Config, updateToken bool) *UpdatePlatformManager
func (*UpdatePlatformManager) CreateJobPostMsgInfo ¶
func (m *UpdatePlatformManager) CreateJobPostMsgInfo(uuid string, updateType system.UpdateType)
CreateJobPostMsgInfo 初始化创建上报信息
func (*UpdatePlatformManager) GenUpdatePolicyByToken ¶
func (m *UpdatePlatformManager) GenUpdatePolicyByToken(updateInRelease bool) error
func (*UpdatePlatformManager) GetCVEUpdateLogs ¶
func (m *UpdatePlatformManager) GetCVEUpdateLogs(pkgs []string) map[string]CEVInfo
func (*UpdatePlatformManager) GetRules ¶
func (m *UpdatePlatformManager) GetRules() []dut.RuleInfo
func (*UpdatePlatformManager) GetSystemMeta ¶
func (m *UpdatePlatformManager) GetSystemMeta() map[string]system.PackageInfo
func (*UpdatePlatformManager) GetUpdateTarget ¶
func (m *UpdatePlatformManager) GetUpdateTarget() string
func (*UpdatePlatformManager) PostStatusMessage ¶
func (m *UpdatePlatformManager) PostStatusMessage(body string)
PostStatusMessage 将检查\下载\安装过程中所有异常状态和每个阶段成功的正常状态上报
func (*UpdatePlatformManager) PostSystemUpgradeMessage ¶
func (m *UpdatePlatformManager) PostSystemUpgradeMessage(uuid string)
PostSystemUpgradeMessage 发送系统更新成功或失败的状态
func (*UpdatePlatformManager) PostUpdateLogFiles ¶
func (m *UpdatePlatformManager) PostUpdateLogFiles(files []string)
PostUpdateLogFiles 将更新日志上传
func (*UpdatePlatformManager) RecoverVersionLink ¶
func (m *UpdatePlatformManager) RecoverVersionLink()
RecoverVersionLink 安装更新并检查完成后,需要用软连接替换文件
func (*UpdatePlatformManager) ReplaceVersionCache ¶
func (m *UpdatePlatformManager) ReplaceVersionCache()
进行安装更新前,需要复制文件替换软连接
func (*UpdatePlatformManager) RetryPostHistory ¶
func (m *UpdatePlatformManager) RetryPostHistory()
func (*UpdatePlatformManager) SaveJobPostMsgByUUID ¶
func (m *UpdatePlatformManager) SaveJobPostMsgByUUID(uuid string, upgradeStatus UpgradeResult, Description string)
SaveJobPostMsgByUUID 需要在success或failed状态迁移前调用,保证数据存储
func (*UpdatePlatformManager) UpdateAllPlatformDataSync ¶
func (m *UpdatePlatformManager) UpdateAllPlatformDataSync() error
UpdateAllPlatformDataSync 同步获取所有需要从更新平台获取的数据
func (*UpdatePlatformManager) UpdateBaseline ¶
func (m *UpdatePlatformManager) UpdateBaseline()
UpdateBaseline 更新安装并检查成功后,同步baseline文件
func (*UpdatePlatformManager) UpdateBaselineCache ¶
func (m *UpdatePlatformManager) UpdateBaselineCache()
type UpgradePostMsg ¶
type UpgradePostMsg struct { SerialNumber string `json:"serialNumber"` MachineID string `json:"machineId"` UpgradeStatus UpgradeResult `json:"status"` UpgradeErrorMsg string `json:"msg"` TimeStamp int64 `json:"timestamp"` SourceUrl []string `json:"sourceUrl"` Version string `json:"version"` PreBuild string `json:"preBuild"` NextShowVersion string `json:"nextShowVersion"` PreBaseline string `json:"preBaseline"` NextBaseline string `json:"nextBaseline"` UpgradeStartTime int64 `json:"updateStartAt"` UpgradeEndTime int64 `json:"updateFinishAt"` Uuid string PostStatus MsgPostStatus RetryCount uint32 // contains filtered or unexported fields }
type UpgradeResult ¶
type UpgradeResult int8
const ( UpgradeSucceed UpgradeResult = 0 UpgradeFailed UpgradeResult = 1 CheckFailed UpgradeResult = 2 )
Click to show internal directories.
Click to hide internal directories.