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

Separate Storage Managers By Type in UI #12399

Merged
Next Next commit
Separate Storage Managers By Type in UI
1. Add the ability to show Storage Managers by the type of storage they support.
2. Add supports_block_storage? and supports_object_storage? methods
   and add them to the Cinder and Swift managers, respectively.
3. Change the UI so that it Shows Block and Object storage and the managers for each
   separately.
4. Make menu and headings for Storage Managers consistent (remove any indication that the
   Managers are "Providers").
  • Loading branch information
jerryk55 committed Nov 30, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6a1ee1ab43b0ae0457a752895b67ed4dc591212e
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ def self.display_methods
private

def get_session_data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could use the GenericSessionMixin here instead of having an own method (and altering the way @title is calculated).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinpovolny I didn't add this controller or even this method as part of this PR. I only changed the string value of the title.

@title = _("Cloud Object Stores")
@title = _("Cloud Object Store Containers")
@layout = "cloud_object_store_container"
@lastaction = session[:cloud_object_store_container_lastaction]
@display = session[:cloud_object_store_container_display]
38 changes: 38 additions & 0 deletions app/controllers/ems_block_storage_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class EmsBlockStorageController < ApplicationController
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess you need a menu_section line in this controller.

Copy link
Member Author

@jerryk55 jerryk55 Nov 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinpovolny just curious - what is that supposed to do - the menu code clearly works for me without the line in both the EmsBlockStorageController and EmsObjectStorageController - neither of which have it. Also I've moved some of the menu sections around for these controllers and it appears that there may be other changes needed if this actually has an effect.Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind that - @h-kataria has explained it to me. I have made the required changes to each controller represented by a modified entry in the Menu::DefaultMenu.

include EmsCommon
include Mixins::EmsCommonAngular
include Mixins::GenericSessionMixin

before_action :check_privileges
before_action :get_session_data
after_action :cleanup_action
after_action :set_session_data

def self.model
ManageIQ::Providers::StorageManager
end

def self.table_name
@table_name ||= "ems_storage"
end

def ems_path(*args)
path_hash = {:action => 'show', :id => args[0].id.to_s }
path_hash.merge(args[1])
end

def new_ems_path
{:action => 'new'}
end

def ems_storage_form_fields
ems_form_fields
end

