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

Adding many models for EmbeddedAnsible provider #13879

Merged
merged 2 commits into from
Feb 23, 2017

Conversation

blomquisg
Copy link
Member

@blomquisg blomquisg commented Feb 13, 2017

WOW! So many changes here.

This is the first attempt to create a way to differentiate the AnsibleTower models from the EmbeddedAnsible models.

The point behind this differentiation is to allow querying done via the MIQ API and UI to filter based on the Embedded vs. External nature of each.

Specifically, one should be able to ask for ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScript.all
and not get any configuration script from any AnsibleTower providers, because AnsibleTower providers should be strictly ExternalAutomationManagers.

How was this accomplished?

  1. Any model-level logic in AnsibleTower models has been extracted and moved to a new ManageIQ::Providers::AnsibleTower::Shared namespace
  2. All models in AnsibleTower and EmbeddedAnsible now pull all logic from models in ManageIQ::Providers::AnsibleTower::Shared models.
    a. Note that only a few models are actually in Shared. This is because only a few actually had any implementation.
  3. EmbeddedAutomationManager and ExternalAutomationManager have been built out more. Maybe not completely. This PR might have missed some gaps.
  4. AutomationManager has more models for completeness. We can decide whether this is really necessary, but it felt better to do it this way.
Authentication / Credential modeling for Ansible Tower and Embedded Ansible
miqansiblecredentials
ConfigurationScript modeling for Ansible Tower and Embedded Ansible

find_by(:manager_id => manager.id, :manager_ref => job_template.id)
end

def create_in_provider_queue(manager_id, params)
manager = ExtManagementSystem.find(manager_id)

manager = ExtManagementSystem.find(manager_id)
Copy link
Member

Choose a reason for hiding this comment

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

Duplicated lines.

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to do it twice because of the non-deterministic nature of computers. LOL

@@ -0,0 +1,90 @@
require 'ansible_tower_client'
module ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::Job
include Status
Copy link
Member

Choose a reason for hiding this comment

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

Might want to use include_concern here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I could not figure that out last night! Thanks, I'll give this a try.

:ext_management_system => template.manager,
:job_template => template)
stack.send(:update_with_provider_object, raw_create_stack(template, options))
stack
Copy link
Member

Choose a reason for hiding this comment

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

I'm sure this copy paste, but a preferred pattern than

x = blah
x.foo = bar
return x

is

blah.tap do |x|
  x.foo = bar
end

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, 100% copy/paste. I can update this as part of the PR, though.

@@ -0,0 +1,3 @@
# This corresponds to Ansible Tower's Azure Resource Manager (azure_rm) type credential. We are not modeling the deprecated Azzure classic
Copy link
Member

Choose a reason for hiding this comment

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

Typo Azzure -> Azure

Copy link
Member Author

Choose a reason for hiding this comment

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

Haha, also copy/paste. I'll add it to the list.

Copy link
Contributor

Choose a reason for hiding this comment

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

hehe, my fault

Copy link
Member

Choose a reason for hiding this comment

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

I azzure you, it's ok 😄

Copy link
Member

Choose a reason for hiding this comment

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

@Fryguy 😑

@Fryguy
Copy link
Member

Fryguy commented Feb 13, 2017

@blomquisg LGTM, with a few minor comments

There are also a few minor rubocop issues, but if they were there previously, then no need to do them in this PR.

@blomquisg blomquisg force-pushed the embedded_automation_manager branch 2 times, most recently from 38520bf to c90a59f Compare February 13, 2017 23:28
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.

@blomquisg looks like specs failed because you missed a few automate service models. See this for an example

@blomquisg
Copy link
Member Author

looks like specs failed because you missed a few automate service models.

Thanks @bdunne .... on it

@blomquisg
Copy link
Member Author

blomquisg commented Feb 15, 2017

OMG it's 🍏 💚 📗 🐸 🐍 🐢 🍀 🌵 🎾 ✳️ ❇️ ✅

Though, any chance we can get #13776 reviewed and merged first? Then, I'll rebase mine on top of that and incorporate the new models introduced there.

@miq-bot
Copy link
Member

miq-bot commented Feb 15, 2017

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

@bdunne
Copy link
Member

bdunne commented Feb 16, 2017

