esxi.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. "yunion.io/x/pkg/utils"
  17. "yunion.io/x/onecloud/pkg/apis"
  18. "yunion.io/x/onecloud/pkg/cloudcommon/types"
  19. deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
  20. )
  21. type SEsxiRootFs struct {
  22. *sGuestRootFsDriver
  23. }
  24. func NewEsxiRootFs(part IDiskPartition) IRootFsDriver {
  25. return &SEsxiRootFs{sGuestRootFsDriver: newGuestRootFsDriver(part)}
  26. }
  27. func (m *SEsxiRootFs) IsFsCaseInsensitive() bool {
  28. return false
  29. }
  30. func (m *SEsxiRootFs) GetName() string {
  31. return "Esxi"
  32. }
  33. func (m *SEsxiRootFs) String() string {
  34. return "EsxiRootFs"
  35. }
  36. func (m *SEsxiRootFs) RootSignatures() []string {
  37. return []string{
  38. "/boot.cfg", "/imgdb.tgz",
  39. }
  40. }
  41. func (m *SEsxiRootFs) GetLoginAccount(rootFs IDiskPartition, user string, defaultRootUser bool, windowsDefaultAdminUser bool) (string, error) {
  42. return "root", nil
  43. }
  44. func (m *SEsxiRootFs) GetOs() string {
  45. return "VMWare"
  46. }
  47. func (m *SEsxiRootFs) ChangeUserPasswd(part IDiskPartition, account, gid, publicKey, password string, isRandomPassword bool) (string, error) {
  48. return utils.EncryptAESBase64(gid, "(blank)")
  49. }
  50. func (m *SEsxiRootFs) DeployHostname(part IDiskPartition, hostname, domain string) error {
  51. return nil
  52. }
  53. func (m *SEsxiRootFs) DeployHosts(part IDiskPartition, hn, domain string, ips []string) error {
  54. return nil
  55. }
  56. func (m *SEsxiRootFs) GetReleaseInfo(IDiskPartition) *deployapi.ReleaseInfo {
  57. spath := "/boot.cfg"
  58. lines, _ := m.rootFs.FileGetContents(spath, false)
  59. prop := ParsePropStr(string(lines))
  60. version, _ := prop["build"]
  61. return &deployapi.ReleaseInfo{
  62. Distro: "ESXi",
  63. Version: version,
  64. Arch: apis.OS_ARCH_X86_64,
  65. }
  66. }
  67. func (m *SEsxiRootFs) DeployPublicKey(rootfs IDiskPartition, uname string, pubkeys *deployapi.SSHKeys) error {
  68. return nil
  69. }
  70. func (m *SEsxiRootFs) PrepareFsForTemplate(IDiskPartition) error {
  71. return nil
  72. }
  73. func (m *SEsxiRootFs) DeployNetworkingScripts(rootfs IDiskPartition, nics []*types.SServerNic) error {
  74. return nil
  75. }
  76. func (d *SEsxiRootFs) ConfigSshd(loginAccount, loginPassword string, sshPort int) error {
  77. return nil
  78. }