-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EmbeddedAnsible ServiceTemplate (ConfigurationScript) CRUD
- Loading branch information
1 parent
f0132c1
commit db2c372
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScript | ||
FRIENDLY_NAME = "Ansible Automation Inside Job Template".freeze | ||
|
||
include ManageIQ::Providers::EmbeddedAnsible::CrudCommon | ||
|
||
def self.params_to_attributes(manager, params) | ||
playbook = manager.configuration_script_payloads.find_by(:name => params[:playbook]) | ||
raise "Playbook name=#{params[:playbook].inspect} no longer exists" if playbook.nil? | ||
|
||
params = params.except(:playbook) | ||
variables = params.slice!(:name, :description).to_h.stringify_keys | ||
params.merge!( | ||
:manager_id => manager.id, | ||
:parent_id => playbook.id, | ||
:variables => variables | ||
) | ||
end | ||
|
||
def self.raw_create_in_provider(manager, params) | ||
create!(params_to_attributes(manager, params)) | ||
end | ||
|
||
def raw_update_in_provider(params) | ||
update_attributes!(self.class.params_to_attributes(manager, params.except(:task_id, :miq_task_id))) | ||
end | ||
|
||
def raw_delete_in_provider | ||
destroy! | ||
end | ||
end |