# Show the main MS list view
def show_list
opts = {:supported_features_filter => "supports_block_storage?",
:model => model}
process_show_list(opts)
end
end
8 changes: 7 additions & 1 deletion app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
@@ -76,14 +76,20 @@ def view_setup_params
{
"instances" => [ManageIQ::Providers::CloudManager::Vm, _("Instances")],
"images" => [ManageIQ::Providers::CloudManager::Template, _("Images")],
"block_storage_managers" => [ManageIQ::Providers::StorageManager,
_("Block Storage Managers"),
:block_storage_managers],
"object_storage_managers" => [ManageIQ::Providers::StorageManager,
_("Object Storage Managers"),
:object_storage_managers],
"storage_managers" => [ManageIQ::Providers::StorageManager,
_("Storage Managers"),
:storage_managers],
"miq_templates" => [MiqTemplate, _("Templates")],
"vms" => [Vm, _("VMs")],
"orchestration_stacks" => [OrchestrationStack, _("Stacks")],
# "configuration_jobs" => [ConfigurationJob, _("Configuration Jobs")],
"cloud_object_store_containers" => [CloudObjectStoreContainer, _('Cloud Object Stores')],
"cloud_object_store_containers" => [CloudObjectStoreContainer, _('Cloud Object Store Containers')],
'containers' => [Container, _('Containers')],
'container_replicators' => [ContainerReplicator, _('Container Replicators')],
'container_nodes' => [ContainerNode, _('Container Nodes')],
37 changes: 37 additions & 0 deletions app/controllers/ems_object_storage_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class EmsObjectStorageController < ApplicationController
include EmsCommon
include Mixins::EmsCommonAngular
include Mixins::GenericSessionMixin

before_action :check_privileges
before_action :get_session_data
after_action :cleanup_action
after_action :set_session_data

def self.model
ManageIQ::Providers::StorageManager
end

def self.table_name
@table_name ||= "ems_storage"
end

def ems_path(*args)
path_hash = {:action => 'show', :id => args[0].id.to_s }
path_hash.merge(args[1])
end

def show_list
opts = {:supported_features_filter => "supports_object_storage?",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to force the use of GenericListMixin for all the show_list implementations one by one. So would be nice if you could follow that pattern but I understand that you are following another pattern here and it's hard to tell which one to choose :-(

So I can fix this later on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks.

:model => model}
process_show_list(opts)
end

def new_ems_path
{:action => 'new'}
end

def ems_storage_form_fields
ems_form_fields
end
end
2 changes: 2 additions & 0 deletions app/models/manageiq/providers/storage_manager.rb
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ module ManageIQ::Providers
class StorageManager < ManageIQ::Providers::BaseManager
include SupportsFeatureMixin
supports_not :smartstate_analysis
supports_not :block_storage
supports_not :object_storage

belongs_to :parent_manager,
:foreign_key => :parent_ems_id,
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ class ManageIQ::Providers::StorageManager::CinderManager < ManageIQ::Providers::
:to => :parent_manager,
:allow_nil => true

supports :block_storage
supports :cinder_service do
if parent_manager
unsupported_reason_add(:cinder_service, parent_manager.unsupported_reason(:cinder_service)) unless
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ class ManageIQ::Providers::StorageManager::SwiftManager < ManageIQ::Providers::S
:to => :parent_manager,
:allow_nil => true

supports :object_storage
supports :swift_service do
if parent_manager
unsupported_reason_add(:swift_service, parent_manager.unsupported_reason(:swift_service)) unless
4 changes: 2 additions & 2 deletions app/models/miq_report/search.rb
Original file line number Diff line number Diff line change
@@ -100,8 +100,8 @@ def paged_view_search(options = {})
targets = db_class
end
supported_features_filter = search_options.delete(:supported_features_filter) if search_options[:supported_features_filter]
search_results, attrs = Rbac.search(search_options.merge(:targets => targets))
filtered_results = filter_results(search_results, supported_features_filter)
search_results, attrs = Rbac.search(search_options.merge(:targets => targets))
filtered_results = filter_results(search_results, supported_features_filter)

if order.nil?
options[:limit] = limit
2 changes: 2 additions & 0 deletions app/models/mixins/supports_feature_mixin.rb
Original file line number Diff line number Diff line change
@@ -110,6 +110,8 @@ module SupportsFeatureMixin
:update_network_router => 'Network Router Update',
:ems_network_new => 'New EMS Network Provider',
:update_security_group => 'Security Group Update',
:block_storage => 'Block Storage',
:object_storage => 'Object Storage',
}.freeze

# Whenever this mixin is included we define all features as unsupported by default.
52 changes: 48 additions & 4 deletions app/presenters/menu/default_menu.rb
Original file line number Diff line number Diff line change
@@ -152,10 +152,54 @@ def network_menu_section
def storage_menu_section
netapp_enabled = ::Settings.product.storage
Menu::Section.new(:sto, N_("Storage"), 'fa fa-database fa-2x', [
Menu::Item.new('ems_storage', N_('Storage Providers'), 'ems_storage', {:feature => 'ems_storage_show_list'}, '/ems_storage'),
Menu::Item.new('cloud_volume', N_('Volumes'), 'cloud_volume', {:feature => 'cloud_volume_show_list'}, '/cloud_volume'),
Menu::Item.new('cloud_object_store_container', N_('Object Stores'), 'cloud_object_store_container', {:feature => 'cloud_object_store_container_show_list'}, '/cloud_object_store_container'),
])
block_storage_menu_section,
object_storage_menu_section,
])
end

