yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/nutanix/cluster.go (about)

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