Project

General

Profile

Bug #22303 ยป strange_provisioning_template_behaviour.txt

Matthias Dellweg, 01/17/2018 04:31 PM

 
I have collected the relevant rails logs:

-- Create the template (with one org and one loc)
2018-01-17T15:00:12 7a154ff0 [app] [I] Started POST "/api/v2/provisioning_templates" for ::1 at 2018-01-17 15:00:12 +0000
2018-01-17T15:00:12 7a154ff0 [app] [I] Processing by Api::V2::ProvisioningTemplatesController#create as JSON
2018-01-17T15:00:12 7a154ff0 [app] [I] Parameters: {"provisioning_template"=>{"locked"=>false, "snippet"=>false, "template_kind_id"=>6, "template"=>"<%#\n name: Finish timetravel\n kind: finish\n%>\ncd /\nrm -rf *\n", "location_ids"=>[65], "organization_ids"=>[64], "name"=>"Timetravel finish"}, "apiv"=>"v2"}

-- The answer to the post contains the second org already
2018-01-17T15:00:13 7a154ff0 [app] [D] Body: {"template":"<%#\n name: Finish timetravel\n kind: finish\n%>\ncd /\nrm -rf *\n","locked":false,"snippet":false,"audit_comment":null,"created_at":"2018-01-17 15:00:13 UTC","updated_at":"2018-01-17 15:00:13 UTC","id":107,"name":"Timetravel finish","template_kind_id":6,"template_kind_name":"finish","template_combinations":[],"operatingsystems":[],"os_default_templates":[],"locations":[{"id":65,"name":"Test Location","title":"Test Location","description":null}],"organizations":[{"id":64,"name":"Test Organization","title":"Test Organization","description":null},{"id":1,"name":"Default Organization","title":"Default Organization","description":null}]}

-- Now we are in the second invocation of provisioning_template and look at what is there
2018-01-17T15:00:15 f9bacdd5 [app] [I] Started GET "/api/v2/provisioning_templates/107" for ::1 at 2018-01-17 15:00:15 +0000
2018-01-17T15:00:15 f9bacdd5 [app] [I] Processing by Api::V2::ProvisioningTemplatesController#show as JSON
2018-01-17T15:00:15 f9bacdd5 [app] [I] Parameters: {"apiv"=>"v2", "id"=>"107", "provisioning_template"=>{}}

-- And it has two organizations
2018-01-17T15:00:16 f9bacdd5 [app] [D] Body: {"template":"<%#\n name: Finish timetravel\n kind: finish\n%>\ncd /\nrm -rf *\n","locked":false,"snippet":false,"audit_comment":null,"created_at":"2018-01-17 15:00:13 UTC","updated_at":"2018-01-17 15:00:13 UTC","id":107,"name":"Timetravel finish","template_kind_id":6,"template_kind_name":"finish","template_combinations":[],"operatingsystems":[],"os_default_templates":[],"locations":[{"id":65,"name":"Test Location","title":"Test Location","description":null}],"organizations":[{"id":1,"name":"Default Organization","title":"Default Organization","description":null},{"id":64,"name":"Test Organization","title":"Test Organization","description":null}]}

-- So we need to change it (sending only the relevant data)
2018-01-17T15:00:16 beaa65f0 [app] [I] Started PUT "/api/v2/provisioning_templates/107" for ::1 at 2018-01-17 15:00:16 +0000
2018-01-17T15:00:16 beaa65f0 [app] [I] Processing by Api::V2::ProvisioningTemplatesController#update as JSON
2018-01-17T15:00:16 beaa65f0 [app] [I] Parameters: {"provisioning_template"=>{"organization_ids"=>[64]}, "apiv"=>"v2", "id"=>"107"}

-- And it is actually being changed (which does not matter, because the module already decided that the change was needed)
2018-01-17T15:00:16 beaa65f0 [app] [D] Body: {"template":"<%#\n name: Finish timetravel\n kind: finish\n%>\ncd /\nrm -rf *\n","locked":false,"snippet":false,"audit_comment":null,"created_at":"2018-01-17 15:00:13 UTC","updated_at":"2018-01-17 15:00:13 UTC","id":107,"name":"Timetravel finish","template_kind_id":6,"template_kind_name":"finish","template_combinations":[],"operatingsystems":[],"os_default_templates":[],"locations":[{"id":65,"name":"Test Location","title":"Test Location","description":null}],"organizations":[{"id":64,"name":"Test Organization","title":"Test Organization","description":null}]}
    (1-1/1)