-
Notifications
You must be signed in to change notification settings - Fork 897
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
Catalog Item type list is dependent on installed providers #16559
Conversation
@Fryguy @bzwei @h-kataria |
app/models/service_template.rb
Outdated
end | ||
|
||
def self.generic_ansible_playbook_provider_present? | ||
ExtManagementSystem.where(:type => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager").any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should check whether it is enabled.
app/models/service_template.rb
Outdated
ORCHESTRATION_PROVIDER_TYPES = %w( | ||
ManageIQ::Providers::Amazon::CloudManager | ||
ManageIQ::Providers::Azure::CloudManager | ||
ManageIQ::Providers::Google::CloudManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no google, but we have ManageIQ::Providers::VMWare::CloudManager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzwei Is there a way to dynamically build this list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmcculloug Yes we can. Working with Madhu now.
app/models/service_template.rb
Outdated
ManageIQ::Providers::Azure::CloudManager | ||
ManageIQ::Providers::Google::CloudManager | ||
ManageIQ::Providers::Openstack::CloudManager | ||
ManageIQ::Providers::Openstack::InfraManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no InfraManager
app/models/service_template.rb
Outdated
@@ -69,6 +69,70 @@ class ServiceTemplate < ApplicationRecord | |||
scope :with_existent_service_template_catalog_id, -> { where.not(:service_template_catalog_id => nil) } | |||
scope :displayed, -> { where(:display => true) } | |||
|
|||
def self.catalog_item_types | |||
CATALOG_ITEM_TYPES.each.with_object({}) do |(key, description), hash| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the UI use it - gray out non-displayable item from the dropdown? Or should we simply remove non-qualified types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzwei @h-kataria mentioned that there is some bootstrap magic that does that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzwei yes UI will show those items as grayed/disabled in the drop down, see screenshot in ManageIQ/manageiq-ui-classic#2908
app/models/service_template.rb
Outdated
ManageIQ::Providers::Openstack::InfraManager | ||
).freeze | ||
|
||
def self.generic_orchestration_provider_present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not solve the case where providers are added but there is no orchestration template. The same question for OpenShift template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzwei so what is the call to check if there is an orchestration template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each orderable
orchestration template, find its eligible_managers
This PR uses changes from backend in ManageIQ/manageiq#16559 to determine whether options in the drop down should be available or disabled based upon results returned in hash by backend method. https://bugzilla.redhat.com/show_bug.cgi?id=1515371
app/models/service_template.rb
Outdated
|
||
def self.generic_orchestration_provider_present? | ||
orchestration_providers = OrchestrationTemplate.distinct.pluck(:type).collect do |otype| | ||
otype.constantize.eligible_managers.collect(&:type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#eligible_managers
has Rbac
(https://github.com/ManageIQ/manageiq/blob/master/app/models/orchestration_template.rb#L127). Should we check the same for other provider_present?
in Ln 104, 108 etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manageiq/app/models/orchestration_template.rb
Line 127 in d66dbcc
Rbac::Filterer.filtered(ExtManagementSystem, :named_scope => [[:with_eligible_manager_types, eligible_manager_types]]) |
Does not accept a User object so its most probably relying on the User.current_user being set in the UI controller based on the currently logged in user so it should do the right thing here. We dont have to pass the user object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- you can pass in
:user
into thefiltered()
call - Rbac slows everything down. It is faster to just have no security.
- The goal is to use rbac in your query along with other sql filtering (e.g.
with_eligible_manager_types
)
Does this work just calling the scope directly?
Rbac::Filterer.filtered(ExtManagementSystem.with_eligible_manager_types(eligible_manager_types))
app/models/service_template.rb
Outdated
end | ||
|
||
def self.openstack_provider_present? | ||
ExtManagementSystem.where(:type => "ManageIQ::Providers::Openstack::InfraManager").any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have both CloudManager
and InfraManager
for OpenStack.
app/models/service_template.rb
Outdated
|
||
def self.azure_provider_present? | ||
ExtManagementSystem.where(:type => "ManageIQ::Providers::Azure::CloudManager").any? | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎 for provider specifics in the manageiq repo...there has to be a way to do this more generically / pluggable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, the fact that this needs to be defined for every provider should send off warning bells.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the hardcoding of providers in here as it's just one more impossible-to-detangle place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make too many queries to the db.
Would be best to bring back catalog items and the corresponding type (from there, the ui should be able to provide a filter)
Having said that, we want to avoid asking the ui to hard code the class names in their checks.
app/models/service_template.rb
Outdated
|
||
def self.generic_orchestration_provider_present? | ||
orchestration_providers = OrchestrationTemplate.distinct.pluck(:type).collect do |otype| | ||
otype.constantize.eligible_managers.collect(&:type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- you can pass in
:user
into thefiltered()
call - Rbac slows everything down. It is faster to just have no security.
- The goal is to use rbac in your query along with other sql filtering (e.g.
with_eligible_manager_types
)
Does this work just calling the scope directly?
Rbac::Filterer.filtered(ExtManagementSystem.with_eligible_manager_types(eligible_manager_types))
app/models/service_template.rb
Outdated
|
||
def self.azure_provider_present? | ||
ExtManagementSystem.where(:type => "ManageIQ::Providers::Azure::CloudManager").any? | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, the fact that this needs to be defined for every provider should send off warning bells.
https://bugzilla.redhat.com/show_bug.cgi?id=1515371 Currently we display all catalog item types irrespective of what providers are installed in the appliance. This PR links the catalog items to different providers and sets the display attribute based on the presence of specific provider(s). This would be used by the UI to list the valid catalog item types
12243fd
to
aca00ba
Compare
app/models/service_template.rb
Outdated
def self.catalog_item_types | ||
ci_types = Rbac.filtered(ExtManagementSystem.all).flat_map(&:supported_catalog_types).uniq | ||
ci_types << 'generic_orchestration' if Rbac.filtered(OrchestrationTemplate).exists? | ||
ci_types << 'generic' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are building this up as an index for lookup purposes (with uniqueness), you would be better off using a Set
object (and not manually calling unique, but letting Set do that for you).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks much better than previously 👍
Checked commits mkanoor/manageiq@aca00ba~...32eef9e with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
All dependent provider PRs merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me @mkanoor 👍
Catalog Item type list is dependent on installed providers (cherry picked from commit 0bedb65) https://bugzilla.redhat.com/show_bug.cgi?id=1520613
Gaprindashvili backport details:
|
https://bugzilla.redhat.com/show_bug.cgi?id=1515371
Currently we display all catalog item types irrespective of what
providers are installed in the appliance. This PR links the catalog
items to different providers and sets the display attribute based
on the presence of specific provider(s). This would be used by the
UI to list the valid catalog item types
Amazon Provider Changes are in PR
ManageIQ/manageiq-providers-amazon#377
VMware Provider changes in PR
ManageIQ/manageiq-providers-vmware#151
Openshift Provider changes in
ManageIQ/manageiq-providers-openshift#74
SCVMM Provider changes in PR
ManageIQ/manageiq-providers-scvmm#54
Openstack Provider PR
ManageIQ/manageiq-providers-openstack#177
Azure Provider PR
ManageIQ/manageiq-providers-azure#185
External Ansible Tower PR
ManageIQ/manageiq-providers-ansible_tower#42
Redhat Provider PR
ManageIQ/manageiq-providers-ovirt#174
Google Provider PR
ManageIQ/manageiq-providers-google#35