cluster.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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 nutanix
  15. type RackableUnits struct {
  16. Id int `json:"id"`
  17. RackableUnitUUID string `json:"rackable_unit_uuid"`
  18. Model string `json:"model"`
  19. ModelName string `json:"model_name"`
  20. //Location interface{} `json:"location"`
  21. Serial string `json:"serial"`
  22. Positions []string `json:"positions"`
  23. Nodes []int `json:"nodes"`
  24. NodeUuids []string `json:"node_uuids"`
  25. }
  26. type ClusterRedundancyState struct {
  27. CurrentRedundancyFactor int `json:"current_redundancy_factor"`
  28. DesiredRedundancyFactor int `json:"desired_redundancy_factor"`
  29. RedundancyStatus RedundancyStatus `json:"redundancy_status"`
  30. }
  31. type RedundancyStatus struct {
  32. KCassandraPrepareDone bool `json:"kCassandraPrepareDone"`
  33. KZookeeperPrepareDone bool `json:"kZookeeperPrepareDone"`
  34. }
  35. type SecurityComplianceConfig struct {
  36. Schedule string `json:"schedule"`
  37. EnableAide bool `json:"enable_aide"`
  38. EnableCore bool `json:"enable_core"`
  39. EnableHighStrengthPassword bool `json:"enable_high_strength_password"`
  40. EnableBanner bool `json:"enable_banner"`
  41. EnableSnmpv3Only bool `json:"enable_snmpv3_only"`
  42. }
  43. type HypervisorSecurityComplianceConfig struct {
  44. Schedule string `json:"schedule"`
  45. EnableAide bool `json:"enable_aide"`
  46. EnableCore bool `json:"enable_core"`
  47. EnableHighStrengthPassword bool `json:"enable_high_strength_password"`
  48. EnableBanner bool `json:"enable_banner"`
  49. }
  50. type HypervisorLldpConfig struct {
  51. EnableLldpTx bool `json:"enable_lldp_tx"`
  52. }
  53. type ClusterStats struct {
  54. HypervisorAvgIoLatencyUsecs string `json:"hypervisor_avg_io_latency_usecs"`
  55. NumReadIops string `json:"num_read_iops"`
  56. HypervisorWriteIoBandwidthKBps string `json:"hypervisor_write_io_bandwidth_kBps"`
  57. TimespanUsecs string `json:"timespan_usecs"`
  58. ControllerNumReadIops string `json:"controller_num_read_iops"`
  59. ReadIoPpm string `json:"read_io_ppm"`
  60. ControllerNumIops string `json:"controller_num_iops"`
  61. TotalReadIoTimeUsecs string `json:"total_read_io_time_usecs"`
  62. ControllerTotalReadIoTimeUsecs string `json:"controller_total_read_io_time_usecs"`
  63. ReplicationTransmittedBandwidthKBps string `json:"replication_transmitted_bandwidth_kBps"`
  64. HypervisorNumIo string `json:"hypervisor_num_io"`
  65. ControllerTotalTransformedUsageBytes string `json:"controller_total_transformed_usage_bytes"`
  66. HypervisorCPUUsagePpm string `json:"hypervisor_cpu_usage_ppm"`
  67. ControllerNumWriteIo string `json:"controller_num_write_io"`
  68. AvgReadIoLatencyUsecs string `json:"avg_read_io_latency_usecs"`
  69. ContentCacheLogicalSsdUsageBytes string `json:"content_cache_logical_ssd_usage_bytes"`
  70. ControllerTotalIoTimeUsecs string `json:"controller_total_io_time_usecs"`
  71. ControllerTotalReadIoSizeKbytes string `json:"controller_total_read_io_size_kbytes"`
  72. ControllerNumSeqIo string `json:"controller_num_seq_io"`
  73. ControllerReadIoPpm string `json:"controller_read_io_ppm"`
  74. ContentCacheNumLookups string `json:"content_cache_num_lookups"`
  75. ControllerTotalIoSizeKbytes string `json:"controller_total_io_size_kbytes"`
  76. ContentCacheHitPpm string `json:"content_cache_hit_ppm"`
  77. ControllerNumIo string `json:"controller_num_io"`
  78. HypervisorAvgReadIoLatencyUsecs string `json:"hypervisor_avg_read_io_latency_usecs"`
  79. ContentCacheNumDedupRefCountPph string `json:"content_cache_num_dedup_ref_count_pph"`
  80. NumWriteIops string `json:"num_write_iops"`
  81. ControllerNumRandomIo string `json:"controller_num_random_io"`
  82. NumIops string `json:"num_iops"`
  83. ReplicationReceivedBandwidthKBps string `json:"replication_received_bandwidth_kBps"`
  84. HypervisorNumReadIo string `json:"hypervisor_num_read_io"`
  85. HypervisorTotalReadIoTimeUsecs string `json:"hypervisor_total_read_io_time_usecs"`
  86. ControllerAvgIoLatencyUsecs string `json:"controller_avg_io_latency_usecs"`
  87. HypervisorHypervCPUUsagePpm string `json:"hypervisor_hyperv_cpu_usage_ppm"`
  88. NumIo string `json:"num_io"`
  89. ControllerNumReadIo string `json:"controller_num_read_io"`
  90. HypervisorNumWriteIo string `json:"hypervisor_num_write_io"`
  91. ControllerSeqIoPpm string `json:"controller_seq_io_ppm"`
  92. ControllerReadIoBandwidthKBps string `json:"controller_read_io_bandwidth_kBps"`
  93. ControllerIoBandwidthKBps string `json:"controller_io_bandwidth_kBps"`
  94. HypervisorHypervMemoryUsagePpm string `json:"hypervisor_hyperv_memory_usage_ppm"`
  95. HypervisorTimespanUsecs string `json:"hypervisor_timespan_usecs"`
  96. HypervisorNumWriteIops string `json:"hypervisor_num_write_iops"`
  97. ReplicationNumTransmittedBytes string `json:"replication_num_transmitted_bytes"`
  98. TotalReadIoSizeKbytes string `json:"total_read_io_size_kbytes"`
  99. HypervisorTotalIoSizeKbytes string `json:"hypervisor_total_io_size_kbytes"`
  100. AvgIoLatencyUsecs string `json:"avg_io_latency_usecs"`
  101. HypervisorNumReadIops string `json:"hypervisor_num_read_iops"`
  102. ContentCacheSavedSsdUsageBytes string `json:"content_cache_saved_ssd_usage_bytes"`
  103. ControllerWriteIoBandwidthKBps string `json:"controller_write_io_bandwidth_kBps"`
  104. ControllerWriteIoPpm string `json:"controller_write_io_ppm"`
  105. HypervisorAvgWriteIoLatencyUsecs string `json:"hypervisor_avg_write_io_latency_usecs"`
  106. HypervisorTotalReadIoSizeKbytes string `json:"hypervisor_total_read_io_size_kbytes"`
  107. ReadIoBandwidthKBps string `json:"read_io_bandwidth_kBps"`
  108. HypervisorEsxMemoryUsagePpm string `json:"hypervisor_esx_memory_usage_ppm"`
  109. HypervisorMemoryUsagePpm string `json:"hypervisor_memory_usage_ppm"`
  110. HypervisorNumIops string `json:"hypervisor_num_iops"`
  111. HypervisorIoBandwidthKBps string `json:"hypervisor_io_bandwidth_kBps"`
  112. ControllerNumWriteIops string `json:"controller_num_write_iops"`
  113. TotalIoTimeUsecs string `json:"total_io_time_usecs"`
  114. HypervisorKvmCPUUsagePpm string `json:"hypervisor_kvm_cpu_usage_ppm"`
  115. ContentCachePhysicalSsdUsageBytes string `json:"content_cache_physical_ssd_usage_bytes"`
  116. ControllerRandomIoPpm string `json:"controller_random_io_ppm"`
  117. ControllerAvgReadIoSizeKbytes string `json:"controller_avg_read_io_size_kbytes"`
  118. TotalTransformedUsageBytes string `json:"total_transformed_usage_bytes"`
  119. AvgWriteIoLatencyUsecs string `json:"avg_write_io_latency_usecs"`
  120. NumReadIo string `json:"num_read_io"`
  121. WriteIoBandwidthKBps string `json:"write_io_bandwidth_kBps"`
  122. HypervisorReadIoBandwidthKBps string `json:"hypervisor_read_io_bandwidth_kBps"`
  123. RandomIoPpm string `json:"random_io_ppm"`
  124. ContentCacheNumHits string `json:"content_cache_num_hits"`
  125. TotalUntransformedUsageBytes string `json:"total_untransformed_usage_bytes"`
  126. HypervisorTotalIoTimeUsecs string `json:"hypervisor_total_io_time_usecs"`
  127. NumRandomIo string `json:"num_random_io"`
  128. HypervisorKvmMemoryUsagePpm string `json:"hypervisor_kvm_memory_usage_ppm"`
  129. ControllerAvgWriteIoSizeKbytes string `json:"controller_avg_write_io_size_kbytes"`
  130. ControllerAvgReadIoLatencyUsecs string `json:"controller_avg_read_io_latency_usecs"`
  131. NumWriteIo string `json:"num_write_io"`
  132. HypervisorEsxCPUUsagePpm string `json:"hypervisor_esx_cpu_usage_ppm"`
  133. TotalIoSizeKbytes string `json:"total_io_size_kbytes"`
  134. IoBandwidthKBps string `json:"io_bandwidth_kBps"`
  135. ContentCachePhysicalMemoryUsageBytes string `json:"content_cache_physical_memory_usage_bytes"`
  136. ReplicationNumReceivedBytes string `json:"replication_num_received_bytes"`
  137. ControllerTimespanUsecs string `json:"controller_timespan_usecs"`
  138. NumSeqIo string `json:"num_seq_io"`
  139. ContentCacheSavedMemoryUsageBytes string `json:"content_cache_saved_memory_usage_bytes"`
  140. SeqIoPpm string `json:"seq_io_ppm"`
  141. WriteIoPpm string `json:"write_io_ppm"`
  142. ControllerAvgWriteIoLatencyUsecs string `json:"controller_avg_write_io_latency_usecs"`
  143. ContentCacheLogicalMemoryUsageBytes string `json:"content_cache_logical_memory_usage_bytes"`
  144. }
  145. type ClusterUsageStats struct {
  146. DataReductionOverallSavingRatioPpm string `json:"data_reduction.overall.saving_ratio_ppm"`
  147. StorageReservedFreeBytes string `json:"storage.reserved_free_bytes"`
  148. StorageTierDasSataUsageBytes string `json:"storage_tier.das-sata.usage_bytes"`
  149. DataReductionCompressionSavedBytes string `json:"data_reduction.compression.saved_bytes"`
  150. DataReductionSavingRatioPpm string `json:"data_reduction.saving_ratio_ppm"`
  151. DataReductionErasureCodingPostReductionBytes string `json:"data_reduction.erasure_coding.post_reduction_bytes"`
  152. StorageTierSsdPinnedUsageBytes string `json:"storage_tier.ssd.pinned_usage_bytes"`
  153. StorageReservedUsageBytes string `json:"storage.reserved_usage_bytes"`
  154. DataReductionErasureCodingSavingRatioPpm string `json:"data_reduction.erasure_coding.saving_ratio_ppm"`
  155. DataReductionThinProvisionSavedBytes string `json:"data_reduction.thin_provision.saved_bytes"`
  156. StorageTierDasSataCapacityBytes string `json:"storage_tier.das-sata.capacity_bytes"`
  157. StorageTierDasSataFreeBytes string `json:"storage_tier.das-sata.free_bytes"`
  158. StorageUsageBytes string `json:"storage.usage_bytes"`
  159. DataReductionErasureCodingSavedBytes string `json:"data_reduction.erasure_coding.saved_bytes"`
  160. DataReductionCompressionPreReductionBytes string `json:"data_reduction.compression.pre_reduction_bytes"`
  161. StorageRebuildCapacityBytes string `json:"storage.rebuild_capacity_bytes"`
  162. StorageTierDasSataPinnedUsageBytes string `json:"storage_tier.das-sata.pinned_usage_bytes"`
  163. DataReductionPreReductionBytes string `json:"data_reduction.pre_reduction_bytes"`
  164. StorageTierSsdCapacityBytes string `json:"storage_tier.ssd.capacity_bytes"`
  165. DataReductionCloneSavedBytes string `json:"data_reduction.clone.saved_bytes"`
  166. StorageTierSsdFreeBytes string `json:"storage_tier.ssd.free_bytes"`
  167. DataReductionDedupPreReductionBytes string `json:"data_reduction.dedup.pre_reduction_bytes"`
  168. DataReductionErasureCodingPreReductionBytes string `json:"data_reduction.erasure_coding.pre_reduction_bytes"`
  169. StorageCapacityBytes string `json:"storage.capacity_bytes"`
  170. DataReductionDedupPostReductionBytes string `json:"data_reduction.dedup.post_reduction_bytes"`
  171. DataReductionCloneSavingRatioPpm string `json:"data_reduction.clone.saving_ratio_ppm"`
  172. StorageLogicalUsageBytes string `json:"storage.logical_usage_bytes"`
  173. DataReductionSavedBytes string `json:"data_reduction.saved_bytes"`
  174. StorageFreeBytes string `json:"storage.free_bytes"`
  175. StorageTierSsdUsageBytes string `json:"storage_tier.ssd.usage_bytes"`
  176. DataReductionCompressionPostReductionBytes string `json:"data_reduction.compression.post_reduction_bytes"`
  177. DataReductionPostReductionBytes string `json:"data_reduction.post_reduction_bytes"`
  178. DataReductionDedupSavedBytes string `json:"data_reduction.dedup.saved_bytes"`
  179. DataReductionOverallSavedBytes string `json:"data_reduction.overall.saved_bytes"`
  180. DataReductionThinProvisionPostReductionBytes string `json:"data_reduction.thin_provision.post_reduction_bytes"`
  181. DataReductionThinProvisionSavingRatioPpm string `json:"data_reduction.thin_provision.saving_ratio_ppm"`
  182. DataReductionCompressionSavingRatioPpm string `json:"data_reduction.compression.saving_ratio_ppm"`
  183. DataReductionDedupSavingRatioPpm string `json:"data_reduction.dedup.saving_ratio_ppm"`
  184. StorageTierSsdPinnedBytes string `json:"storage_tier.ssd.pinned_bytes"`
  185. StorageReservedCapacityBytes string `json:"storage.reserved_capacity_bytes"`
  186. DataReductionThinProvisionPreReductionBytes string `json:"data_reduction.thin_provision.pre_reduction_bytes"`
  187. }
  188. type SCluster struct {
  189. Id string `json:"id"`
  190. UUID string `json:"uuid"`
  191. ClusterIncarnationId int64 `json:"cluster_incarnation_id"`
  192. ClusterUUID string `json:"cluster_uuid"`
  193. Name string `json:"name"`
  194. //ClusterExternalIpaddress interface{} `json:"cluster_external_ipaddress"`
  195. //ClusterFullyQualifiedDomainName interface{} `json:"cluster_fully_qualified_domain_name"`
  196. IsNsenabled bool `json:"is_nsenabled"`
  197. //ClusterExternalDataServicesIpaddress interface{} `json:"cluster_external_data_services_ipaddress"`
  198. //SegmentedIscsiDataServicesIpaddress interface{} `json:"segmented_iscsi_data_services_ipaddress"`
  199. //ClusterMasqueradingIpaddress interface{} `json:"cluster_masquerading_ipaddress"`
  200. //ClusterMasqueradingPort interface{} `json:"cluster_masquerading_port"`
  201. Timezone string `json:"timezone"`
  202. SupportVerbosityType string `json:"support_verbosity_type"`
  203. OperationMode string `json:"operation_mode"`
  204. Encrypted bool `json:"encrypted"`
  205. ClusterUsageWarningAlertThresholdPct int `json:"cluster_usage_warning_alert_threshold_pct"`
  206. ClusterUsageCriticalAlertThresholdPct int `json:"cluster_usage_critical_alert_threshold_pct"`
  207. StorageType string `json:"storage_type"`
  208. ClusterFunctions []string `json:"cluster_functions"`
  209. IsLts bool `json:"is_lts"`
  210. //IsRegisteredToPc interface{} `json:"is_registered_to_pc"`
  211. NumNodes int `json:"num_nodes"`
  212. BlockSerials []string `json:"block_serials"`
  213. Version string `json:"version"`
  214. FullVersion string `json:"full_version"`
  215. TargetVersion string `json:"target_version"`
  216. ExternalSubnet string `json:"external_subnet"`
  217. InternalSubnet string `json:"internal_subnet"`
  218. NccVersion string `json:"ncc_version"`
  219. EnableLockDown bool `json:"enable_lock_down"`
  220. EnablePasswordRemoteLoginToCluster bool `json:"enable_password_remote_login_to_cluster"`
  221. FingerprintContentCachePercentage int `json:"fingerprint_content_cache_percentage"`
  222. SsdPinningPercentageLimit int `json:"ssd_pinning_percentage_limit"`
  223. EnableShadowClones bool `json:"enable_shadow_clones"`
  224. //GlobalNfsWhiteList []interface{} `json:"global_nfs_white_list"`
  225. //NameServers []string `json:"name_servers"`
  226. //NtpServers []string `json:"ntp_servers"`
  227. //ServiceCenters []interface{} `json:"service_centers"`
  228. //HTTPProxies []interface{} `json:"http_proxies"`
  229. //RackableUnits []RackableUnits `json:"rackable_units"`
  230. //PublicKeys []interface{} `json:"public_keys"`
  231. //SMTPServer interface{} `json:"smtp_server"`
  232. HypervisorTypes []string `json:"hypervisor_types"`
  233. ClusterRedundancyState ClusterRedundancyState `json:"cluster_redundancy_state"`
  234. Multicluster bool `json:"multicluster"`
  235. Cloudcluster bool `json:"cloudcluster"`
  236. HasSelfEncryptingDrive bool `json:"has_self_encrypting_drive"`
  237. IsUpgradeInProgress bool `json:"is_upgrade_in_progress"`
  238. SecurityComplianceConfig SecurityComplianceConfig `json:"security_compliance_config"`
  239. HypervisorSecurityComplianceConfig HypervisorSecurityComplianceConfig `json:"hypervisor_security_compliance_config"`
  240. HypervisorLldpConfig HypervisorLldpConfig `json:"hypervisor_lldp_config"`
  241. ClusterArch string `json:"cluster_arch"`
  242. //IscsiConfig interface{} `json:"iscsi_config"`
  243. //Domain interface{} `json:"domain"`
  244. NosClusterAndHostsDomainJoined bool `json:"nos_cluster_and_hosts_domain_joined"`
  245. AllHypervNodesInFailoverCluster bool `json:"all_hyperv_nodes_in_failover_cluster"`
  246. //Credential interface{} `json:"credential"`
  247. Stats ClusterStats `json:"stats"`
  248. UsageStats ClusterUsageStats `json:"usage_stats"`
  249. EnforceRackableUnitAwarePlacement bool `json:"enforce_rackable_unit_aware_placement"`
  250. DisableDegradedNodeMonitoring bool `json:"disable_degraded_node_monitoring"`
  251. CommonCriteriaMode bool `json:"common_criteria_mode"`
  252. EnableOnDiskDedup bool `json:"enable_on_disk_dedup"`
  253. //ManagementServers interface{} `json:"management_servers"`
  254. FaultToleranceDomainType string `json:"fault_tolerance_domain_type"`
  255. //ThresholdForStorageThinProvision interface{} `json:"threshold_for_storage_thin_provision"`
  256. }
  257. func (self *SRegion) GetClusters() ([]SCluster, error) {
  258. clusters := []SCluster{}
  259. err := self.listAll("clusters", nil, &clusters)
  260. if err != nil {
  261. return nil, err
  262. }
  263. return clusters, nil
  264. }
  265. func (self *SRegion) GetCluster(id string) (*SCluster, error) {
  266. cluster := &SCluster{}
  267. return cluster, self.cli.get("clusters", id, nil, cluster)
  268. }