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

ansible refresh parser as graph refresh #13585

Merged
merged 1 commit into from
Jan 30, 2017

Conversation

durandom
Copy link
Member

@durandom durandom commented Jan 19, 2017

Converted current ansible refresh to new graph refresh

cc @Ladas @juliancheal @blomquisg
@miq-bot add_label providers/ansible, wip

@@ -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"
Copy link
Member Author

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

Copy link
Contributor

@Ladas Ladas Jan 19, 2017

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
Copy link
Member Author

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

Copy link
Contributor

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.
Copy link
Member Author

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 InventoryCollections would be linked under one e.g. InventoryObject

Copy link
Contributor

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,
Copy link
Member Author

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

Copy link
Contributor

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
Copy link
Member Author

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

Copy link
Contributor

@Ladas Ladas Jan 19, 2017

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 :-)

@miq-bot
Copy link
Member

miq-bot commented Jan 19, 2017

@durandom Cannot apply the following label because they are not recognized: providers/ansible

@miq-bot miq-bot added the wip label Jan 19, 2017
@durandom durandom force-pushed the ansible_inventory_refresh branch from c786ee3 to 8352bae Compare January 19, 2017 16:45
@durandom
Copy link
Member Author

@miq-bot assign @blomquisg
@miq-bot add_label providers/ansible_tower

@durandom durandom force-pushed the ansible_inventory_refresh branch from 8352bae to fae7952 Compare January 20, 2017 13:12
@durandom durandom changed the title [WIP] ansible refresh parser as graph refresh ansible refresh parser as graph refresh Jan 20, 2017
@durandom
Copy link
Member Author

@miq-bot remove_label wip

@durandom
Copy link
Member Author

@blomquisg please review

@@ -0,0 +1,80 @@
class ManageIQ::Providers::AnsibleTower::ConfigurationManager::RefreshWorker::Parser
attr_accessor :inventory, :ems
Copy link
Contributor

@Ladas Ladas Jan 23, 2017

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],
Copy link
Contributor

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.

@blomquisg
Copy link
Member

Waiting for #13630 ... then this PR will have to reflect the move to AutomationManager.

@blomquisg
Copy link
Member

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
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@bdunne
Copy link
Member

bdunne commented Jan 25, 2017

Overall, 👍 LGTM

@miq-bot
Copy link
Member

miq-bot commented Jan 26, 2017

This pull request is not mergeable. Please rebase and repush.

@durandom durandom force-pushed the ansible_inventory_refresh branch from e54297b to 81f6327 Compare January 27, 2017 21:56
@durandom
Copy link
Member Author

Had to squash all commits into one for easier rebasing on top of master.
But this is just the last version with @bdunne remarks addressed.
So, should be good to go

@durandom durandom force-pushed the ansible_inventory_refresh branch from 81f6327 to 3f21c56 Compare January 27, 2017 22:36
@miq-bot
Copy link
Member

miq-bot commented Jan 27, 2017

Checked commit durandom@3f21c56 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
6 files checked, 0 offenses detected
Everything looks good. 🍰

Copy link
Member

@bdunne bdunne left a 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
Copy link
Member

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.

Copy link
Member

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

@blomquisg blomquisg merged commit 8aceeb1 into ManageIQ:master Jan 30, 2017
@blomquisg blomquisg added this to the Sprint 53 Ending Jan 30, 2017 milestone Jan 30, 2017
@durandom durandom deleted the ansible_inventory_refresh branch March 17, 2017 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants