Skip to content

Commit e8d8a5a

Browse files
authored
[PCD-3023] Enable Alma Linux 10 Support in pcd-ctl (#422)
* Export functions used in check node * RHEL support for hostagent progress bar
1 parent fb1b1b4 commit e8d8a5a

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

pkg/platform/centos/centos.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,44 @@ func NewCentOS(exec cmdexec.Executor) *CentOS {
3838
func (c *CentOS) Check() []platform.Check {
3939
var checks []platform.Check
4040

41-
result, err := c.removePyCli()
41+
result, err := c.RemovePyCli()
4242
checks = append(checks, platform.Check{"Removal of existing CLI", false, result, err, util.PyCliErr})
4343

4444
result, err = c.CheckExistingInstallation()
4545
checks = append(checks, platform.Check{"Existing Platform9 Packages Check", false, result, err, util.ExisitngInstallationErr})
4646

47-
result, err = c.checkOSPackages()
47+
result, err = c.CheckOSPackages()
4848
checks = append(checks, platform.Check{"Required OS Packages Check", true, result, err, fmt.Sprintf("%s. %s", util.OSPackagesErr, err)})
4949

50-
result, err = c.checkSudo()
50+
result, err = c.CheckSudo()
5151
checks = append(checks, platform.Check{"SudoCheck", true, result, err, util.SudoErr})
5252

53-
result, err = c.checkEnabledRepos()
53+
result, err = c.CheckEnabledRepos()
5454
checks = append(checks, platform.Check{"Required Enabled Repositories Check", true, result, err, fmt.Sprintf("%s", err)})
5555

56-
result, err = c.checkCPU()
56+
result, err = c.CheckCPU()
5757
checks = append(checks, platform.Check{"CPUCheck", false, result, err, fmt.Sprintf("%s %s", util.CPUErr, err)})
5858

59-
result, err = c.checkDisk()
59+
result, err = c.CheckDisk()
6060
checks = append(checks, platform.Check{"DiskCheck", false, result, err, fmt.Sprintf("%s %s", util.DiskErr, err)})
6161

62-
result, err = c.checkMem()
62+
result, err = c.CheckMem()
6363
checks = append(checks, platform.Check{"MemoryCheck", false, result, err, fmt.Sprintf("%s %s", util.MemErr, err)})
6464

65-
result, err = c.checkPort()
65+
result, err = c.CheckPort()
6666
checks = append(checks, platform.Check{"PortCheck", false, result, err, fmt.Sprintf("%s", err)})
6767

6868
result, err = c.CheckKubernetesCluster()
6969
checks = append(checks, platform.Check{"Existing Kubernetes Cluster Check", false, result, err, fmt.Sprintf("%s", err)})
7070

71-
result, err = c.checkPIDofSystemd()
71+
result, err = c.CheckPIDofSystemd()
7272
checks = append(checks, platform.Check{"Check if system is booted with systemd", true, result, err, fmt.Sprintf("%s", err)})
7373

74-
result, err = c.checkFirewalldIsRunning()
74+
result, err = c.CheckFirewalldIsRunning()
7575
checks = append(checks, platform.Check{"Check if firewalld service is not running", false, result, err, fmt.Sprintf("%s", err)})
7676

7777
if !util.SwapOffDisabled {
78-
result, err = c.disableSwap()
78+
result, err = c.DisableSwap()
7979
checks = append(checks, platform.Check{"Disabling swap and removing swap in fstab", true, result, err, fmt.Sprintf("%s", err)})
8080
}
8181

@@ -129,7 +129,7 @@ func (c *CentOS) CheckExistingInstallation() (bool, error) {
129129
return true, nil
130130
}
131131

132-
func (c *CentOS) checkOSPackages() (bool, error) {
132+
func (c *CentOS) CheckOSPackages() (bool, error) {
133133

134134
var rhel8, rocky9 bool
135135
errLines := []string{packageInstallError}
@@ -177,7 +177,7 @@ func (c *CentOS) checkOSPackages() (bool, error) {
177177
return true, nil
178178
}
179179

180-
func (c *CentOS) checkEnabledRepos() (bool, error) {
180+
func (c *CentOS) CheckEnabledRepos() (bool, error) {
181181

182182
var centos, rhel8 bool
183183
centos, _ = regexp.MatchString(`.*7\.[3-9]\.*`, string(version))
@@ -227,7 +227,7 @@ func (c *CentOS) checkEnabledRepos() (bool, error) {
227227
return true, nil
228228
}
229229

230-
func (c *CentOS) checkSudo() (bool, error) {
230+
func (c *CentOS) CheckSudo() (bool, error) {
231231
idS, err := c.exec.RunWithStdout("bash", "-c", "id -u | tr -d '\\n'")
232232
if err != nil {
233233
return false, err
@@ -241,7 +241,7 @@ func (c *CentOS) checkSudo() (bool, error) {
241241
return id == 0, nil
242242
}
243243

244-
func (c *CentOS) checkCPU() (bool, error) {
244+
func (c *CentOS) CheckCPU() (bool, error) {
245245
cpuS, err := c.exec.RunWithStdout("bash", "-c", "grep -c ^processor /proc/cpuinfo | tr -d '\\n'")
246246
if err != nil {
247247
return false, err
@@ -260,7 +260,7 @@ func (c *CentOS) checkCPU() (bool, error) {
260260
return false, fmt.Errorf("Number of CPUs found: %d", cpu)
261261
}
262262

263-
func (c *CentOS) checkMem() (bool, error) {
263+
func (c *CentOS) CheckMem() (bool, error) {
264264
memS, err := c.exec.RunWithStdout("bash", "-c", "echo $(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024))) | tr -d '\\n'")
265265
if err != nil {
266266
return false, err
@@ -279,7 +279,7 @@ func (c *CentOS) checkMem() (bool, error) {
279279
return false, fmt.Errorf("Total memory found: %.0f GB", math.Ceil(mem/1024))
280280
}
281281

282-
func (c *CentOS) checkDisk() (bool, error) {
282+
func (c *CentOS) CheckDisk() (bool, error) {
283283
diskS, err := c.exec.RunWithStdout("bash", "-c", "df -k / --output=size | sed 1d | xargs | tr -d '\\n'")
284284
if err != nil {
285285
return false, err
@@ -314,7 +314,7 @@ func (c *CentOS) checkDisk() (bool, error) {
314314
return false, fmt.Errorf("Available disk space: %.0f GB", math.Trunc(avail/util.GB))
315315
}
316316

317-
func (c *CentOS) checkPort() (bool, error) {
317+
func (c *CentOS) CheckPort() (bool, error) {
318318
var arg string
319319

320320
// For remote execution the command is wrapped under quotes ("") which creates
@@ -345,7 +345,7 @@ func (c *CentOS) checkPort() (bool, error) {
345345
return true, nil
346346
}
347347

348-
func (c *CentOS) removePyCli() (bool, error) {
348+
func (c *CentOS) RemovePyCli() (bool, error) {
349349

350350
if _, err := c.exec.RunWithStdout("rm", "-rf", util.PyCliPath); err != nil {
351351
return false, err
@@ -422,7 +422,7 @@ func (c *CentOS) installOSPackages(p string) error {
422422
return nil
423423
}
424424

425-
func (c *CentOS) disableSwap() (bool, error) {
425+
func (c *CentOS) DisableSwap() (bool, error) {
426426
err := swapoff.SetupNode(c.exec)
427427
if err != nil {
428428
return false, errors.New("error occurred while disabling swap")
@@ -431,7 +431,7 @@ func (c *CentOS) disableSwap() (bool, error) {
431431
}
432432
}
433433

434-
func (c *CentOS) checkPIDofSystemd() (bool, error) {
434+
func (c *CentOS) CheckPIDofSystemd() (bool, error) {
435435
_, err := c.exec.RunWithStdout("bash", "-c", "ps -p 1 -o comm= | grep systemd")
436436
if err != nil {
437437
return false, errors.New("System is not booted with systemd")
@@ -440,7 +440,7 @@ func (c *CentOS) checkPIDofSystemd() (bool, error) {
440440
}
441441
}
442442

443-
func (c *CentOS) checkFirewalldIsRunning() (bool, error) {
443+
func (c *CentOS) CheckFirewalldIsRunning() (bool, error) {
444444
_, err := c.exec.RunWithStdout("bash", "-c", "systemctl is-active firewalld")
445445
if err != nil {
446446
return true, nil

pkg/platform/centos/centos_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type args struct {
1717
exec cmdexec.Executor
1818
}
1919

20-
//CPU check test case
20+
// CPU check test case
2121
func TestCPU(t *testing.T) {
2222
type want struct {
2323
result bool
@@ -62,7 +62,7 @@ func TestCPU(t *testing.T) {
6262
for name, tc := range cases {
6363
t.Run(name, func(t *testing.T) {
6464
c := &CentOS{exec: tc.exec}
65-
o, err := c.checkCPU()
65+
o, err := c.CheckCPU()
6666

6767
if diff := cmp.Diff(tc.want.result, o); diff != "" {
6868
t.Errorf("r: -want, +got:\n%s", diff)
@@ -118,7 +118,7 @@ func TestRAM(t *testing.T) {
118118
for name, tc := range cases {
119119
t.Run(name, func(t *testing.T) {
120120
c := &CentOS{exec: tc.exec}
121-
o, err := c.checkMem()
121+
o, err := c.CheckMem()
122122

123123
if diff := cmp.Diff(tc.want.result, o); diff != "" {
124124
t.Errorf("r: -want, +got:\n%s", diff)
@@ -174,7 +174,7 @@ func TestDisk(t *testing.T) {
174174
for name, tc := range cases {
175175
t.Run(name, func(t *testing.T) {
176176
c := &CentOS{exec: tc.exec}
177-
o, err := c.checkDisk()
177+
o, err := c.CheckDisk()
178178

179179
if diff := cmp.Diff(tc.want.result, o); diff != "" {
180180
t.Errorf("r: -want, +got:\n%s", diff)
@@ -185,7 +185,7 @@ func TestDisk(t *testing.T) {
185185
}
186186
}
187187

188-
//Sudo check test case
188+
// Sudo check test case
189189
func TestSudo(t *testing.T) {
190190
type want struct {
191191
result bool
@@ -230,7 +230,7 @@ func TestSudo(t *testing.T) {
230230
for name, tc := range cases {
231231
t.Run(name, func(t *testing.T) {
232232
c := &CentOS{exec: tc.exec}
233-
o, err := c.checkSudo()
233+
o, err := c.CheckSudo()
234234

235235
if diff := cmp.Diff(tc.want.err, err); diff != "" {
236236
t.Errorf("r: -want, +got:\n%s", diff)
@@ -242,7 +242,7 @@ func TestSudo(t *testing.T) {
242242
}
243243
}
244244

245-
//Port check test case
245+
// Port check test case
246246
func TestPort(t *testing.T) {
247247
type want struct {
248248
result bool
@@ -285,7 +285,7 @@ func TestPort(t *testing.T) {
285285
for name, tc := range cases {
286286
t.Run(name, func(t *testing.T) {
287287
c := &CentOS{exec: tc.exec}
288-
o, _ := c.checkPort()
288+
o, _ := c.CheckPort()
289289

290290
if diff := cmp.Diff(tc.want.result, o); diff != "" {
291291
t.Errorf("r: -want, +got:\n%s", diff)
@@ -294,7 +294,7 @@ func TestPort(t *testing.T) {
294294
}
295295
}
296296

297-
//ExistingInstallation check test case
297+
// ExistingInstallation check test case
298298
func TestExistingInstallation(t *testing.T) {
299299
type want struct {
300300
result bool
@@ -395,7 +395,7 @@ func TestOSPackages(t *testing.T) {
395395
for name, tc := range cases {
396396
t.Run(name, func(t *testing.T) {
397397
c := &CentOS{exec: tc.exec}
398-
o, err := c.checkOSPackages()
398+
o, err := c.CheckOSPackages()
399399

400400
if diff := cmp.Diff(tc.want.result, o); diff != "" {
401401
t.Errorf("r: -want, +got:\n%s", diff)
@@ -406,7 +406,7 @@ func TestOSPackages(t *testing.T) {
406406
}
407407
}
408408

409-
//Test case for RemovePyCli check
409+
// Test case for RemovePyCli check
410410
func TestRemovePyCli(t *testing.T) {
411411
type want struct {
412412
result bool
@@ -451,7 +451,7 @@ func TestRemovePyCli(t *testing.T) {
451451
for name, tc := range cases {
452452
t.Run(name, func(t *testing.T) {
453453
c := &CentOS{exec: tc.exec}
454-
result, err := c.removePyCli()
454+
result, err := c.RemovePyCli()
455455

456456
assert.Equal(t, tc.want.err, err)
457457
assert.Equal(t, tc.want.result, result)
@@ -607,7 +607,7 @@ func TestDisableSwap(t *testing.T) {
607607
for name, tc := range cases {
608608
t.Run(name, func(t *testing.T) {
609609
c := &CentOS{exec: tc.exec}
610-
result, err := c.disableSwap()
610+
result, err := c.DisableSwap()
611611
assert.Equal(t, tc.result, result)
612612
assert.Equal(t, tc.err, err)
613613
})
@@ -657,7 +657,7 @@ func TestPIDofSystemdCheck(t *testing.T) {
657657
for name, tc := range cases {
658658
t.Run(name, func(t *testing.T) {
659659
c := &CentOS{exec: tc.exec}
660-
result, err := c.checkPIDofSystemd()
660+
result, err := c.CheckPIDofSystemd()
661661
assert.Equal(t, tc.result, result)
662662
assert.Equal(t, tc.err, err)
663663
})
@@ -707,7 +707,7 @@ func TestCheckFirewalldService(t *testing.T) {
707707
for name, tc := range cases {
708708
t.Run(name, func(t *testing.T) {
709709
c := &CentOS{exec: tc.exec}
710-
result, err := c.checkFirewalldIsRunning()
710+
result, err := c.CheckFirewalldIsRunning()
711711
assert.Equal(t, tc.result, result)
712712
assert.Equal(t, tc.err, err)
713713
})

pkg/util/constants.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ var (
130130
regexp.MustCompile(`.*/etc/pf9/certs/hostagent/key\.pem`),
131131
regexp.MustCompile(`.*/etc/pf9/certs/ca/cert\.pem`),
132132
regexp.MustCompile(`.*/etc/pf9/hostagent\.conf`),
133-
regexp.MustCompile(`.*pf9-hostagent-.*\.x86_64\.deb`),
134-
regexp.MustCompile(`.*pf9-comms-.*\.x86_64\.deb`),
133+
regexp.MustCompile(`.*pf9-hostagent-.*\.x86_64\.*`),
134+
regexp.MustCompile(`.*pf9-comms-.*\.x86_64\.*`),
135135
regexp.MustCompile(`.*download_nocert_routine executed successfully.*`),
136136
}
137137
HostAgentprogressPercentage = []int{5, 10, 15, 20, 25, 75, 100}

0 commit comments

Comments
 (0)