alma.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package fsdriver
  15. import (
  16. "strings"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/onecloud/pkg/cloudcommon/types"
  19. deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
  20. )
  21. type SAlmaRootFs struct {
  22. *sRedhatLikeRootFs
  23. }
  24. func NewAlmaLinuxRootFs(part IDiskPartition) IRootFsDriver {
  25. return &SAlmaRootFs{sRedhatLikeRootFs: newRedhatLikeRootFs(part)}
  26. }
  27. func (d *SAlmaRootFs) GetName() string {
  28. return "AlmaLinux"
  29. }
  30. func (d *SAlmaRootFs) String() string {
  31. return "AlmaRootFs"
  32. }
  33. func (d *SAlmaRootFs) RootSignatures() []string {
  34. sig := d.sLinuxRootFs.RootSignatures()
  35. return append([]string{"/etc/sysconfig/network", "/etc/almalinux-release"}, sig...)
  36. }
  37. func (d *SAlmaRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo {
  38. rel, _ := rootFs.FileGetContents("/etc/almalinux-release", false)
  39. var version string
  40. if len(rel) > 0 {
  41. dat := strings.Split(string(rel), " ")
  42. if len(dat) > 2 {
  43. version = dat[2]
  44. }
  45. }
  46. return deployapi.NewReleaseInfo(d.GetName(), version, d.GetArch(rootFs))
  47. }
  48. func (d *SAlmaRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*types.SServerNic) error {
  49. relInfo := d.GetReleaseInfo(rootFs)
  50. if err := d.sRedhatLikeRootFs.deployNetworkingScripts(rootFs, nics, relInfo); err != nil {
  51. return err
  52. }
  53. return nil
  54. }
  55. func (c *SAlmaRootFs) EnableSerialConsole(rootFs IDiskPartition, sysInfo *jsonutils.JSONDict) error {
  56. return c.enableSerialConsoleSystemd(rootFs)
  57. }
  58. func (c *SAlmaRootFs) DisableSerialConsole(rootFs IDiskPartition) error {
  59. c.disableSerialConsoleSystemd(rootFs)
  60. return nil
  61. }