-
Notifications
You must be signed in to change notification settings - Fork 900
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
ansible refresh parser as graph refresh #13585
Conversation
@@ -16,6 +16,9 @@ class ManageIQ::Providers::AnsibleTower::ConfigurationManager < ManageIQ::Provid | |||
:with_provider_connection, | |||
:to => :provider | |||
|
|||
# FIXME: shouldnt be needed. Its here because otherwise the STI type column is the base class in refresh | |||
has_many :configured_systems, :dependent => :destroy, :foreign_key => "manager_id" |
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.
@Ladas can I somehow force the class on the collection right now? Or maybe we can tweak get_entity_builder
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've deleted the 'get_entity_builder', does that help? :-)
So should be enough to have the right class in the InventoryCollection constructor, or send a :type, if you store multiple under one IC
And yeah, has_many takes :class_name I think
def initialize(ems, target, _options = nil) | ||
@ems = ems | ||
@connection = ems.connect | ||
@target = target |
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.
so, yeah, target is not used yet. Not sure how targeted refresh would work. Maybe I drop it here
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, I am getting into a point that targeted refresh goes through managers
so e.g. a proper targeted refresh of a VM needs info from CloudManager, NetworkManager and StorageManager now
end | ||
|
||
def inventory_groups | ||
# FIXME: memoization should not be needed. |
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.
@Ladas this could be done, if all those individual InventoryCollection
s would be linked under one e.g. InventoryObject
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.
well, I've started to store them in Inventory under AWS, but probably that is not ideal
@inventory_groups ||= ManagerRefresh::InventoryCollection.new( | ||
ManageIQ::Providers::ConfigurationManager::InventoryRootGroup, | ||
:association => :inventory_root_groups, | ||
:parent => ems, |
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.
@Ladas see above, if this collection would be s child of an InventoryObject this parent could be infered from 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.
yeah, I do fill this automatically in my Inventory helpers in AWS now
@@ -6,6 +6,7 @@ class ManageIQ::Providers::ConfigurationManager < ::ExtManagementSystem | |||
has_many :configuration_profiles, :dependent => :destroy, :foreign_key => "manager_id" | |||
has_many :configuration_scripts, :dependent => :destroy, :foreign_key => "manager_id" | |||
has_many :inventory_groups, :dependent => :destroy, :foreign_key => "ems_id", :inverse_of => :manager | |||
has_many :inventory_root_groups, :dependent => :destroy, :foreign_key => "ems_id", :inverse_of => :manager |
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.
@Ladas same here, ideally it would work without the need of adding that assoc
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.
well, this is an easy way to define the SQL join, you can do that using :arel in the InventoryCollection :-)
@durandom Cannot apply the following label because they are not recognized: providers/ansible |
c786ee3
to
8352bae
Compare
@miq-bot assign @blomquisg |
8352bae
to
fae7952
Compare
@miq-bot remove_label wip |
@blomquisg please review |
@@ -0,0 +1,80 @@ | |||
class ManageIQ::Providers::AnsibleTower::ConfigurationManager::RefreshWorker::Parser | |||
attr_accessor :inventory, :ems |
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.
can be just attr_reader?
:association => :configured_systems, | ||
# FIXME: array should not be needed | ||
# FIXME: manager_ref should not be needed here | ||
:manager_ref => [:manager_ref], |
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 think you need to define this. In ideal world, there would be a DB unique index here, then we can take manager_ref from that.
Waiting for #13630 ... then this PR will have to reflect the move to |
This looks fairly straightforward, btw. As soon as the (re)modeling is done, we can move on this pretty quickly I think. |
[target, inventory] | ||
end | ||
|
||
targets_with_data |
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 variable isn't necessary
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.
removed
Overall, 👍 LGTM |
This pull request is not mergeable. Please rebase and repush. |
e54297b
to
81f6327
Compare
Had to squash all commits into one for easier rebasing on top of master. |
81f6327
to
3f21c56
Compare
Checked commit durandom@3f21c56 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
👍 LGTM
def parse_targeted_inventory(ems, target, inventory) | ||
log_header = format_ems_for_logging(ems) | ||
_log.debug "#{log_header} Parsing inventory..." | ||
hashes, = Benchmark.realtime_block(:parse_inventory) do |
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.
Usually I would expect to see a placeholder for the unused assignment.
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.
Hrm, we seem to waffle on this a bit on our codebase:
>$ git grep ", _ =" | wc -l
4
>$ git grep ", =" | wc -l
29
Converted current ansible refresh to new graph refresh
cc @Ladas @juliancheal @blomquisg
@miq-bot add_label providers/ansible, wip