Skip to content

Commit

Permalink
Remove dependency of EmbeddedAnsible on AnsibleTower::Shared
Browse files Browse the repository at this point in the history
NickL Note:  Commenting out specs here that will fail, and
re-implementing them as the logic is added in future commits.  Most pull
in specs from the ansible_tower provider repo, so they are no longer
valid anyway, but can't be tested at this stage since the new model code
doesn't exist yet.

Also, removed the shared specs for credential.rb for the moment.
This will be revisited in the future, but for now doesn't have enough
merit to be included with the current implementation.

Worth noting, however, is the mthods `notify_on_provider_interaction?`
and `.native_ref` have been added to the credential model, since that is
currently the functionality of the AnsibleTower provider (and
EmbeddedAnsible by virtue of the shared code between the two), so I
mirrored that here.  This also fixes some test cases that were relying
on the type casting of `native_ref` to work properly.

The credential logic will be re-implemented and used in the future.
  • Loading branch information
Fryguy authored and NickLaMuro committed Jun 11, 2019
1 parent e574cf6 commit 63be848
Show file tree
Hide file tree
Showing 45 changed files with 22 additions and 218 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def manageiq_plugin(plugin_name)
end
end

manageiq_plugin "manageiq-providers-ansible_tower" # can't move this down yet, because we can't autoload ManageIQ::Providers::AnsibleTower::Shared
manageiq_plugin "manageiq-schema"

# Unmodified gems
Expand Down Expand Up @@ -95,6 +94,10 @@ group :amazon, :manageiq_default do
gem "amazon_ssa_support", :require => false, :git => "https://github.com/ManageIQ/amazon_ssa_support.git", :branch => "master" # Temporary dependency to be moved to manageiq-providers-amazon when officially release
end

group :ansible_tower, :manageiq_default do
manageiq_plugin "manageiq-providers-ansible_tower"
end

group :azure, :manageiq_default do
manageiq_plugin "manageiq-providers-azure"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager < ManageIQ::Providers::EmbeddedAutomationManager
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager

require_nested :Credential
require_nested :AmazonCredential
require_nested :AzureCredential
require_nested :CloudCredential
require_nested :GoogleCredential
require_nested :MachineCredential
require_nested :VaultCredential
require_nested :NetworkCredential
require_nested :OpenstackCredential
require_nested :RhvCredential
require_nested :ScmCredential
require_nested :VaultCredential
require_nested :VmwareCredential
require_nested :RhvCredential

require_nested :ConfigurationScript
require_nested :ConfigurationScriptSource
require_nested :ConfigurationWorkflow
require_nested :ConfiguredSystem
require_nested :EventCatcher
require_nested :EventParser
require_nested :Inventory
require_nested :Job
require_nested :Playbook
require_nested :Refresher
require_nested :RefreshWorker

def self.ems_type
@ems_type ||= "embedded_ansible_automation".freeze
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::AmazonCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::AmazonCredential

