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

Initial commit for ansible playbook methods and service model. #13717

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/models/service_ansible_playbook.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class ServiceAnsiblePlaybook < ServiceGeneric
def execute(action)
_log.info("Execute for Service context: #{action}")
end

def check_completed(action)
_log.info("Check_completed for Service context: #{action}")
end

def refresh(action)
_log.info("Refresh for Service context: #{action}")
end

def check_refreshed(action)
_log.info("Check_refreshed for Service context: #{action}")
end
end
30 changes: 17 additions & 13 deletions app/models/service_generic.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
class ServiceGeneric < Service
# A chance for taking options from automate script to override options from a service dialog
def preprovision(_options = {})
def preprocess(_action, _options = {})
end

# Interact with external provider to act on this service item
# The result is called stack, normally a vmdb object. It can map to an object in the provider,
# or even be a virtual object
def provision
raise NotImplementedError, _("provision must be implemented in a subclass")
def execute(_action)
raise NotImplementedError, _("execute must be implemented in a subclass")
end

# Check the provider provision status. It should return [true/false, status_message]
def check_provisioned?
raise NotImplementedError, _("check_provisioned must be implemented in a subclass")
# Check the provider execution status. It should return [true/false, status_message]
# Return [false, nil] if the execution is still in progress.
# Return [true, nil] if the execution is completed without error.
# Return [true, message] if the execution completed with an error.
def check_completed(_action)
raise NotImplementedError, _("check_completed must be implemented in a subclass")
end

# Start a provider refresh
def refresh_provider
raise NotImplementedError, _("refresh_provider must be implemented in a subclass")
# Start a refresh
def refresh(_action)
raise NotImplementedError, _("refresh must be implemented in a subclass")
end

# Check the refresh status. It should return [true/false, status_message]
def check_refreshed
# Return [false, nil] if the refresh is still in progress.
# Return [true, nil] if the refresh is completed without error.
# Return [true, message] if the refresh completed with an error.
def check_refreshed(_action)
raise NotImplementedError, _("check_refreshed must be implemented in a subclass")
end

# Execute after refresh is done. Do cleaning up or update linkage here
def post_provision(_options = {})
def postprocess(_action)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MiqAeMethodService
class MiqAeServiceServiceAnsiblePlaybook < MiqAeServiceServiceGeneric
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
module MiqAeMethodService
class MiqAeServiceServiceGeneric < MiqAeServiceService
expose :preprocess
expose :execute
expose :check_completed
expose :refresh
expose :check_refreshed
expose :postprocess
end
end