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

Update Service Template via API #22882

Open
agrare opened this issue Feb 6, 2024 Discussed in #22877 · 5 comments
Open

Update Service Template via API #22882

agrare opened this issue Feb 6, 2024 Discussed in #22877 · 5 comments
Assignees

Comments

@agrare
Copy link
Member

agrare commented Feb 6, 2024

Discussed in https://github.com/orgs/ManageIQ/discussions/22877

Originally posted by bfilion87 February 5, 2024
Hello,

I am trying to update a service template item that we use as part of a service catalog bundle and am wanting to do it via the API. In the docs it shows the following example:

image

But specifically what I am trying to update is the src_vm_id under config_info. I've tried doing a post and a put to the /api/service_template/:id endpoint with the following body:

{
"action" : "edit",
"resource" : {
"config_info" : {
"src_vm_id" : [4981, "dc-RedHat-8"]
}
}
}

But I get a 400 code back with the body:

image

I guess my ultimate question is is it possible to update the config_info of a service_template via the API?

@agrare agrare added the bug label Feb 6, 2024
@agrare
Copy link
Member Author

agrare commented Feb 6, 2024

I was able to reproduce this

  1. Create a VMware ServiceTemplate
  2. Try to edit the config_info via the API: POST /api/service_templates/1 {"action": "edit", "config_info": {"src_vm_id": 3}}
[489, 498] in /home/grare/adam/src/manageiq/manageiq/app/models/service_template.rb
   489:   def update_service_resources(config_info, auth_user = nil)
   490:     config_info = config_info.except(:provision, :retirement, :reconfigure)
   491:     workflow_class = MiqProvisionWorkflow.class_for_source(config_info[:src_vm_id])
   492:     if workflow_class
   493:       service_resources.find_by(:resource_type => 'MiqRequest').try(:destroy)
=> 494:       new_request = workflow_class.new(config_info, auth_user).make_request(nil, config_info)
   495: 
   496:       add_resource!(new_request)
   497:     end
   498:   end
(byebug) 

Backtrace:

(byebug) error
#<MiqAeException::Error: Unable to launch Automate Method because currently in SQL transaction>
(byebug) pp error.backtrace
["/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb:190:in `ruby_method_runnable?'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb:198:in `invoke_inline_ruby'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb:10:in `invoke_inline'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb:92:in `invoke'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:544:in `invoke_method'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:368:in `block in process_method_raw'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/more_core_extensions-4.4.0/lib/more_core_extensions/core_ext/benchmark/realtime_store.rb:20:in `realtime_store'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/more_core_extensions-4.4.0/lib/more_core_extensions/core_ext/benchmark/realtime_store.rb:62:in `realtime_block'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:361:in `process_method_raw'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:374:in `process_method'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:313:in `block in process_filtered_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:307:in `each'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:307:in `process_filtered_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:303:in `process_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:210:in `instantiate'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:650:in `process_relationship_raw'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:354:in `process_relationship'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:313:in `block in process_filtered_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:307:in `each'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:307:in `process_filtered_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:303:in `process_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:210:in `instantiate'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:650:in `process_relationship_raw'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:354:in `process_relationship'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:313:in `block in process_filtered_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:307:in `each'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:307:in `process_filtered_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:303:in `process_fields'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:210:in `instantiate'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:54:in `instantiate_with_user'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:48:in `block in instantiate'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/user.rb:381:in `with_user'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:48:in `instantiate'",
 "/home/grare/adam/src/manageiq/manageiq-automation_engine/lib/miq_automation_engine/engine/miq_ae_engine.rb:328:in `resolve_automation_object'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/miq_request_workflow.rb:698:in `dialog_name_from_automate'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/miq_provision_virt_workflow.rb:49:in `dialog_name_from_automate'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/manageiq/providers/infra_manager/provision_workflow.rb:63:in `dialog_name_from_automate'",
 "/home/grare/adam/src/manageiq/manageiq-providers-vmware/app/models/manageiq/providers/vmware/infra_manager/provision_workflow.rb:21:in `dialog_name_from_automate'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/miq_request_workflow.rb:651:in `get_dialogs'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/miq_provision_virt_workflow.rb:27:in `initialize'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/service_template.rb:494:in `new'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/service_template.rb:494:in `update_service_resources'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/service_template.rb:154:in `block in update_catalog_item'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:209:in `transaction'",
 "/home/grare/adam/.gem/ruby/3.1.0/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:290:in `transaction'",
 "/home/grare/adam/src/manageiq/manageiq/app/models/service_template.rb:150:in `update_catalog_item'",
 "/home/grare/adam/src/manageiq/manageiq-api/app/controllers/api/service_templates_controller.rb:26:in `edit_resource'",
 "/home/grare/adam/src/manageiq/manageiq-api/app/controllers/api/base_controller/manager.rb:101:in `update_one_collection'",
 "/home/grare/adam/src/manageiq/manageiq-api/app/controllers/api/base_controller/manager.rb:23:in `update_collection'",
 "/home/grare/adam/src/manageiq/manageiq-api/app/controllers/api/base_controller.rb:95:in `update'",

@agrare
Copy link
Member Author

agrare commented Feb 6, 2024

cc @Fryguy

@kbrock
Copy link
Member

kbrock commented Feb 23, 2024

@agrare The culprit: dialog_name_from_automate https://github.com/ManageIQ/manageiq/blob/master/app/models/miq_request_workflow.rb#L651

Also of interest:

But specifically what I am trying to update is the src_vm_id under config_info. I've tried doing a post and a put to the /api/service_template/:id endpoint with the following body:

@Fryguy Is this related to our previous discussion around removing edit from some request models in the api?

@Fryguy
Copy link
Member

Fryguy commented Mar 8, 2024

@Fryguy Is this related to our previous discussion around removing edit from some request models in the api?

I don't believe so

@miq-bot miq-bot added the stale label Jun 10, 2024
@miq-bot
Copy link
Member

miq-bot commented Jun 10, 2024

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants