Skip to content

Commit 26c18e4

Browse files
committed
Convert Host operations to supports feature
1 parent 268a7a0 commit 26c18e4

File tree

1 file changed

+15
-0
lines changed
  • app/models/manageiq/providers/vmware/infra_manager

1 file changed

+15
-0
lines changed

app/models/manageiq/providers/vmware/infra_manager/host_esx.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ class ManageIQ::Providers::Vmware::InfraManager::HostEsx < ManageIQ::Providers::
22
supports :refresh_advanced_settings
33
supports :refresh_firewall_rules
44
supports :refresh_logs
5+
supports :reboot { validate_active_with_power_state(:reboot, "on") }
6+
supports :shutdown { validate_active_with_power_state(:shutdown, "on") }
7+
supports :standby { validate_active_with_power_state(:standby, "on") }
8+
supports :enter_maint_mode { validate_active_with_power_state(:enter_maint_mode, "on") }
9+
supports :exit_maint_mode { validate_active_with_power_state(:exit_maint_mode, "maintenance") }
10+
supports :enable_vmotion { validate_active_with_power_state(:enable_vmotion, "on") }
11+
supports :disable_vmotion { validate_active_with_power_state(:disable_vmotion, "on") }
12+
supports :vmotion { validate_active_with_power_state(:vmotion, "on") }
513

614
def vim_shutdown(force = false)
715
with_provider_object do |vim_host|
@@ -177,4 +185,11 @@ def thumbprint_sha1
177185
require 'VMwareWebService/esx_thumb_print'
178186
ESXThumbPrint.new(ipaddress, authentication_userid, authentication_password).to_sha1
179187
end
188+
189+
private
190+
191+
def validate_active_with_power_state(feature, expected_power_state)
192+
return unsupported_reason_add(feature, _("The Host is not connected to an active Provider")) unless has_active_ems?
193+
return unsupported_reason_add(feature, _("The host is not powered '#{expected_power_state}'")) unless expected_power_state == power_state
194+
end
180195
end

0 commit comments

Comments
 (0)