-
Notifications
You must be signed in to change notification settings - Fork 4
MiqProvisionTask based workspace provision #18
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a7c377e
Update ServiceTemplateTerraformEnterprise
agrare 977a1a6
TFE Non-generic catalog prov_type
agrare c882168
Updates for allowed_configuration_scripts
agrare 2c1aacd
Change how configuration script values are formatted
GilbertCherrie 031c807
Add manager_name for catalog UI
agrare fba98fe
Update to use src_configuration_script_id
agrare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,70 +1,31 @@ | ||
| class ServiceTemplateTerraformEnterprise < ServiceTemplate | ||
| include ServiceConfigurationMixin | ||
| include ServiceTemplateAutomationMixin | ||
|
|
||
| alias terraform_workspace configuration_script | ||
| alias terraform_workspace= configuration_script= | ||
|
|
||
| def self.default_provisioning_entry_point(_service_type) | ||
| '/AutomationManagement/TerraformEnterprise/Service/Provisioning/StateMachines/Provision/CatalogItemInitialization' | ||
| end | ||
|
|
||
| def self.default_reconfiguration_entry_point | ||
| nil | ||
| end | ||
|
|
||
| def self.default_retirement_entry_point | ||
| nil | ||
| end | ||
|
|
||
| def self.create_catalog_item(options, _auth_user = nil) | ||
| def self.create_catalog_item(options, auth_user = nil) | ||
| transaction do | ||
| create_from_options(options).tap do |service_template| | ||
| config_info = validate_config_info(options) | ||
|
|
||
| service_template.terraform_workspace = if config_info[:configuration_script_id] | ||
| ConfigurationScript.find(config_info[:configuration_script_id]) | ||
| else | ||
| config_info[:configuration] | ||
| end | ||
|
|
||
| service_template.create_resource_actions(config_info) | ||
| config_info = options[:config_info].except(:provision, :retirement, :reconfigure) | ||
| validate_config_info!(config_info) | ||
|
|
||
| wf_class = ManageIQ::Providers::TerraformEnterprise::AutomationManager::ProvisionWorkflow | ||
| wf = wf_class.new(config_info, auth_user) | ||
| request = wf.make_request(nil, config_info) | ||
| service_template.add_resource(request) | ||
| service_template.create_resource_actions(options[:config_info]) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def create_subtasks(_parent_service_task, _parent_service) | ||
| # no sub task is needed for this service | ||
| [] | ||
| end | ||
|
|
||
| def my_zone | ||
| configuration_script.manager.try(:my_zone) | ||
| end | ||
|
|
||
| def self.validate_config_info(options) | ||
| config_info = options[:config_info] || {} | ||
| config_info[:provision][:fqname] ||= default_provisioning_entry_point(SERVICE_TYPE_ATOMIC) if config_info.key?(:provision) | ||
|
|
||
| raise _("Must provide a configuration_script_id") if config_info[:configuration_script_id].nil? | ||
|
|
||
| config_info | ||
| def self.validate_config_info!(config_info) | ||
| raise _("Must provide a src_configuration_script_id") if config_info[:src_configuration_script_id].nil? | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def update_service_resources(config_info, _auth_user = nil) | ||
| return if !config_info.key?(:configuration_script_id) || config_info[:configuration_script_id] == configuration_script&.id | ||
|
|
||
| service_resources.find_by(:resource_type => 'ConfigurationScriptBase').destroy | ||
| self.configuration_script = ConfigurationScriptBase.find(config_info[:configuration_script_id]) | ||
| end | ||
|
|
||
| def validate_update_config_info(options) | ||
| super | ||
| config_info = super | ||
|
|
||
| return unless options.key?(:config_info) | ||
|
|
||
| self.class.validate_config_info(options) | ||
| self.class.validate_config_info!(config_info) | ||
| config_info | ||
| end | ||
| end | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does removing this now prevent the UI from doing automate based provisioning? Or maybe not prevent, but the user would have to know to put this into the field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not. Previously there was no way for the user to select anything except the above value. Now the user has the same options as vm provisioning to select automate or workflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.