tencentos.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 STencentOsRootFs struct {
  22. *SCentosRootFs
  23. }
  24. func NewTencentOsRootFs(part IDiskPartition) IRootFsDriver {
  25. return &STencentOsRootFs{
  26. SCentosRootFs: NewCentosRootFs(part).(*SCentosRootFs),
  27. }
  28. }
  29. func (d *STencentOsRootFs) GetName() string {
  30. return "TencentOS"
  31. }
  32. func (d *STencentOsRootFs) String() string {
  33. return "TencentOsRootFs"
  34. }
  35. func (d *STencentOsRootFs) RootSignatures() []string {
  36. sig := d.sLinuxRootFs.RootSignatures()
  37. return append([]string{"/etc/sysconfig/network", "/etc/tencentos-release"}, sig...)
  38. }
  39. func (d *STencentOsRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo {
  40. rel, _ := rootFs.FileGetContents("/etc/tencentos-release", false)
  41. var version string
  42. if len(rel) > 0 {
  43. dat := strings.Split(string(rel), " ")
  44. if len(dat) > 2 {
  45. version = strings.TrimSpace(dat[2])
  46. }
  47. }
  48. return deployapi.NewReleaseInfo(d.GetName(), version, d.GetArch(rootFs))
  49. }
  50. func (d *STencentOsRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*types.SServerNic) error {
  51. relInfo := d.GetReleaseInfo(rootFs)
  52. if err := d.sRedhatLikeRootFs.deployNetworkingScripts(rootFs, nics, relInfo); err != nil {
  53. return err
  54. }
  55. return nil
  56. }
  57. func (c *STencentOsRootFs) EnableSerialConsole(rootFs IDiskPartition, sysInfo *jsonutils.JSONDict) error {
  58. return c.enableSerialConsoleSystemd(rootFs)
  59. }
  60. func (c *STencentOsRootFs) DisableSerialConsole(rootFs IDiskPartition) error {
  61. c.disableSerialConsoleSystemd(rootFs)
  62. return nil
  63. }