Skip to content

Commit f93d14c

Browse files
committed
feat(updateplatform): Add Helper support for machineID retrieval
and policy check interval configuration - Added CheckPolicyInterval and GetHardwareIdByHelper fields to the configuration structure; - Added SetCheckPolicyInterval and SetStartCheckRange methods to support dynamic adjustment of policy check configurations; - Updated UpdatePlatformManager to support retrieving the machineID via Helper, and added task ID management and event reporting capabilities; - Implemented the UpdateSourceList method for maintaining private repository source files; - Modified the hardware ID retrieval logic to add functionality for obtaining the hardware ID via the DBus sync helper; - Updated the Token configuration file generation logic to support the new hardware ID retrieval method; - Synchronized Token generation updates in the GatherInfo and CheckPolicy tools to ensure authentication consistency; - Added read/write methods for the cached task ID file to ensure task information persistence and reading accuracy. Task: https://pms.uniontech.com/task-view-385321.html
1 parent 17c9c99 commit f93d14c

15 files changed

Lines changed: 321 additions & 41 deletions

File tree

src/internal/config/config.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ type Config struct {
9292
PlatformUrl string // 更新接口地址
9393
CheckPolicyCron string // 策略检查间隔
9494
StartCheckRange []int // 开机检查更新区间
95+
CheckPolicyInterval int // 策略检查时间间隔(单位:秒)
96+
GetHardwareIdByHelper bool // machineID是否直接从sync helper获取
9597
IncludeDiskInfo bool // machineID是否包含硬盘信息
9698
PostUpgradeCron string // 更新上报间隔
9799
UpdateTime string // 定时更新
@@ -197,6 +199,8 @@ const (
197199
dSettingsKeySecurityRepoType = "security-repo-type"
198200
dSettingsKeyPlatformRepoComponents = "platform-repo-components"
199201
dSettingsKeyIncrementalUpdate = "incremental-update"
202+
dSettingsKeyGetHardwareIdByHelper = "hardware-id-from-helper"
203+
dSettingsKeyCheckPolicyInterval = "check-policy-interval"
200204
)
201205

202206
const configTimeLayout = "2006-01-02T15:04:05.999999999-07:00"
@@ -620,6 +624,24 @@ func getConfigFromDSettings() *Config {
620624
c.SecurityRepoType = RepoType(v.Value().(string))
621625
}
622626

627+
v, err = c.dsLastoreManager.Value(0, dSettingsKeyGetHardwareIdByHelper)
628+
if err != nil {
629+
logger.Warning(err)
630+
} else {
631+
c.GetHardwareIdByHelper = v.Value().(bool)
632+
}
633+
634+
v, err = c.dsLastoreManager.Value(0, dSettingsKeyCheckPolicyInterval)
635+
if err != nil {
636+
logger.Warning(err)
637+
} else {
638+
if val, ok := v.Value().(int64); ok {
639+
c.CheckPolicyInterval = int(val)
640+
} else {
641+
logger.Warningf("dSettings key %s: value is not int64", dSettingsKeyCheckPolicyInterval)
642+
}
643+
}
644+
623645
err = c.recoveryAndApplyOemFlag(system.SystemUpdate)
624646
if err != nil {
625647
logger.Warning(err)
@@ -897,6 +919,16 @@ func (c *Config) SetSecurityRepoType(typ RepoType) error {
897919
return c.save(dSettingsKeySecurityRepoType, typ)
898920
}
899921

922+
func (c *Config) SetCheckPolicyInterval(interval int) error {
923+
c.CheckPolicyInterval = interval
924+
return c.save(dSettingsKeyCheckPolicyInterval, interval)
925+
}
926+
927+
func (c *Config) SetStartCheckRange(checkRange []int) error {
928+
c.StartCheckRange = checkRange
929+
return c.save(dSettingsKeyStartCheckRange, checkRange)
930+
}
931+
900932
const (
901933
onlineCachePath = "/tmp/platform_cache.json"
902934
classifiedCachePath = "/tmp/classified_cache.json"

src/internal/system/system.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import (
1212

1313
const VarLibDir = "/var/lib/lastore"
1414

15+
// TODO: Assign value later
16+
var IsPrivateLastore bool
17+
1518
type Status string
1619

1720
const (

0 commit comments

Comments
 (0)