Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the suspension of cloud, infra and physical infra providers #4269

Merged
merged 9 commits into from
Jan 17, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.name = data.name;
$scope.emsCommonModel.emstype = data.emstype;
$scope.emsCommonModel.zone = data.zone;
$scope.emsCommonModel.zone_hidden = data.zone_hidden;
$scope.emsCommonModel.tenant_mapping_enabled = data.tenant_mapping_enabled;
$scope.emsCommonModel.hostname = data.hostname;
$scope.emsCommonModel.default_hostname = data.default_hostname;
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def set_form_vars

def form_instance_vars
@server_zones = []
zones = Zone.order('lower(description)')
zones = Zone.visible.order('lower(description)')
zones.each do |zone|
@server_zones.push([zone.description, zone.name])
end
Expand Down Expand Up @@ -647,8 +647,8 @@ def process_emss(emss, task)
:userid => session[:userid]}
AuditEvent.success(audit)

ems.disable! if action == "pause"
ems.enable! if action == "resume"
ems.pause! if action == "pause"
ems.resume! if action == "resume"
end
else
model.where(:id => emss).order("lower(name)").each do |ems|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/miq_task_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def build_jobs_tab
@pp_choices = PPCHOICES2 # Get special pp choices for jobs/tasks lists
@settings[:perpage][:job_task] ||= 50 # Default to 50 per page until changed
@tasks_options = HashWithIndifferentAccess.new if @tasks_options.blank?
@tasks_options[:zones] = Zone.all.collect { |z| z.name if z.miq_servers.present? }.compact
@tasks_options[:zones] = Zone.visible.includes(:miq_servers).collect { |z| z.name if z.miq_servers.present? }.compact
tasks_set_default_options if @tasks_options[@tabform].blank?

@tabs ||= []
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/mixins/ems_common_angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def ems_form_fields
render :json => {:name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
:zone_hidden => zone == MiqRegion.my_region.maintenance_zone.name,
:tenant_mapping_enabled => @ems.tenant_mapping_enabled == true,
:provider_id => @ems.provider_id || "",
:hostname => @ems.hostname,
Expand Down Expand Up @@ -410,6 +411,7 @@ def ems_form_fields
render :json => { :name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
:zone_hidden => zone == MiqRegion.my_region.maintenance_zone.name,
:provider_id => @ems.provider_id || "",
:default_hostname => @ems.connection_configurations.default.endpoint.hostname,
:amqp_hostname => amqp_hostname,
Expand Down Expand Up @@ -455,6 +457,7 @@ def ems_form_fields
render :json => {:name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
:zone_hidden => zone == MiqRegion.my_region.maintenance_zone.name,
:hostname => @ems.hostname,
:default_hostname => @ems.connection_configurations.default.endpoint.hostname,
:default_api_port => @ems.connection_configurations.default.endpoint.port,
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/mixins/manager_controller_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ def model_to_type_name(provmodel)
def new
assert_privileges("#{privilege_prefix}_add_provider")
@provider_manager = concrete_model.new
@server_zones = Zone.in_my_region.order('lower(description)').pluck(:description, :name)
@server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name)
render_form
end

def edit
@server_zones = Zone.in_my_region.order('lower(description)').pluck(:description, :name)
@server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name)
case params[:button]
when "cancel"
cancel_provider
Expand Down Expand Up @@ -279,7 +279,7 @@ def form_fields
assert_privileges("#{privilege_prefix}_edit_provider")
# set value of read only zone text box, when there is only single zone
if params[:id] == "new"
return render(:json => {:zone => Zone.in_my_region.size >= 1 ? Zone.in_my_region.first.name : nil})
return render(:json => {:zone => Zone.visible.in_my_region.size >= 1 ? Zone.visible.in_my_region.first.name : nil})
end

manager = find_record(concrete_model, params[:id])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ops_controller/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def db_list(exp = nil)
]
)
elsif model == VmdbDatabaseConnection
@zones = Zone.all.sort_by(&:name).collect { |z| [z.name, z.name] }
@zones = Zone.visible.order(&:name).collect { |z| [z.name, z.name] }
# for now we dont need this pulldown, need to get a method that gives us a list of workers for filter pulldown
# @workers = MiqWorker.all.sort_by(&:type).collect { |w| [w.friendly_name, w.id] }
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ops_controller/diagnostics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def diagnostics_set_form_vars
end
elsif x_node == "root"
if @sb[:active_tab] == "diagnostics_zones"
@zones = Zone.in_my_region
@zones = Zone.visible.in_my_region
elsif %w(diagnostics_roles_servers diagnostics_servers_roles).include?(@sb[:active_tab])
@selected_server = MiqRegion.my_region
@sb[:selected_server_id] = @selected_server.id
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/ops_controller/settings/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ def settings_get_info(nodetype = x_node)
case nodes[1]
when "z"
@right_cell_text = _("Settings Zones")
@zones = Zone.in_my_region
@zones = Zone.visible.in_my_region
when "sis"
@right_cell_text = _("Settings Analysis Profiles")
aps_list
Expand Down Expand Up @@ -1279,7 +1279,7 @@ def settings_set_view_vars
if @sb[:active_tab] == "settings_details"
# Enterprise Details tab
@scan_items = ScanItemSet.all
@zones = Zone.in_my_region
@zones = Zone.visible.in_my_region
@miq_schedules = MiqSchedule.where("(prod_default != 'system' or prod_default is null) and adhoc IS NULL")
.sort_by { |s| s.name.downcase }
end
Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper/button/ems_refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class ApplicationHelper::Button::EmsRefresh < ApplicationHelper::Button::Basic

