kylin.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 SGalaxyKylinRootFs struct {
  22. *sRedhatLikeRootFs
  23. }
  24. func NewGalaxyKylinRootFs(part IDiskPartition) IRootFsDriver {
  25. return &SGalaxyKylinRootFs{sRedhatLikeRootFs: newRedhatLikeRootFs(part)}
  26. }
  27. func (d *SGalaxyKylinRootFs) GetName() string {
  28. return "Kylin"
  29. }
  30. func (d *SGalaxyKylinRootFs) String() string {
  31. return "KylinRootFs"
  32. }
  33. func (d *SGalaxyKylinRootFs) RootSignatures() []string {
  34. sigs := []string{"/etc/kylin-release", "/etc/.productinfo"}
  35. for _, sig := range d.sRedhatLikeRootFs.RootSignatures() {
  36. if sig != "/etc/redhat-release" {
  37. sigs = append(sigs, sig)
  38. }
  39. }
  40. return sigs
  41. }
  42. func (d *SGalaxyKylinRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo {
  43. rel, _ := rootFs.FileGetContents("/etc/kylin-release", false)
  44. var version string
  45. if len(rel) > 0 {
  46. relStr := string(rel)
  47. endPos := strings.IndexByte(relStr, '(')
  48. if endPos > 0 {
  49. relStr = strings.TrimSpace(relStr[:endPos])
  50. }
  51. dat := strings.Split(relStr, " ")
  52. version = dat[len(dat)-1]
  53. }
  54. return deployapi.NewReleaseInfo(d.GetName(), version, d.GetArch(rootFs))
  55. }
  56. func (d *SGalaxyKylinRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*types.SServerNic) error {
  57. relInfo := d.GetReleaseInfo(rootFs)
  58. if err := d.sRedhatLikeRootFs.deployNetworkingScripts(rootFs, nics, relInfo); err != nil {
  59. return err
  60. }
  61. return nil
  62. }
  63. func (c *SGalaxyKylinRootFs) EnableSerialConsole(rootFs IDiskPartition, sysInfo *jsonutils.JSONDict) error {
  64. return c.enableSerialConsoleSystemd(rootFs)
  65. }
  66. func (c *SGalaxyKylinRootFs) DisableSerialConsole(rootFs IDiskPartition) error {
  67. c.disableSerialConsoleSystemd(rootFs)
  68. return nil
  69. }