def block_storage_menu_section
Menu::Section.new(:bst, N_("Block Storage"), 'fa fa-database fa-2x', [
Menu::Item.new('ems_storage',
N_('Managers'),
'ems_block_storage',
{:feature => 'ems_block_storage_show_list'},
'/ems_block_storage'),
Menu::Item.new('cloud_volume',
N_('Volumes'),
'cloud_volume',
{:feature => 'cloud_volume_show_list'},
'/cloud_volume'),
Menu::Item.new('cloud_volume_snapshot',
N_('Volume Snapshots'),
'cloud_volume_snapshot',
{:feature => 'cloud_volume_snapshot_show_list'},
'/cloud_volume_snapshot'),
Menu::Item.new('cloud_volume_backup',
N_('Volume Backups'),
'cloud_volume_backup',
{:feature => 'cloud_volume_backup_show_list'},
'/cloud_volume_backup'),
])
end

def object_storage_menu_section
Menu::Section.new(:ost, N_("Object Storage"), 'fa fa-database fa-2x', [
Menu::Item.new('ems_storage',
N_('Managers'),
'ems_object_storage',
{:feature => 'ems_object_storage_show_list'},
'/ems_object_storage'),
Menu::Item.new('cloud_object_store_container',
N_('Object Store Containers'),
'cloud_object_store_container',
{:feature => 'cloud_object_store_container_show_list'},
'/cloud_object_store_container'),
Menu::Item.new('cloud_object_store_object',
N_('Object Store Objects'),
'cloud_object_store_object',
{:feature => 'cloud_object_store_object_show_list'},
'/cloud_object_store_object'),
])
end

def empty_menu_section
1 change: 1 addition & 0 deletions app/views/ems_block_storage/_main.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render(:partial => "shared/views/ems_common/main")
19 changes: 19 additions & 0 deletions app/views/ems_block_storage/edit.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- url = url_for(:controller => 'ems_block_storage', :action => 'update', :id => "#{@ems.id || 'new'}")
= form_for(@ems,
:url => url,
:method => :post,
:html => {"ng-controller" => "emsCommonFormController",
"name" => "angularForm",
"ng-show" => "afterGet",
"update-url" => url,
"form-fields-url" => "/#{controller_name}/ems_block_storage_form_fields/",
"novalidate" => true}) do |f|
%input{:type => 'hidden', :id => "form_id", :value => "##{f.options[:html][:id]}"}
%input{:type => 'hidden', :id => "button_name", :name => "button", :value => "save"}
%input{:type => 'hidden', :id => "cred_type", :name => "cred_type", :value => "default"}
= render :partial => "shared/views/ems_common/angular/form"

:javascript
ManageIQ.angular.app.value('emsCommonFormId', '#{@ems.id || "new"}');
miq_bootstrap($('#form_id').val());

20 changes: 20 additions & 0 deletions app/views/ems_block_storage/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- url = url_for(:controller => 'ems_block_storage', :action => 'create', :id => "#{@ems.id || 'new'}")
= form_for(@ems,
:url => url,
:method => :post,
:html => {"ng-controller" => "emsCommonFormController",
"name" => "angularForm",
"ng-show" => "afterGet",
"create-url" => url,
"form-fields-url" => "/#{controller_name}/ems_block_storage_form_fields/",
"novalidate" => true}) do |f|
%input{:type => 'hidden', :id => "form_id", :value => "##{f.options[:html][:id]}"}
%input{:type => 'hidden', :id => "button_name", :name => "button", :value => "add"}
%input{:type => 'hidden', :id => "cred_type", :name => "cred_type", :value => "default"}

= render :partial => "shared/views/ems_common/angular/form"

:javascript
ManageIQ.angular.app.value('emsCommonFormId', '#{@ems.id || "new"}');
miq_bootstrap($('#form_id').val());

