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

Fix saving network manager in belongsto filter #18504

Merged

Conversation

lpichler
Copy link
Contributor

@lpichler lpichler commented Mar 1, 2019

belongsto filters are set in group in Host & Cluster tab:

screenshot 2019-03-01 at 14 08 14

In this filter are listed Providers, Hosts, Storage managers and also Network Providers.

But when you checked any network provider then it was stored to the group but it was not reflected in UI because the method MiqFilter#belongsto2object_list did not work properly with network providers.

This PR fixes method MiqFilter#belongsto2object_list to count also with network providers.

Links

@miq-bot assign @gtanzillo
@miq-bot add_label bug

@miq-bot miq-bot added the bug label Mar 1, 2019
@lpichler lpichler closed this Mar 1, 2019
@lpichler lpichler reopened this Mar 1, 2019
@lpichler lpichler closed this Mar 3, 2019
@lpichler lpichler reopened this Mar 3, 2019
def self.belongsto2object(tag)
belongsto2object_list(tag).last
end

def self.find_object_by_special_class(name)
Copy link
Member

Choose a reason for hiding this comment

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

For both these methods, it would be more generic if you can inspect the name here to determine the class and return an error if it's not one of the supported "special" classes.

@lpichler lpichler force-pushed the load_network_manager_in_belongsto_filter branch 2 times, most recently from 7b9790e to 35ad01c Compare March 7, 2019 09:04
@lpichler
Copy link
Contributor Author

lpichler commented Mar 7, 2019

@gtanzillo I did couple changes as you pointed out. In addition I found the real reason for this fix.
This is change is needed when network manager will have different the name the parent manager (his provider) and thanks to that we need to find network manager according to name of parent manager (his provider) because this name is stored in belongs to filter in format: <name of parent manager> NetworkManager.

def self.belongsto2object(tag)
belongsto2object_list(tag).last
end

def self.find_descendant_class_by(klass, name)
if ALLOWED_DESCENDANT_CLASSES_FROM_MODEL.include?(klass.to_s) && name.end_with?(ManageIQ::Providers::NetworkManager::PROVIDER_NAME)
Copy link
Member

Choose a reason for hiding this comment

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

@libor Perhaps this logic can be moved into the NetworkManager class and this code can be something like

if ALLOWED_DESCENDANT_CLASSES_FROM_MODEL.include?(klass.to_s) && klass.respond_to?(:belongsto_descendant_class)
 return  klass.belongsto_descendant_class(name)
else
 ...

The in NetworkManager

def belongsto_descendant_class(name)
  ManageIQ::Providers::NetworkManager if name.end_with?(ManageIQ::Providers::NetworkManager::PROVIDER_NAME)
end

This way the provider specific code doesn't have to live in Filterer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍, I followed pattern but I need to put to the ExtManagementSystem because klass is ExtManagementSystem , thanks!

@lpichler lpichler force-pushed the load_network_manager_in_belongsto_filter branch from 35ad01c to 709ff9e Compare March 19, 2019 14:29
@miq-bot
Copy link
Member

miq-bot commented Mar 19, 2019

Checked commits lpichler/manageiq@f069348~...709ff9e with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
4 files checked, 0 offenses detected
Everything looks fine. 🏆

@gtanzillo gtanzillo added this to the Sprint 108 Ending Apr 1, 2019 milestone Mar 19, 2019
@gtanzillo gtanzillo merged commit 35d745b into ManageIQ:master Mar 19, 2019
@lpichler lpichler deleted the load_network_manager_in_belongsto_filter branch March 19, 2019 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants