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

Create a provision request for a service template #13972

Merged
merged 9 commits into from
Feb 23, 2017

Conversation

mkanoor
Copy link
Contributor

@mkanoor mkanoor commented Feb 17, 2017

Model method to submit a provision request from a service template.

https://www.pivotaltracker.com/n/projects/1937537/stories/140055813

This method is also accessible from Automate method e.g

st = $evm.root["service_template"]
req=$evm.create_service_provision_request(st, {})

workflow = ResourceActionWorkflow.new({}, User.find_by!(:userid => userid),
provision_action, :target => self)
options.each { |key, value| workflow.set_value(key, value) }
workflow.submit_request
Copy link
Member

Choose a reason for hiding this comment

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

@mkanoor If we want to allow the API to call this it should be broken up into two methods. One to be called from the API that returns the workflow to match what the current code does: lib/services/api/service_template_workflow.rb#L7

And another which can be called when we need to create and submit the workflow. This would support the two use cases from the API as well as what we need for control actions and automate.

Current API callers:

workflow = ServiceTemplateWorkflow.create(service_template, data || {})

ServiceTemplateWorkflow.create(service_template, service_request)

@gmcculloug
Copy link
Member

LGTM @abellotti Please review the recent changes.

def provision_workflow(userid, options = {})
ResourceActionWorkflow.new({}, User.find_by!(:userid => userid),
provision_action, :target => self).tap do |wf|
options.each { |key, value| wf.set_value(key, value) }
Copy link
Member

Choose a reason for hiding this comment

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

this might fail if method is called as provision_workflow(userid, nil)
maybe default options to nil, then have a separate options ||= {}

@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 21, 2017

@abellotti @gmcculloug
Please review.
I have changed to pass in user object instead of userid.
and default value for options is nil

@abellotti
Copy link
Member

LGTM!! @mkanoor thanks for the update.

@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 21, 2017

Fails with the
app/models/miq_request_workflow.rb:738:in set_request_values': undefined method current_group' for nil:NilClass (NoMethodError)

@miq-bot
Copy link
Member

miq-bot commented Feb 22, 2017

Checked commits mkanoor/manageiq@b4cf882~...06fdddd with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 0 offenses detected
Everything looks good. 🍪

@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 22, 2017

@gmcculloug
Please review, the travis failure is unrelated to my changes

@gmcculloug
Copy link
Member

👍 Once we tests green.

@gmcculloug gmcculloug merged commit 196a2e5 into ManageIQ:master Feb 23, 2017
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.

4 participants