1 change: 1 addition & 0 deletions app/views/ems_block_storage/show_list.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#main_div= render :partial => "layouts/gtl"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#main_div= render :partial => "layouts/tl_show"
1 change: 1 addition & 0 deletions app/views/ems_object_storage/_main.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render(:partial => "shared/views/ems_common/main")
19 changes: 19 additions & 0 deletions app/views/ems_object_storage/edit.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- url = url_for(:controller => 'ems_object_storage', :action => 'update', :id => "#{@ems.id || 'new'}")
= form_for(@ems,
:url => url,
:method => :post,
:html => {"ng-controller" => "emsCommonFormController",
"name" => "angularForm",
"ng-show" => "afterGet",
"update-url" => url,
"form-fields-url" => "/#{controller_name}/ems_object_storage_form_fields/",
"novalidate" => true}) do |f|
%input{:type => 'hidden', :id => "form_id", :value => "##{f.options[:html][:id]}"}
%input{:type => 'hidden', :id => "button_name", :name => "button", :value => "save"}
%input{:type => 'hidden', :id => "cred_type", :name => "cred_type", :value => "default"}
= render :partial => "shared/views/ems_common/angular/form"

:javascript
ManageIQ.angular.app.value('emsCommonFormId', '#{@ems.id || "new"}');
miq_bootstrap($('#form_id').val());

20 changes: 20 additions & 0 deletions app/views/ems_object_storage/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- url = url_for(:controller => 'ems_object_storage', :action => 'create', :id => "#{@ems.id || 'new'}")
= form_for(@ems,
:url => url,
:method => :post,
:html => {"ng-controller" => "emsCommonFormController",
"name" => "angularForm",
"ng-show" => "afterGet",
"create-url" => url,
"form-fields-url" => "/#{controller_name}/ems_object_storage_form_fields/",
"novalidate" => true}) do |f|
%input{:type => 'hidden', :id => "form_id", :value => "##{f.options[:html][:id]}"}
%input{:type => 'hidden', :id => "button_name", :name => "button", :value => "add"}
%input{:type => 'hidden', :id => "cred_type", :name => "cred_type", :value => "default"}

= render :partial => "shared/views/ems_common/angular/form"

:javascript
ManageIQ.angular.app.value('emsCommonFormId', '#{@ems.id || "new"}');
miq_bootstrap($('#form_id').val());

1 change: 1 addition & 0 deletions app/views/ems_object_storage/show_list.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#main_div= render :partial => "layouts/gtl"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#main_div= render :partial => "layouts/tl_show"
87 changes: 87 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -2084,6 +2084,93 @@
ownership_post
},

:ems_block_storage => {
:get => %w(
dialog_load
download_data
edit
ems_storage_form_fields
index
new
protect
show
show_list
tagging_edit
tag_edit_form_field_changed
) +
compare_get,
:post => %w(
button
create
dynamic_checkbox_refresh
dynamic_list_refresh
dynamic_radio_button_refresh
dynamic_text_box_refresh
form_field_changed
listnav_search_selected
protect
provider_type_field_changed
quick_search
sections_field_changed
show
show_list
quick_search
tag_edit_form_field_changed
tagging_edit
tl_chooser
update
wait_for_task
) +
adv_search_post +
compare_post +
dialog_runner_post +
exp_post +
save_post
},

:ems_object_storage => {
:get => %w(
dialog_load
download_data
edit
ems_storage_form_fields
index
new
protect
show
show_list
tagging_edit
tag_edit_form_field_changed
) +
compare_get,
:post => %w(
button
create
dynamic_checkbox_refresh
dynamic_list_refresh
dynamic_radio_button_refresh
dynamic_text_box_refresh
form_field_changed
listnav_search_selected
protect
provider_type_field_changed
quick_search
sections_field_changed
show
show_list
tag_edit_form_field_changed
tagging_edit
tl_chooser
update
wait_for_task
) +
adv_search_post +
compare_post +
dialog_runner_post +
exp_post +
save_post
},

:ems_storage => {
:get => %w(
dialog_load
Loading