Skip to content

Commit bc5c31d

Browse files
committed
Remove return from supports block
Introduced by ManageIQ#486 you can not have a return in a block. It causes a LongJump error Besides, it tries to return from inside the calling block - not what we want.
1 parent 691a9ca commit bc5c31d

File tree

3 files changed

+46
-19
lines changed
  • app/models/manageiq/providers/ibm_cloud

3 files changed

+46
-19
lines changed

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

+26-11
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,43 @@ class ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::Vm < Man
2020
supports_not :suspend
2121

2222
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?
23+
if blank?
24+
_("Publish not supported because VM is blank")
25+
elsif orphaned?
26+
_("Publish not supported because VM is orphaned")
27+
elsif archived?
28+
_("Publish not supported because VM is archived")
29+
end
2630
end
2731

2832
# TODO: converge these all into console and use unsupported_reason(:console) for all
2933
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?
34+
if current_state != "on"
35+
_("VM Console not supported because VM is not powered on")
36+
elsif orphaned?
37+
_("VM Console not supported because VM is orphaned")
38+
elsif archived?
39+
_("VM Console not supported because VM is archived")
40+
end
3341
end
3442
supports :launch_html5_console
3543

3644
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?
45+
if orphaned?
46+
_("VM Console not supported because VM is orphaned")
47+
elsif archived?
48+
_("VM Console not supported because VM is archived")
49+
end
3950
end
4051

4152
supports :resize do
42-
return _('The VM is not powered off') unless current_state == "off"
43-
return _('The VM is not connected to a provider') unless ext_management_system
44-
return _('SAP VM resize not supported') if flavor.kind_of?(ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::SAPProfile)
53+
if current_state != "off"
54+
_('The VM is not powered off')
55+
elsif ext_management_system.nil?
56+
_('The VM is not connected to a provider')
57+
elsif flavor.kind_of?(ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::SAPProfile)
58+
_('SAP VM resize not supported')
59+
end
4560
end
4661

4762
def cloud_instance_id

app/models/manageiq/providers/ibm_cloud/power_virtual_servers/storage_manager/cloud_volume.rb

+15-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@ class ManageIQ::Providers::IbmCloud::PowerVirtualServers::StorageManager::CloudV
22
supports :create
33
supports :clone
44
supports :delete do
5-
return _("the volume is not connected to an active Provider") unless ext_management_system
6-
return _("cannot delete volume that is in use.") if status == "in-use"
5+
if ext_management_system.nil?
6+
_("the volume is not connected to an active Provider")
7+
elsif status == "in-use"
8+
_("cannot delete volume that is in use.")
9+
end
710
end
811
supports_not :snapshot_create
912
supports_not :update
1013
supports :attach do
11-
return _("the volume is not connected to an active Provider") unless ext_management_system
12-
return _("cannot attach non-shareable volume that is in use.") if status == "in-use" && !multi_attachment
14+
if ext_management_system.nil?
15+
_("the volume is not connected to an active Provider")
16+
elsif status == "in-use" && !multi_attachment
17+
_("cannot attach non-shareable volume that is in use.")
18+
end
1319
end
1420
supports :detach do
15-
return _("the volume is not connected to an active Provider") unless ext_management_system
16-
return _("the volume status is '%{status}' but should be 'in-use'") % {:status => status} unless status == "in-use"
21+
if ext_management_system.nil?
22+
_("the volume is not connected to an active Provider")
23+
elsif status != "in-use"
24+
_("the volume status is '%{status}' but should be 'in-use'") % {:status => status}
25+
end
1726
end
1827

1928
def available_vms

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ def raw_destroy
112112
end
113113

114114
supports :resize do
115-
return _('The VM is not powered off') unless current_state == "off"
116-
return _('The VM is not connected to a provider') unless ext_management_system
115+
if current_state != "off"
116+
_('The VM is not powered off')
117+
elsif ext_management_system.nil?
118+
_('The VM is not connected to a provider')
119+
end
117120
end
118121

119122
def raw_resize(options)

0 commit comments

Comments
 (0)