Skip to content

Commit 95a9ae6

Browse files
committed
convert console_supported? to supports
1 parent e0d3d0a commit 95a9ae6

File tree

1 file changed

+10
-12
lines changed
  • app/models/manageiq/providers/ibm_cloud/power_virtual_servers/cloud_manager

1 file changed

+10
-12
lines changed

app/models/manageiq/providers/ibm_cloud/power_virtual_servers/cloud_manager/vm.rb

+10-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ class ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::Vm < Man
22
include Operations
33

44
supports :capture
5+
# leverages the logic of native_console
6+
supports(:console) { unsupported_reason(:native_console) }
7+
supports :vnc_console
58
supports :terminate
69
supports :reboot_guest do
710
_("The VM is not powered on") unless current_state == "on"
@@ -20,22 +23,21 @@ class ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::Vm < Man
2023
supports_not :suspend
2124

2225
supports :publish do
23-
return _("Publish not supported because VM is blank") if blank?
24-
return _("Publish not supported because VM is orphaned") if orphaned?
25-
return _("Publish not supported because VM is archived") if archived?
26+
unsupported_reason(:action)
2627
end
2728

2829
# TODO: converge these all into console and use unsupported_reason(:console) for all
2930
supports :html5_console do
30-
return _("VM Console not supported because VM is not powered on") unless current_state == "on"
31-
return _("VM Console not supported because VM is orphaned") if orphaned?
32-
return _("VM Console not supported because VM is archived") if archived?
31+
if current_state != "on"
32+
_("VM Console not supported because VM is not powered on")
33+
else
34+
unsupported_reason(:native_console)
35+
end
3336
end
3437
supports :launch_html5_console
3538

3639
supports :native_console do
37-
return _("VM Console not supported because VM is orphaned") if orphaned?
38-
return _("VM Console not supported because VM is archived") if archived?
40+
unsupported_reason(:action)
3941
end
4042

4143
supports :resize do
@@ -201,10 +203,6 @@ def self.calculate_power_state(raw_power_state)
201203
end
202204
end
203205

204-
def console_supported?(type)
205-
return true if type.upcase == 'VNC'
206-
end
207-
208206
def console_url
209207
crn = ERB::Util.url_encode(ext_management_system.pcloud_crn.values.join(":"))
210208
params = URI.encode_www_form(:paneId => "manageiq", :crn => crn)

0 commit comments

Comments
 (0)