Skip to content

Commit d1baa8f

Browse files
authored
Merge pull request #1298 from agrare/fix_snapshot_operations_queue_name
Snapshot Operations should queue_object_action with role=ems_operations
2 parents e019ada + 113acad commit d1baa8f

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

app/controllers/api/subcollections/snapshots.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def snapshots_create_resource(parent, _type, _id, data)
1414
parent,
1515
message,
1616
:method_name => "create_snapshot",
17+
:role => "ems_operations",
1718
:args => [data["name"], data["description"], data.fetch("memory", false)]
1819
)
1920

@@ -28,7 +29,7 @@ def delete_resource_snapshots(parent, type, id, _data)
2829
raise parent.unsupported_reason(:remove_snapshot) unless parent.supports?(:remove_snapshot)
2930

3031
message = "Deleting snapshot #{snapshot.name} for #{snapshot_ident(parent)}"
31-
task_id = queue_object_action(parent, message, :method_name => "remove_snapshot", :args => [id])
32+
task_id = queue_object_action(parent, message, :method_name => "remove_snapshot", :role => "ems_operations", :args => [id])
3233
action_result(true, message, :task_id => task_id)
3334
rescue => e
3435
action_result(false, e.to_s)
@@ -41,7 +42,7 @@ def snapshots_revert_resource(parent, type, id, _data)
4142
snapshot = resource_search(id, type)
4243

4344
message = "Reverting to snapshot #{snapshot.name} for #{snapshot_ident(parent)}"
44-
task_id = queue_object_action(parent, message, :method_name => "revert_to_snapshot", :args => [id])
45+
task_id = queue_object_action(parent, message, :method_name => "revert_to_snapshot", :role => "ems_operations", :args => [id])
4546
action_result(true, message, :task_id => task_id)
4647
rescue => e
4748
action_result(false, e.to_s)

spec/requests/snapshots_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@
8383
}
8484
expect(response.parsed_body).to include(expected)
8585
expect(response).to have_http_status(:ok)
86+
87+
queue_item = MiqQueue.find_by(:class_name => vm.class.name, :method_name => "create_snapshot")
88+
expect(queue_item).to have_attributes(
89+
:zone => ems.zone_name,
90+
:queue_name => ems.queue_name_for_ems_operations
91+
)
8692
end
8793

8894
it "renders a failed action response if snapshotting is not supported" do
@@ -168,8 +174,15 @@
168174
"task_href" => a_string_matching(api_tasks_url),
169175
"task_id" => anything
170176
}
177+
171178
expect(response.parsed_body).to include(expected)
172179
expect(response).to have_http_status(:ok)
180+
181+
queue_item = MiqQueue.find_by(:class_name => vm.class.name, :method_name => "revert_to_snapshot")
182+
expect(queue_item).to have_attributes(
183+
:zone => ems.zone_name,
184+
:queue_name => ems.queue_name_for_ems_operations
185+
)
173186
end
174187

175188
it "renders a failed action response if reverting is not supported" do
@@ -216,6 +229,12 @@
216229
}
217230
expect(response.parsed_body).to include(expected)
218231
expect(response).to have_http_status(:ok)
232+
233+
queue_item = MiqQueue.find_by(:class_name => vm.class.name, :method_name => "remove_snapshot")
234+
expect(queue_item).to have_attributes(
235+
:zone => ems.zone_name,
236+
:queue_name => ems.queue_name_for_ems_operations
237+
)
219238
end
220239

221240
it "renders a failed action response if deleting is not supported" do

0 commit comments

Comments
 (0)