ctyunos.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/onecloud/pkg/cloudcommon/types"
  18. deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
  19. )
  20. type CTyunOSRootFs struct {
  21. *SOpenEulerRootFs
  22. }
  23. func NewCTyunOSRootFs(part IDiskPartition) IRootFsDriver {
  24. return &CTyunOSRootFs{
  25. SOpenEulerRootFs: NewOpenEulerRootFs(part).(*SOpenEulerRootFs),
  26. }
  27. }
  28. func (c *CTyunOSRootFs) String() string {
  29. return "CTyunOSRootFs"
  30. }
  31. func (c *CTyunOSRootFs) GetName() string {
  32. return "CTyunOS"
  33. }
  34. func (c *CTyunOSRootFs) RootSignatures() []string {
  35. sig := c.sLinuxRootFs.RootSignatures()
  36. return append([]string{"/etc/sysconfig/network", "/etc/ctyunos-release"}, sig...)
  37. }
  38. func (c *CTyunOSRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo {
  39. rel, _ := rootFs.FileGetContents("/etc/os-release", false)
  40. var version string
  41. if len(rel) > 0 {
  42. for _, line := range strings.Split(string(rel), "\n") {
  43. line = strings.TrimSpace(line)
  44. if strings.HasPrefix(line, "VERSION=") {
  45. version = strings.Trim(strings.TrimSpace(strings.TrimPrefix(line, "VERSION=")), `"`)
  46. break
  47. }
  48. }
  49. }
  50. version = strings.TrimSpace(version)
  51. return deployapi.NewReleaseInfo(c.GetName(), version, c.GetArch(rootFs))
  52. }
  53. func (c *CTyunOSRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*types.SServerNic) error {
  54. relInfo := c.GetReleaseInfo(rootFs)
  55. if err := c.sRedhatLikeRootFs.deployNetworkingScripts(rootFs, nics, relInfo); err != nil {
  56. return err
  57. }
  58. return nil
  59. }