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

Pass multiple objects to automate by object class #18088

Closed
wants to merge 1 commit into from

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Oct 11, 2018

I think we should be passing the array of multiple objects from a custom button run on many vms or hosts or whatevers as the class name rather than running class on an id and getting an Integer which will fail on https://github.com/ManageIQ/manageiq-automation_engine/blob/1975fe20dbcd622c4e8b0363e793d2a477c4c430/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb#L562.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1628224

@d-m-u
Copy link
Contributor Author

d-m-u commented Oct 11, 2018

@tinaafitz @bdunne can ya'll review please?
@miq-bot add_label bug, hammer/yes

@@ -20,8 +20,7 @@ def automate_queue_hash(target, override_attrs, user, open_url_task_id = nil)
elsif target.kind_of?(Hash)
override_values = target
elsif target.kind_of?(Array) || target.kind_of?(ActiveRecord::Relation)
klass = target.first.id.class
object_ids = target.collect { |t| "#{klass}::#{t.id}" }.join(",")
object_ids = target.collect { |t| "#{t.class.to_s.demodulize}::#{t.id}" }.join(",")
Copy link
Member

Choose a reason for hiding this comment

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

Prefer t.class.name.demodulize

@miq-bot
Copy link
Member

miq-bot commented Oct 12, 2018

Checked commit d-m-u@999e01b with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍰

@d-m-u
Copy link
Contributor Author

d-m-u commented Oct 18, 2018

@tinaafitz can you please review?

@d-m-u
Copy link
Contributor Author

d-m-u commented Oct 18, 2018

@miq-bot assign @gmcculloug

@@ -20,8 +20,7 @@ def automate_queue_hash(target, override_attrs, user, open_url_task_id = nil)
elsif target.kind_of?(Hash)
override_values = target
elsif target.kind_of?(Array) || target.kind_of?(ActiveRecord::Relation)
klass = target.first.id.class
object_ids = target.collect { |t| "#{klass}::#{t.id}" }.join(",")
object_ids = target.collect { |t| "#{t.class.name.demodulize}::#{t.id}" }.join(",")
Copy link
Member

Choose a reason for hiding this comment

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

@@ -62,8 +62,7 @@
it "validates queue entry" do
targets = [FactoryGirl.create(:vm_vmware), FactoryGirl.create(:vm_vmware)]
ae_attributes[:target_object_type] = targets.first.class.base_class.name
klass = targets.first.id.class
ae_attributes['Array::target_object_ids'] = targets.collect { |t| "#{klass}::#{t.id}" }.join(",")
ae_attributes['Array::target_object_ids'] = targets.collect { |t| "#{t.class.name.demodulize}::#{t.id}" }.join(",")
Copy link
Contributor

Choose a reason for hiding this comment

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

@d-m-u
Is there a way to test and see if its broken by doing a multi select and invoke a custom button on the, does Automate complain about invalid objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a bug open about this very thing so I think that kinda proves it's currently broken.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would mean that this feature has not been QE'ed if its that broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since QE is the one who opened this bug, that sounds about right.

@d-m-u d-m-u closed this Oct 24, 2018
@d-m-u
Copy link
Contributor Author

d-m-u commented Oct 24, 2018

This isn't the bug I was looking for :)

@d-m-u d-m-u deleted the change_id_class_to_object_class branch February 1, 2019 20:48
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.

5 participants