yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/nutanix/host.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  import (
    18  	"strconv"
    19  
    20  	"yunion.io/x/jsonutils"
    21  	"yunion.io/x/pkg/errors"
    22  
    23  	api "yunion.io/x/cloudmux/pkg/apis/compute"
    24  	"yunion.io/x/cloudmux/pkg/cloudprovider"
    25  	"yunion.io/x/cloudmux/pkg/multicloud"
    26  )
    27  
    28  type SHost struct {
    29  	multicloud.STagBase
    30  	multicloud.SHostBase
    31  	firstHost bool
    32  
    33  	zone *SZone
    34  
    35  	ServiceVmid                            string                                 `json:"service_vmid"`
    36  	UUID                                   string                                 `json:"uuid"`
    37  	DiskHardwareConfigs                    DiskHardwareConfigs                    `json:"disk_hardware_configs"`
    38  	Name                                   string                                 `json:"name"`
    39  	ServiceVmexternalIP                    string                                 `json:"service_vmexternal_ip"`
    40  	ServiceVmnatIP                         string                                 `json:"service_vmnat_ip"`
    41  	ServiceVmnatPort                       string                                 `json:"service_vmnat_port"`
    42  	OplogDiskPct                           float64                                `json:"oplog_disk_pct"`
    43  	OplogDiskSize                          int64                                  `json:"oplog_disk_size"`
    44  	HypervisorKey                          string                                 `json:"hypervisor_key"`
    45  	HypervisorAddress                      string                                 `json:"hypervisor_address"`
    46  	HypervisorUsername                     string                                 `json:"hypervisor_username"`
    47  	HypervisorPassword                     string                                 `json:"hypervisor_password"`
    48  	BackplaneIP                            string                                 `json:"backplane_ip"`
    49  	ControllerVMBackplaneIP                string                                 `json:"controller_vm_backplane_ip"`
    50  	RdmaBackplaneIps                       string                                 `json:"rdma_backplane_ips"`
    51  	ManagementServerName                   string                                 `json:"management_server_name"`
    52  	IpmiAddress                            string                                 `json:"ipmi_address"`
    53  	IpmiUsername                           string                                 `json:"ipmi_username"`
    54  	IpmiPassword                           string                                 `json:"ipmi_password"`
    55  	Monitored                              bool                                   `json:"monitored"`
    56  	Position                               Position                               `json:"position"`
    57  	Serial                                 string                                 `json:"serial"`
    58  	BlockSerial                            string                                 `json:"block_serial"`
    59  	BlockModel                             string                                 `json:"block_model"`
    60  	BlockModelName                         string                                 `json:"block_model_name"`
    61  	BlockLocation                          string                                 `json:"block_location"`
    62  	HostMaintenanceModeReason              string                                 `json:"host_maintenance_mode_reason"`
    63  	HypervisorState                        string                                 `json:"hypervisor_state"`
    64  	AcropolisConnectionState               string                                 `json:"acropolis_connection_state"`
    65  	MetadataStoreStatus                    string                                 `json:"metadata_store_status"`
    66  	MetadataStoreStatusMessage             string                                 `json:"metadata_store_status_message"`
    67  	State                                  string                                 `json:"state"`
    68  	DynamicRingChangingNode                string                                 `json:"dynamic_ring_changing_node"`
    69  	RemovalStatus                          []string                               `json:"removal_status"`
    70  	VzoneName                              string                                 `json:"vzone_name"`
    71  	CPUModel                               string                                 `json:"cpu_model"`
    72  	NumCPUCores                            int                                    `json:"num_cpu_cores"`
    73  	NumCPUThreads                          int                                    `json:"num_cpu_threads"`
    74  	NumCPUSockets                          int                                    `json:"num_cpu_sockets"`
    75  	CPUFrequencyInHz                       int64                                  `json:"cpu_frequency_in_hz"`
    76  	CPUCapacityInHz                        int64                                  `json:"cpu_capacity_in_hz"`
    77  	MemoryCapacityInBytes                  int64                                  `json:"memory_capacity_in_bytes"`
    78  	HypervisorFullName                     string                                 `json:"hypervisor_full_name"`
    79  	HypervisorType                         string                                 `json:"hypervisor_type"`
    80  	NumVms                                 int                                    `json:"num_vms"`
    81  	BootTimeInUsecs                        int64                                  `json:"boot_time_in_usecs"`
    82  	IsDegraded                             bool                                   `json:"is_degraded"`
    83  	IsSecureBooted                         bool                                   `json:"is_secure_booted"`
    84  	IsHardwareVirtualized                  bool                                   `json:"is_hardware_virtualized"`
    85  	FailoverClusterFqdn                    string                                 `json:"failover_cluster_fqdn"`
    86  	FailoverClusterNodeState               string                                 `json:"failover_cluster_node_state"`
    87  	RebootPending                          bool                                   `json:"reboot_pending"`
    88  	DefaultVMLocation                      string                                 `json:"default_vm_location"`
    89  	DefaultVMStorageContainerID            string                                 `json:"default_vm_storage_container_id"`
    90  	DefaultVMStorageContainerUUID          string                                 `json:"default_vm_storage_container_uuid"`
    91  	DefaultVhdLocation                     string                                 `json:"default_vhd_location"`
    92  	DefaultVhdStorageContainerID           string                                 `json:"default_vhd_storage_container_id"`
    93  	DefaultVhdStorageContainerUUID         string                                 `json:"default_vhd_storage_container_uuid"`
    94  	BiosVersion                            string                                 `json:"bios_version"`
    95  	BiosModel                              string                                 `json:"bios_model"`
    96  	BmcVersion                             string                                 `json:"bmc_version"`
    97  	BmcModel                               string                                 `json:"bmc_model"`
    98  	HbaFirmwaresList                       string                                 `json:"hba_firmwares_list"`
    99  	ClusterUUID                            string                                 `json:"cluster_uuid"`
   100  	Stats                                  Stats                                  `json:"stats"`
   101  	UsageStats                             UsageStats                             `json:"usage_stats"`
   102  	HasCsr                                 bool                                   `json:"has_csr"`
   103  	HostNicIds                             []string                               `json:"host_nic_ids"`
   104  	HostGpus                               string                                 `json:"host_gpus"`
   105  	GpuDriverVersion                       string                                 `json:"gpu_driver_version"`
   106  	HostType                               string                                 `json:"host_type"`
   107  	KeyManagementDeviceToCertificateStatus KeyManagementDeviceToCertificateStatus `json:"key_management_device_to_certificate_status"`
   108  	HostInMaintenanceMode                  string                                 `json:"host_in_maintenance_mode"`
   109  }
   110  
   111  type Num1 struct {
   112  	SerialNumber           string `json:"serial_number"`
   113  	DiskID                 string `json:"disk_id"`
   114  	DiskUUID               string `json:"disk_uuid"`
   115  	Location               int    `json:"location"`
   116  	Bad                    bool   `json:"bad"`
   117  	Mounted                bool   `json:"mounted"`
   118  	MountPath              string `json:"mount_path"`
   119  	Model                  string `json:"model"`
   120  	Vendor                 string `json:"vendor"`
   121  	BootDisk               bool   `json:"boot_disk"`
   122  	OnlyBootDisk           bool   `json:"only_boot_disk"`
   123  	UnderDiagnosis         bool   `json:"under_diagnosis"`
   124  	BackgroundOperation    string `json:"background_operation"`
   125  	CurrentFirmwareVersion string `json:"current_firmware_version"`
   126  	TargetFirmwareVersion  string `json:"target_firmware_version"`
   127  	CanAddAsNewDisk        bool   `json:"can_add_as_new_disk"`
   128  	CanAddAsOldDisk        bool   `json:"can_add_as_old_disk"`
   129  }
   130  type Num2 struct {
   131  	SerialNumber           string `json:"serial_number"`
   132  	DiskID                 string `json:"disk_id"`
   133  	DiskUUID               string `json:"disk_uuid"`
   134  	Location               int    `json:"location"`
   135  	Bad                    bool   `json:"bad"`
   136  	Mounted                bool   `json:"mounted"`
   137  	MountPath              string `json:"mount_path"`
   138  	Model                  string `json:"model"`
   139  	Vendor                 string `json:"vendor"`
   140  	BootDisk               bool   `json:"boot_disk"`
   141  	OnlyBootDisk           bool   `json:"only_boot_disk"`
   142  	UnderDiagnosis         bool   `json:"under_diagnosis"`
   143  	BackgroundOperation    string `json:"background_operation"`
   144  	CurrentFirmwareVersion string `json:"current_firmware_version"`
   145  	TargetFirmwareVersion  string `json:"target_firmware_version"`
   146  	CanAddAsNewDisk        bool   `json:"can_add_as_new_disk"`
   147  	CanAddAsOldDisk        bool   `json:"can_add_as_old_disk"`
   148  }
   149  type DiskHardwareConfigs struct {
   150  	Num1 Num1 `json:"1"`
   151  	Num2 Num2 `json:"2"`
   152  }
   153  type Position struct {
   154  	Ordinal          int    `json:"ordinal"`
   155  	Name             string `json:"name"`
   156  	PhysicalPosition string `json:"physical_position"`
   157  }
   158  type Stats struct {
   159  	HypervisorAvgIoLatencyUsecs          string `json:"hypervisor_avg_io_latency_usecs"`
   160  	NumReadIops                          string `json:"num_read_iops"`
   161  	HypervisorWriteIoBandwidthKBps       string `json:"hypervisor_write_io_bandwidth_kBps"`
   162  	TimespanUsecs                        string `json:"timespan_usecs"`
   163  	ControllerNumReadIops                string `json:"controller_num_read_iops"`
   164  	ReadIoPpm                            string `json:"read_io_ppm"`
   165  	ControllerNumIops                    string `json:"controller_num_iops"`
   166  	TotalReadIoTimeUsecs                 string `json:"total_read_io_time_usecs"`
   167  	ControllerTotalReadIoTimeUsecs       string `json:"controller_total_read_io_time_usecs"`
   168  	HypervisorNumIo                      string `json:"hypervisor_num_io"`
   169  	ControllerTotalTransformedUsageBytes string `json:"controller_total_transformed_usage_bytes"`
   170  	HypervisorCPUUsagePpm                string `json:"hypervisor_cpu_usage_ppm"`
   171  	ControllerNumWriteIo                 string `json:"controller_num_write_io"`
   172  	AvgReadIoLatencyUsecs                string `json:"avg_read_io_latency_usecs"`
   173  	ContentCacheLogicalSsdUsageBytes     string `json:"content_cache_logical_ssd_usage_bytes"`
   174  	ControllerTotalIoTimeUsecs           string `json:"controller_total_io_time_usecs"`
   175  	ControllerTotalReadIoSizeKbytes      string `json:"controller_total_read_io_size_kbytes"`
   176  	ControllerNumSeqIo                   string `json:"controller_num_seq_io"`
   177  	ControllerReadIoPpm                  string `json:"controller_read_io_ppm"`
   178  	ContentCacheNumLookups               string `json:"content_cache_num_lookups"`
   179  	ControllerTotalIoSizeKbytes          string `json:"controller_total_io_size_kbytes"`
   180  	ContentCacheHitPpm                   string `json:"content_cache_hit_ppm"`
   181  	ControllerNumIo                      string `json:"controller_num_io"`
   182  	HypervisorAvgReadIoLatencyUsecs      string `json:"hypervisor_avg_read_io_latency_usecs"`
   183  	ContentCacheNumDedupRefCountPph      string `json:"content_cache_num_dedup_ref_count_pph"`
   184  	NumWriteIops                         string `json:"num_write_iops"`
   185  	ControllerNumRandomIo                string `json:"controller_num_random_io"`
   186  	NumIops                              string `json:"num_iops"`
   187  	HypervisorNumReadIo                  string `json:"hypervisor_num_read_io"`
   188  	HypervisorTotalReadIoTimeUsecs       string `json:"hypervisor_total_read_io_time_usecs"`
   189  	ControllerAvgIoLatencyUsecs          string `json:"controller_avg_io_latency_usecs"`
   190  	NumIo                                string `json:"num_io"`
   191  	ControllerNumReadIo                  string `json:"controller_num_read_io"`
   192  	HypervisorNumWriteIo                 string `json:"hypervisor_num_write_io"`
   193  	ControllerSeqIoPpm                   string `json:"controller_seq_io_ppm"`
   194  	ControllerReadIoBandwidthKBps        string `json:"controller_read_io_bandwidth_kBps"`
   195  	ControllerIoBandwidthKBps            string `json:"controller_io_bandwidth_kBps"`
   196  	HypervisorNumReceivedBytes           string `json:"hypervisor_num_received_bytes"`
   197  	HypervisorTimespanUsecs              string `json:"hypervisor_timespan_usecs"`
   198  	HypervisorNumWriteIops               string `json:"hypervisor_num_write_iops"`
   199  	TotalReadIoSizeKbytes                string `json:"total_read_io_size_kbytes"`
   200  	HypervisorTotalIoSizeKbytes          string `json:"hypervisor_total_io_size_kbytes"`
   201  	AvgIoLatencyUsecs                    string `json:"avg_io_latency_usecs"`
   202  	HypervisorNumReadIops                string `json:"hypervisor_num_read_iops"`
   203  	ContentCacheSavedSsdUsageBytes       string `json:"content_cache_saved_ssd_usage_bytes"`
   204  	ControllerWriteIoBandwidthKBps       string `json:"controller_write_io_bandwidth_kBps"`
   205  	ControllerWriteIoPpm                 string `json:"controller_write_io_ppm"`
   206  	HypervisorAvgWriteIoLatencyUsecs     string `json:"hypervisor_avg_write_io_latency_usecs"`
   207  	HypervisorNumTransmittedBytes        string `json:"hypervisor_num_transmitted_bytes"`
   208  	HypervisorTotalReadIoSizeKbytes      string `json:"hypervisor_total_read_io_size_kbytes"`
   209  	ReadIoBandwidthKBps                  string `json:"read_io_bandwidth_kBps"`
   210  	HypervisorMemoryUsagePpm             string `json:"hypervisor_memory_usage_ppm"`
   211  	HypervisorNumIops                    string `json:"hypervisor_num_iops"`
   212  	HypervisorIoBandwidthKBps            string `json:"hypervisor_io_bandwidth_kBps"`
   213  	ControllerNumWriteIops               string `json:"controller_num_write_iops"`
   214  	TotalIoTimeUsecs                     string `json:"total_io_time_usecs"`
   215  	ContentCachePhysicalSsdUsageBytes    string `json:"content_cache_physical_ssd_usage_bytes"`
   216  	ControllerRandomIoPpm                string `json:"controller_random_io_ppm"`
   217  	ControllerAvgReadIoSizeKbytes        string `json:"controller_avg_read_io_size_kbytes"`
   218  	TotalTransformedUsageBytes           string `json:"total_transformed_usage_bytes"`
   219  	AvgWriteIoLatencyUsecs               string `json:"avg_write_io_latency_usecs"`
   220  	NumReadIo                            string `json:"num_read_io"`
   221  	WriteIoBandwidthKBps                 string `json:"write_io_bandwidth_kBps"`
   222  	HypervisorReadIoBandwidthKBps        string `json:"hypervisor_read_io_bandwidth_kBps"`
   223  	RandomIoPpm                          string `json:"random_io_ppm"`
   224  	TotalUntransformedUsageBytes         string `json:"total_untransformed_usage_bytes"`
   225  	HypervisorTotalIoTimeUsecs           string `json:"hypervisor_total_io_time_usecs"`
   226  	NumRandomIo                          string `json:"num_random_io"`
   227  	ControllerAvgWriteIoSizeKbytes       string `json:"controller_avg_write_io_size_kbytes"`
   228  	ControllerAvgReadIoLatencyUsecs      string `json:"controller_avg_read_io_latency_usecs"`
   229  	NumWriteIo                           string `json:"num_write_io"`
   230  	TotalIoSizeKbytes                    string `json:"total_io_size_kbytes"`
   231  	IoBandwidthKBps                      string `json:"io_bandwidth_kBps"`
   232  	ContentCachePhysicalMemoryUsageBytes string `json:"content_cache_physical_memory_usage_bytes"`
   233  	ControllerTimespanUsecs              string `json:"controller_timespan_usecs"`
   234  	NumSeqIo                             string `json:"num_seq_io"`
   235  	ContentCacheSavedMemoryUsageBytes    string `json:"content_cache_saved_memory_usage_bytes"`
   236  	SeqIoPpm                             string `json:"seq_io_ppm"`
   237  	WriteIoPpm                           string `json:"write_io_ppm"`
   238  	ControllerAvgWriteIoLatencyUsecs     string `json:"controller_avg_write_io_latency_usecs"`
   239  	ContentCacheLogicalMemoryUsageBytes  string `json:"content_cache_logical_memory_usage_bytes"`
   240  }
   241  type UsageStats struct {
   242  	StorageTierDasSataUsageBytes    string `json:"storage_tier.das-sata.usage_bytes"`
   243  	StorageCapacityBytes            string `json:"storage.capacity_bytes"`
   244  	StorageLogicalUsageBytes        string `json:"storage.logical_usage_bytes"`
   245  	StorageTierDasSataCapacityBytes string `json:"storage_tier.das-sata.capacity_bytes"`
   246  	StorageFreeBytes                string `json:"storage.free_bytes"`
   247  	StorageTierSsdUsageBytes        string `json:"storage_tier.ssd.usage_bytes"`
   248  	StorageTierSsdCapacityBytes     string `json:"storage_tier.ssd.capacity_bytes"`
   249  	StorageTierDasSataFreeBytes     string `json:"storage_tier.das-sata.free_bytes"`
   250  	StorageUsageBytes               string `json:"storage.usage_bytes"`
   251  	StorageTierSsdFreeBytes         string `json:"storage_tier.ssd.free_bytes"`
   252  }
   253  type KeyManagementDeviceToCertificateStatus struct {
   254  }
   255  
   256  func (self *SRegion) GetHosts() ([]SHost, error) {
   257  	hosts := []SHost{}
   258  	return hosts, self.listAll("hosts", nil, &hosts)
   259  }
   260  
   261  func (self *SRegion) GetHost(id string) (*SHost, error) {
   262  	host := &SHost{}
   263  	return host, self.cli.get("hosts", id, nil, host)
   264  }
   265  
   266  func (self *SHost) GetName() string {
   267  	return self.Name
   268  }
   269  
   270  func (self *SHost) GetId() string {
   271  	return self.UUID
   272  }
   273  
   274  func (self *SHost) GetGlobalId() string {
   275  	return self.UUID
   276  }
   277  
   278  func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudprovider.ICloudVM, error) {
   279  	image, err := self.zone.region.GetImage(opts.ExternalImageId)
   280  	if err != nil {
   281  		return nil, errors.Wrapf(err, "GetImage")
   282  	}
   283  	disks := []map[string]interface{}{
   284  		{
   285  			"disk_address": map[string]interface{}{
   286  				"device_bus":   "ide",
   287  				"device_index": 0,
   288  			},
   289  			"is_cdrom": true,
   290  			"is_empty": true,
   291  		},
   292  		{
   293  			"disk_address": map[string]interface{}{
   294  				"device_bus":   "scsi",
   295  				"device_index": 0,
   296  			},
   297  			"is_cdrom": false,
   298  			"vm_disk_clone": map[string]interface{}{
   299  				"disk_address": map[string]string{
   300  					"vmdisk_uuid": image.VMDiskID,
   301  				},
   302  				"minimum_size": opts.SysDisk.SizeGB * 1024 * 1024 * 1024,
   303  			},
   304  		},
   305  	}
   306  	for i, disk := range opts.DataDisks {
   307  		disks = append(disks, map[string]interface{}{
   308  			"disk_address": map[string]interface{}{
   309  				"device_bus":   "scsi",
   310  				"device_index": i + 1,
   311  			},
   312  			"is_cdrom": false,
   313  			"vm_disk_create": map[string]interface{}{
   314  				"size":                   disk.SizeGB * 1024 * 1024 * 1024,
   315  				"storage_container_uuid": disk.StorageExternalId,
   316  			},
   317  		})
   318  	}
   319  	nic := map[string]interface{}{
   320  		"network_uuid": opts.ExternalVpcId,
   321  	}
   322  	if len(opts.IpAddr) > 0 {
   323  		nic["requested_ip_address"] = opts.IpAddr
   324  	}
   325  	params := map[string]interface{}{
   326  		"boot": map[string]interface{}{
   327  			"boot_device_order": []string{"CDROM", "DISK", "NIC"},
   328  			"uefi_boot":         false,
   329  		},
   330  		"description":        opts.Description,
   331  		"hypervisor_type":    "ACROPOLIS",
   332  		"memory_mb":          opts.MemoryMB,
   333  		"name":               opts.Name,
   334  		"num_cores_per_vcpu": 1,
   335  		"num_vcpus":          opts.Cpu,
   336  		"timezone":           "UTC",
   337  		"vm_customization_config": map[string]interface{}{
   338  			"files_to_inject_list": []string{},
   339  			"userdata":             opts.UserData,
   340  		},
   341  		"vm_disks": disks,
   342  		"vm_features": map[string]interface{}{
   343  			"AGENT_VM": false,
   344  		},
   345  		"vm_nics": []map[string]interface{}{
   346  			nic,
   347  		},
   348  	}
   349  	ret := struct {
   350  		TaskUUID string
   351  	}{}
   352  	err = self.zone.region.post("vms", jsonutils.Marshal(params), &ret)
   353  	if err != nil {
   354  		return nil, err
   355  	}
   356  	resId, err := self.zone.region.cli.wait(ret.TaskUUID)
   357  	if err != nil {
   358  		return nil, err
   359  	}
   360  	vm, err := self.zone.region.GetInstance(resId)
   361  	if err != nil {
   362  		return nil, err
   363  	}
   364  	vm.host = self
   365  	return vm, nil
   366  }
   367  
   368  func (self *SHost) GetAccessIp() string {
   369  	return self.HypervisorAddress
   370  }
   371  
   372  func (self *SHost) GetAccessMac() string {
   373  	return ""
   374  }
   375  
   376  func (self *SHost) GetCpuCmtbound() float32 {
   377  	return 16.0
   378  }
   379  
   380  func (self *SHost) GetMemCmtbound() float32 {
   381  	return 1.5
   382  }
   383  
   384  func (self *SHost) GetCpuCount() int {
   385  	return self.NumCPUCores * self.NumCPUSockets
   386  }
   387  
   388  func (self *SHost) GetNodeCount() int8 {
   389  	return int8(self.NumCPUSockets)
   390  }
   391  
   392  func (self *SHost) GetEnabled() bool {
   393  	return true
   394  }
   395  
   396  func (self *SHost) GetCpuDesc() string {
   397  	return self.CPUModel
   398  }
   399  
   400  func (self *SHost) GetCpuMhz() int {
   401  	return int(self.CPUCapacityInHz / 1000 / 1000)
   402  }
   403  
   404  func (self *SHost) GetMemSizeMB() int {
   405  	return int(self.MemoryCapacityInBytes / 1024 / 1024)
   406  }
   407  
   408  func (self *SHost) GetStorageSizeMB() int {
   409  	sizeBytes, _ := strconv.Atoi(self.UsageStats.StorageCapacityBytes)
   410  	return sizeBytes / 1024 / 1024
   411  }
   412  
   413  func (self *SHost) GetStorageType() string {
   414  	return api.DISK_TYPE_HYBRID
   415  }
   416  
   417  func (self *SHost) GetHostType() string {
   418  	return api.HOST_TYPE_NUTANIX
   419  }
   420  
   421  func (self *SHost) GetHostStatus() string {
   422  	return api.HOST_ONLINE
   423  }
   424  
   425  func (self *SHost) GetIHostNics() ([]cloudprovider.ICloudHostNetInterface, error) {
   426  	return []cloudprovider.ICloudHostNetInterface{}, nil
   427  }
   428  
   429  func (self *SHost) GetIsMaintenance() bool {
   430  	return false
   431  }
   432  
   433  func (self *SHost) GetVersion() string {
   434  	return ""
   435  }
   436  
   437  func (self *SHost) GetStatus() string {
   438  	return api.HOST_STATUS_RUNNING
   439  }
   440  
   441  func (self *SHost) GetSN() string {
   442  	return ""
   443  }
   444  
   445  func (self *SHost) GetSysInfo() jsonutils.JSONObject {
   446  	info := jsonutils.NewDict()
   447  	info.Add(jsonutils.NewString(CLOUD_PROVIDER_NUTANIX), "manufacture")
   448  	return info
   449  }
   450  
   451  func (self *SHost) IsEmulated() bool {
   452  	return false
   453  }
   454  
   455  func (self *SHost) Refresh() error {
   456  	host, err := self.zone.region.GetHost(self.UUID)
   457  	if err != nil {
   458  		return err
   459  	}
   460  	return jsonutils.Update(self, host)
   461  }
   462  
   463  func (self *SHost) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
   464  	return self.zone.GetIStorages()
   465  }
   466  
   467  func (self *SHost) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
   468  	return self.zone.GetIStorageById(id)
   469  }
   470  
   471  func (self *SHost) GetIVMs() ([]cloudprovider.ICloudVM, error) {
   472  	vms, err := self.zone.region.GetInstances()
   473  	if err != nil {
   474  		return nil, errors.Wrapf(err, "GetInstances")
   475  	}
   476  	ret := []cloudprovider.ICloudVM{}
   477  	for i := range vms {
   478  		if vms[i].HostUUID == self.UUID || (self.firstHost && len(vms[i].HostUUID) == 0) {
   479  			vms[i].host = self
   480  			ret = append(ret, &vms[i])
   481  		}
   482  	}
   483  	return ret, nil
   484  }
   485  
   486  func (self *SHost) GetIVMById(id string) (cloudprovider.ICloudVM, error) {
   487  	vm, err := self.zone.region.GetInstance(id)
   488  	if err != nil {
   489  		return nil, errors.Wrapf(err, "GetInstance")
   490  	}
   491  	if len(vm.HostUUID) > 0 && vm.HostUUID != self.UUID {
   492  		return nil, errors.Wrapf(cloudprovider.ErrNotFound, "vm not locate host %s, it locate host %s", self.Name, vm.HostUUID)
   493  	}
   494  	vm.host = self
   495  	return vm, nil
   496  }
   497  
   498  func (self *SHost) GetIWires() ([]cloudprovider.ICloudWire, error) {
   499  	vpcs, err := self.zone.region.GetIVpcs()
   500  	if err != nil {
   501  		return nil, err
   502  	}
   503  	ret := []cloudprovider.ICloudWire{}
   504  	for i := range vpcs {
   505  		wires, err := vpcs[i].GetIWires()
   506  		if err != nil {
   507  			return nil, errors.Wrapf(err, "GetIWires")
   508  		}
   509  		ret = append(ret, wires...)
   510  	}
   511  	return ret, nil
   512  }