def disabled?
super
@error_message ||= _("Unable to refresh the provider while it is suspended") unless @record.enabled?
@error_message ||= _("Credentials must be valid to refresh a provider") unless @record.authentication_status.downcase == "valid"
@error_message.present?
end
Expand Down
17 changes: 17 additions & 0 deletions app/helpers/application_helper/toolbar/ems_cloud_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ class ApplicationHelper::Toolbar::EmsCloudCenter < ApplicationHelper::Toolbar::B
t = N_('Edit this Cloud Provider'),
t,
:full_path => "<%= edit_ems_cloud_path(@ems) %>"),
button(
:ems_cloud_resume,
'pficon pficon-trend-up fa-lg',
t = N_('Resume this Cloud Provider'),
t,
:confirm => N_("Resume this Cloud Provider?"),
:enabled => proc { [email protected]? },
:url_parms => "main_div"),
button(
:ems_cloud_pause,
'pficon pficon-trend-down fa-lg',
t = N_('Pause this Cloud Provider'),
t,
:confirm => N_("Warning: While this provider is paused no data will be collected from it. " \
"This may cause gaps in inventory, metrics and events!"),
:enabled => proc { @record.enabled? },
:url_parms => "main_div"),
button(
:ems_cloud_delete,
'pficon pficon-delete fa-lg',
Expand Down
21 changes: 21 additions & 0 deletions app/helpers/application_helper/toolbar/ems_clouds_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ class ApplicationHelper::Toolbar::EmsCloudsCenter < ApplicationHelper::Toolbar::
:send_checked => true,
:enabled => false,
:onwhen => "1"),
button(
:ems_cloud_resume,
'pficon pficon-trend-up fa-lg',
t = N_('Resume selected Cloud Providers'),
t,
:confirm => N_("Resume these Cloud Providers?"),
:enabled => false,
:url_parms => "main_div",
:send_checked => true,
:onwhen => "1+"),
button(
:ems_cloud_pause,
'pficon pficon-trend-down fa-lg',
t = N_('Pause selected Cloud Providers'),
t,
:confirm => N_("Warning: While these providers are paused no data will be collected from them. " \
"This may cause gaps in inventory, metrics and events!"),
:enabled => false,
:url_parms => "main_div",
:send_checked => true,
:onwhen => "1+"),
button(
:ems_cloud_delete,
'pficon pficon-delete fa-lg',
Expand Down
17 changes: 17 additions & 0 deletions app/helpers/application_helper/toolbar/ems_infra_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ class ApplicationHelper::Toolbar::EmsInfraCenter < ApplicationHelper::Toolbar::B
'pficon pficon-edit fa-lg',
t = N_('Edit this Infrastructure Provider'),
t),
button(
:ems_infra_resume,
'pficon pficon-trend-up fa-lg',
t = N_('Resume this Infrastructure Provider'),
t,
:confirm => N_("Resume this Infrastructure Provider?"),
:enabled => proc { [email protected]? },
:url_parms => "main_div"),
button(
:ems_infra_pause,
'pficon pficon-trend-down fa-lg',
t = N_('Pause this Infrastructure Provider'),
t,
:confirm => N_("Warning: While this provider is paused no data will be collected from it. " \
"This may cause gaps in inventory, metrics and events!"),
:enabled => proc { @record.enabled? },
:url_parms => "main_div"),
button(
:ems_infra_scale,
'pficon pficon-edit fa-lg',
Expand Down
21 changes: 21 additions & 0 deletions app/helpers/application_helper/toolbar/ems_infras_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ class ApplicationHelper::Toolbar::EmsInfrasCenter < ApplicationHelper::Toolbar::
:send_checked => true,
:enabled => false,
:onwhen => "1"),
button(
:ems_infra_resume,
'pficon pficon-trend-up fa-lg',
t = N_('Resume selected Infrastructure Providers'),
t,
:confirm => N_("Resume these Infrastructure Providers?"),
:enabled => false,
:url_parms => "main_div",
:send_checked => true,
:onwhen => "1+"),
button(
:ems_infra_pause,
'pficon pficon-trend-down fa-lg',
t = N_('Pause selected Infrastructure Providers'),
t,
:confirm => N_("Warning: While these providers are paused no data will be collected from them. " \
"This may cause gaps in inventory, metrics and events!"),
:enabled => false,
:url_parms => "main_div",
:send_checked => true,
:onwhen => "1+"),
button(
:ems_infra_delete,
'pficon pficon-delete fa-lg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ class ApplicationHelper::Toolbar::EmsPhysicalInfraCenter < ApplicationHelper::To
'pficon pficon-edit fa-lg',
t = N_('Edit this Infrastructure Provider'),
t),
button(
:ems_physical_infra_resume,
'pficon pficon-trend-up fa-lg',
t = N_('Resume this Infrastructure Provider'),
t,
:confirm => N_("Resume this Infrastructure Provider?"),
:enabled => proc { [email protected]? },
:url_parms => "main_div"),
button(
:ems_physical_infra_pause,
'pficon pficon-trend-down fa-lg',
t = N_('Pause this Infrastructure Provider'),
t,
:confirm => N_("Warning: While this provider is paused no data will be collected from it. " \
"This may cause gaps in inventory, metrics and events!"),
:enabled => proc { @record.enabled? },
:url_parms => "main_div"),
button(
:ems_physical_infra_delete,
'pficon pficon-delete fa-lg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ class ApplicationHelper::Toolbar::EmsPhysicalInfrasCenter < ApplicationHelper::T
:send_checked => true,
:enabled => false,
:onwhen => "1"),
button(
:ems_physical_infra_resume,
'pficon pficon-trend-up fa-lg',
t = N_('Resume selected Infrastructure Providers'),
t,
:confirm => N_("Resume these Infrastructure Providers?"),
:enabled => false,
:url_parms => "main_div",
:send_checked => true,
:onwhen => "1+"),
button(
:ems_physical_infra_pause,
'pficon pficon-trend-down fa-lg',
t = N_('Pause selected Infrastructure Providers'),
t,
:confirm => N_("Warning: While these providers are paused no data will be collected from them. " \
"This may cause gaps in inventory, metrics and events!"),
:enabled => false,
:url_parms => "main_div",
:send_checked => true,
:onwhen => "1+"),
button(
:ems_physical_infra_delete,
'pficon pficon-delete fa-lg',
Expand Down
5 changes: 1 addition & 4 deletions app/helpers/ems_cloud_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module EmsCloudHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -145,10 +146,6 @@ def textual_security_groups
h
end

def textual_zone
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => @record.zone.name}
end