@blomquisg #13776 is merged. I think we can merge after rebase.

@blomquisg
Copy link
Member Author

blomquisg commented Feb 16, 2017

tag_collection_spec failures?

...

Those tests pass locally for me, so it must be something very recently added since my last rebase.

@jameswnl
Copy link
Contributor

It's broken in master

@blomquisg blomquisg closed this Feb 21, 2017
@blomquisg blomquisg reopened this Feb 21, 2017
@miq-bot
Copy link
Member

miq-bot commented Feb 21, 2017

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

@blomquisg
Copy link
Member Author

it's the classic
master is broken ↩️
close/open PR to restart tests ↩️
PR is unmergeable b/c master changed ↩️
rebase ↩️
hope master isn't broken again 🔁

@miq-bot
Copy link
Member

miq-bot commented Feb 22, 2017

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

WOW!  So many changes here.

This is the first attempt to create a way to differentiate the
AnsibleTower models from the EmbeddedAnsible models.

The point behind this differentiation is to allow querying done via the
MIQ API and UI to filter based on the Embedded vs. External nature of
each.

Specifically, one should be able to ask for
`ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScript.all`
and not get any configuration script from any `AnsibleTower` providers,
because `AnsibleTower` providers should be strictly
`ExternalAutomationManagers`.

This definitely feels like a lot of convoluted hierarchical organization
that's going to hurt in the future.

TODO:  OMG, draw a picture of this!
@miq-bot
Copy link
Member

miq-bot commented Feb 22, 2017

Checked commits blomquisg/manageiq@be9b4d0~...f72a278 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
90 files checked, 11 offenses detected

app/models/manageiq/providers/ansible_tower/shared/automation_manager/configuration_script.rb

app/models/manageiq/providers/ansible_tower/shared/automation_manager/job.rb

spec/models/manageiq/providers/ansible_tower/automation_manager/configuration_script_spec.rb

@blomquisg blomquisg closed this Feb 23, 2017
@blomquisg blomquisg reopened this Feb 23, 2017
@blomquisg blomquisg closed this Feb 23, 2017
@blomquisg blomquisg reopened this Feb 23, 2017
@@ -8,22 +11,19 @@ def create_in_provider(manager_id, params)

# Get the record in our database
# TODO: This needs to be targeted refresh so it doesn't take too long
EmsRefresh.queue_refresh(manager, nil, true) if manager.authentication_status_ok?

EmsRefresh.queue_refresh(manager, nil, true) if !manager.missing_credentials? && manager.authentication_status_ok?
Copy link
Member

Choose a reason for hiding this comment

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

@blomquisg This changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It did ... or, it did when I first copied all this stuff around


def provider_object(connection = nil)
(connection || connection_source.connect).api.job_templates.find(manager_ref)
end
Copy link
Member

Choose a reason for hiding this comment

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

Also why was this added?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Fryguy Fryguy merged commit 13acb63 into ManageIQ:master Feb 23, 2017
@Fryguy Fryguy added this to the Sprint 55 Ending Feb 27, 2017 milestone Feb 23, 2017
@blomquisg
Copy link
Member Author

blomquisg commented Feb 24, 2017

Adding a comment regarding filtering by models. This has come up a few times, and I wanna make sure it's captured somewhere.

Preface

There are two different AutomationManagers: AnsibleTower::AutomationManager and EmbeddedAnsible::AutomationManager. MIQ wants to show different details of the model objects under those different AutomationManagers.

However, propagating specific provider names back into the UI breaks future-looking pluggability of trying to keep specific provider names out of the UI.

So, an intermediate layer has been added to allow model-level filtering between "Embedded" and "External" types of AutomationManagers. Specifically, there are:

  • ManageIQ::Providers::EmbeddedAutomationManager
    • For all EmbeddedAnsible things (and any future embedded automation manager things)
  • ManageIQ::Providers::ExternalAutomationManager
    • For all AnsibleTower things (and any future external automation manager things)

Filtering

To see all of the ConfigurationScriptSource objects for EmbeddedAnsible:

ManageIQ::Providers::EmbeddedAutomationManager.ConfigurationScriptSource.all

To see all of the ConfigurationScript (Job Template) objects for AnsibleTower:

ManageIQ::Providers::ExternalAutomationManager.ConfigurationScript.all

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