def self.display_name(number = 1)
n_('Credential (Amazon)', 'Credentials (Amazon)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This corresponds to Ansible Tower's Azure Resource Manager (azure_rm) type credential
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::AzureCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::AzureCredential

def self.display_name(number = 1)
n_('Credential (Microsoft Azure)', 'Credentials (Microsoft Azure)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential <
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Credential
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Credential
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript <
ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScript

include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::ConfigurationScript
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::TowerApi

class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScript
FRIENDLY_NAME = "Ansible Automation Inside Job Template".freeze
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptSource

include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::ConfigurationScriptSource
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::TowerApi

FRIENDLY_NAME = "Ansible Automation Inside Project".freeze

def self.display_name(number = 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationWorkflow < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScript
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::ConfigurationWorkflow
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfiguredSystem <
ManageIQ::Providers::EmbeddedAutomationManager::ConfiguredSystem

include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::ConfiguredSystem
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfiguredSystem < ManageIQ::Providers::EmbeddedAutomationManager::ConfiguredSystem
include ProviderObjectMixin
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Credential < Mana
alias_attribute :manager_id, :resource_id
alias_attribute :manager, :resource

include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::Credential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::TowerApi

FRIENDLY_NAME = "Ansible Automation Inside Credential".freeze

def self.provider_params(params)
super.merge(:organization => ManageIQ::Providers::EmbeddedAnsible::AutomationManager.first.provider.default_organization)
end

def self.notify_on_provider_interaction?
true
end

def native_ref
Integer(manager_ref)
end
end

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::GoogleCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::GoogleCredential

def self.display_name(number = 1)
n_('Credential (Google)', 'Credentials (Google)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job < ManageIQ::Providers::EmbeddedAutomationManager::OrchestrationStack
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::Job
include CiFeatureMixin

require_nested :Status
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job::Status < ::OrchestrationStack::Status
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::Job::Status
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::MachineCredential <
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Credential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::MachineCredential

class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::MachineCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Credential
def self.display_name(number = 1)
n_('Credential (Machine)', 'Credentials (Machine)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::NetworkCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Credential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::NetworkCredential

def self.display_name(number = 1)
n_('Credential (Network)', 'Credentials (Network)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::OpenstackCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::OpenstackCredential

def self.display_name(number = 1)
n_('Credential (OpenStack)', 'Credentials (OpenStack)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook <
ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptPayload

class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScriptPayload
has_many :jobs, :class_name => 'OrchestrationStack', :foreign_key => :configuration_script_base_id

def run(options, userid = nil)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::RhvCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::RhvCredential

def self.display_name(number = 1)
n_('Credential (RHV)', 'Credentials (RHV)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ScmCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Credential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::ScmCredential

def self.display_name(number = 1)
n_('Credential (SCM)', 'Credentials (SCM)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::VaultCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Credential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::VaultCredential

def self.display_name(number = 1)
n_('Credential (Vault)', 'Credentials (Vault)', number)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::VmwareCredential < ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::VmwareCredential

def self.display_name(number = 1)
n_('Credential (VMware)', 'Credentials (VMware)', number)
end
Expand Down
18 changes: 0 additions & 18 deletions app/models/manageiq/providers/embedded_ansible/inventory.rb

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions app/models/manageiq/providers/embedded_ansible/provider.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
class ManageIQ::Providers::EmbeddedAnsible::Provider < ::Provider
include ManageIQ::Providers::AnsibleTower::Shared::Provider

include_concern 'DefaultAnsibleObjects'

has_one :automation_manager,
:foreign_key => "provider_id",
:class_name => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager",
:dependent => :destroy, # to be removed after ansible_tower side code is updated
:autosave => true

def self.raw_connect(base_url, username, password, verify_ssl)
return super if MiqRegion.my_region.role_active?('embedded_ansible')
raise StandardError, 'Embedded ansible is disabled'
end
end
4 changes: 0 additions & 4 deletions lib/workers/miq_worker_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"ManageIQ::Providers::Azure::CloudManager::EventCatcher" => %i(manageiq_default),
"ManageIQ::Providers::Azure::CloudManager::MetricsCollectorWorker" => %i(manageiq_default),
"ManageIQ::Providers::Azure::CloudManager::RefreshWorker" => %i(manageiq_default),
"ManageIQ::Providers::EmbeddedAnsible::AutomationManager::EventCatcher" => %i(manageiq_default),
"ManageIQ::Providers::EmbeddedAnsible::AutomationManager::RefreshWorker" => %i(manageiq_default),
"ManageIQ::Providers::Foreman::ConfigurationManager::RefreshWorker" => %i(manageiq_default),
"ManageIQ::Providers::Foreman::ProvisioningManager::RefreshWorker" => %i(manageiq_default),
"ManageIQ::Providers::Google::CloudManager::EventCatcher" => %i(manageiq_default),
Expand Down Expand Up @@ -101,7 +99,6 @@
ManageIQ::Providers::Google::CloudManager::RefreshWorker
ManageIQ::Providers::Google::NetworkManager::RefreshWorker
ManageIQ::Providers::AnsibleTower::AutomationManager::RefreshWorker
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::RefreshWorker
ManageIQ::Providers::Foreman::ConfigurationManager::RefreshWorker
ManageIQ::Providers::Foreman::ProvisioningManager::RefreshWorker
ManageIQ::Providers::Kubernetes::ContainerManager::InventoryCollectorWorker
Expand Down Expand Up @@ -140,7 +137,6 @@
ManageIQ::Providers::Amazon::CloudManager::EventCatcher
ManageIQ::Providers::Azure::CloudManager::EventCatcher
ManageIQ::Providers::AnsibleTower::AutomationManager::EventCatcher
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::EventCatcher
ManageIQ::Providers::Google::CloudManager::EventCatcher
ManageIQ::Providers::Kubernetes::ContainerManager::EventCatcher
ManageIQ::Providers::Kubernetes::MonitoringManager::EventCatcher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
describe ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ScmCredential do
let(:manager) do
FactoryBot.create(:provider_embedded_ansible, :with_authentication, :default_organization => 1).managers.first
FactoryBot.create(:provider_embedded_ansible, :default_organization => 1).managers.first
end

before do
EvmSpecHelper.assign_embedded_ansible_role
end

it_behaves_like 'ansible credential'
# it_behaves_like 'ansible credential'
end

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
describe ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job::Status do
it_behaves_like 'ansible job status'
# it_behaves_like 'ansible job status'
end
Loading

0 comments on commit 63be848

Please sign in to comment.