def textual_topology
{:label => _('Topology'),
:icon => "pficon pficon-topology",
Expand Down
5 changes: 1 addition & 4 deletions app/helpers/ems_container_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module EmsContainerHelper::TextualSummary
include TextualMixins::TextualMetricsStatus
include TextualMixins::TextualDataCollectionState
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -70,10 +71,6 @@ def textual_port
@record.supports_port? ? @record.port : nil
end

def textual_zone
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => @record.zone.name}
end

def textual_topology
{:label => _('Topology'),
:icon => "pficon pficon-topology",
Expand Down
5 changes: 1 addition & 4 deletions app/helpers/ems_infra_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module EmsInfraHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -169,10 +170,6 @@ def textual_orchestration_stacks
@record.orchestration_stacks
end

def textual_zone
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => @record.zone.name}
end

def textual_host_default_vnc_port_range
return nil if @record.host_default_vnc_port_start.blank?
value = "#{@record.host_default_vnc_port_start} - #{@record.host_default_vnc_port_end}"
Expand Down
5 changes: 1 addition & 4 deletions app/helpers/ems_network_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module EmsNetworkHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -102,10 +103,6 @@ def textual_topology
:title => _("Show topology")}
end

def textual_zone
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => @record.zone.try(:name)}
end

def textual_cloud_tenants
textual_link(
@record.try(:cloud_tenants),
Expand Down
5 changes: 1 addition & 4 deletions app/helpers/ems_physical_infra_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module EmsPhysicalInfraHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -105,10 +106,6 @@ def textual_vms
textual_link(@record.vms, :label => _("Virtual Machines"))
end

def textual_zone
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => @record.zone.name}
end

def textual_topology
{:label => _('Topology'),
:icon => "pficon pficon-topology",
Expand Down
5 changes: 1 addition & 4 deletions app/helpers/ems_storage_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module EmsStorageHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -61,10 +62,6 @@ def textual_parent_ems_cloud
textual_link(@record.try(:parent_manager), :label => _("Parent Cloud Provider"))
end

def textual_zone
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => @record.zone.try(:name)}
end

def textual_cloud_volumes
textual_link(@record.try(:cloud_volumes), :label => _('Cloud Volumes'))
end
Expand Down
Loading