interface.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. "os"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/pkg/object"
  19. "yunion.io/x/onecloud/pkg/cloudcommon/types"
  20. deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
  21. )
  22. type IDiskPartition interface {
  23. // GetLocalPath join mountpoint as full path
  24. GetLocalPath(sPath string, caseInsensitive bool) string
  25. // FileGetContents will get file contents by join mountpoint as full path
  26. FileGetContents(sPath string, caseInsensitive bool) ([]byte, error)
  27. // FileGetContentsByPath get file contents directly
  28. FileGetContentsByPath(sPath string) ([]byte, error)
  29. FilePutContents(sPath, content string, modAppend, caseInsensitive bool) error
  30. Exists(sPath string, caseInsensitive bool) bool
  31. Chown(sPath string, uid, gid int, caseInsensitive bool) error
  32. Chmod(sPath string, mode uint32, caseInsensitive bool) error
  33. CheckOrAddUser(user, homeDir string, isSys bool) (realHomeDir string, err error)
  34. Stat(sPath string, caseInsensitive bool) os.FileInfo
  35. Symlink(src, dst string, caseInsensitive bool) error
  36. Passwd(account, password string, caseInsensitive bool) error
  37. Mkdir(sPath string, mode int, caseInsensitive bool) error
  38. ListDir(sPath string, caseInsensitive bool) []string
  39. Remove(path string, caseInsensitive bool)
  40. Cleandir(dir string, keepdir, caseInsensitive bool) error
  41. Zerofiles(dir string, caseInsensitive bool) error
  42. SupportSerialPorts() bool
  43. //Copy(src, dest string) error
  44. GetPartDev() string
  45. IsMounted() bool
  46. Mount() bool
  47. MountPartReadOnly() bool
  48. Umount() error
  49. GetMountPath() string
  50. IsReadonly() bool
  51. GetPhysicalPartitionType() string
  52. Zerofree()
  53. GenerateSshHostKeys() error
  54. }
  55. type IRootFsDriver interface {
  56. object.IObject
  57. GetPartition() IDiskPartition
  58. GetName() string
  59. String() string
  60. IsFsCaseInsensitive() bool
  61. RootSignatures() []string
  62. RootExcludeSignatures() []string
  63. GetReleaseInfo(IDiskPartition) *deployapi.ReleaseInfo
  64. GetOs() string
  65. DeployHostname(part IDiskPartition, hn, domain string) error
  66. DeployHosts(part IDiskPartition, hn, domain string, ips []string) error
  67. DeployQgaBlackList(part IDiskPartition) error
  68. DeployQgaService(part IDiskPartition) error
  69. DeployNetworkingScripts(IDiskPartition, []*types.SServerNic) error
  70. DeployStandbyNetworkingScripts(part IDiskPartition, nics, nicsStandby []*types.SServerNic) error
  71. DeployUdevSubsystemScripts(IDiskPartition) error
  72. DeployFstabScripts(IDiskPartition, []*deployapi.Disk) error
  73. GetLoginAccount(IDiskPartition, string, bool, bool) (string, error)
  74. DeployPublicKey(IDiskPartition, string, *deployapi.SSHKeys) error
  75. ChangeUserPasswd(part IDiskPartition, account, gid, publicKey, password string, isRandomPassword bool) (string, error)
  76. DeployYunionroot(rootFs IDiskPartition, pubkeys *deployapi.SSHKeys, isInit bool, enableCloudInit bool) error
  77. EnableSerialConsole(IDiskPartition, *jsonutils.JSONDict) error
  78. DisableSerialConsole(IDiskPartition) error
  79. CommitChanges(IDiskPartition) error
  80. DeployFiles(deploys []*deployapi.DeployContent) error
  81. DeployUserData(userData string) error
  82. DeployTelegraf(config string) (bool, error)
  83. DetectIsUEFISupport(IDiskPartition) bool
  84. IsCloudinitInstall() bool
  85. IsResizeFsPartitionSupport() bool
  86. PrepareFsForTemplate(IDiskPartition) error
  87. CleanNetworkScripts(rootFs IDiskPartition) error
  88. AllowAdminLogin() bool
  89. ConfigSshd(loginAccount, loginPassword string, sshPort int) error
  90. }
  91. type IDebianRootFsDriver interface {
  92. IRootFsDriver
  93. DistroName() string
  94. VersionFilePath() string
  95. }