host.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 bingocloud
  15. import (
  16. "time"
  17. )
  18. type SHost struct {
  19. CPUHz string `json:"CpuHz"`
  20. ModelId string `json:"ModelId"`
  21. MonitorType string `json:"MonitorType"`
  22. IpmiMgrEnabled string `json:"IpmiMgrEnabled"`
  23. JoinTime time.Time `json:"JoinTime"`
  24. IsBareMetal string `json:"isBareMetal"`
  25. BmcPwd string `json:"BmcPwd"`
  26. Extra string `json:"Extra"`
  27. InstanceId string `json:"instanceId"`
  28. Manufacturer string `json:"Manufacturer"`
  29. BaseBoardSerial string `json:"BaseBoardSerial"`
  30. BareMetalHWInfo string `json:"BareMetalHWInfo"`
  31. BmcPort string `json:"BmcPort"`
  32. CPUCores int `json:"CpuCores"`
  33. BmcIP string `json:"BmcIp"`
  34. Cabinet string `json:"Cabinet"`
  35. Memo string `json:"Memo"`
  36. HostIP string `json:"HostIp"`
  37. Memory int `json:"Memory"`
  38. HostId string `json:"HostId"`
  39. CPUKind string `json:"CpuKind"`
  40. SystemSerial string `json:"SystemSerial"`
  41. InCloud string `json:"InCloud"`
  42. Location string `json:"Location"`
  43. BmcUser string `json:"BmcUser"`
  44. PublicIP string `json:"PublicIp"`
  45. Status string `json:"Status"`
  46. Room string `json:"Room"`
  47. SSHMgrEnabled string `json:"SshMgrEnabled"`
  48. BmState string `json:"bmState"`
  49. HostName string `json:"HostName"`
  50. }
  51. func (self *SRegion) GetHosts(nextToken string) ([]SHost, string, error) {
  52. params := map[string]string{}
  53. if len(nextToken) > 0 {
  54. params["NextToken"] = nextToken
  55. }
  56. resp, err := self.invoke("DescribePhysicalHosts", params)
  57. if err != nil {
  58. return nil, "", err
  59. }
  60. ret := struct {
  61. DescribePhysicalHostsResult struct {
  62. PhysicalHostSet []SHost
  63. }
  64. NextToken string
  65. }{}
  66. _ = resp.Unmarshal(&ret)
  67. return ret.DescribePhysicalHostsResult.PhysicalHostSet, ret.NextToken, nil
  68. }