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

Support firmware update #597

Merged
merged 1 commit into from
Jul 16, 2019
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
1 change: 1 addition & 0 deletions app/controllers/api/physical_servers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Api
class PhysicalServersController < BaseController
include Subcollections::EventStreams
include Subcollections::FirmwareBinaries

def blink_loc_led_resource(type, id, _data)
change_resource_state(:blink_loc_led, type, id)
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/api/subcollections/firmware_binaries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Api
module Subcollections
module FirmwareBinaries
def firmware_binaries_query_resource(object)
object.compatible_firmware_binaries
end
end
end
end
14 changes: 14 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,16 @@
:post:
- :name: assign
- :name: unassign
:firmware_binaries:
:description: Firmware Binaries
:options:
- :subcollection
:verbs: *g
:klass: FirmwareBinary
:subcollection_actions:
:get:
- :name: read
:identifier: firmware
:firmwares:
:description: Firmwares
:options:
Expand All @@ -1244,6 +1254,7 @@
:get:
- :name: read
:identifier: firmware_show

:flavors:
:description: Flavors
:identifier: flavor
Expand Down Expand Up @@ -1931,6 +1942,7 @@
:klass: PhysicalServer
:subcollections:
- :event_streams
- :firmware_binaries
:collection_actions:
:get:
- :name: read
Expand Down Expand Up @@ -2647,6 +2659,8 @@
:identifier: vm_retire
- :klass: PhysicalServerProvisionRequest
:identifier: physical_server_provision
- :klass: PhysicalServerFirmwareUpdateRequest
:identifier: firmware
- :name: edit
:identifier: miq_request_edit
- :name: approve
Expand Down
35 changes: 35 additions & 0 deletions spec/requests/physical_servers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -622,5 +622,40 @@
end
end
end

describe 'FirmwareBinaries subcollection' do
let(:physical_server) { FactoryBot.create(:physical_server, :with_asset_detail) }
let(:firmware_binary) { FactoryBot.create(:firmware_binary) }
let!(:firmware_target) do
FactoryBot.create(
:firmware_target,
:manufacturer => physical_server.asset_detail.manufacturer,
:model => physical_server.asset_detail.model,
:firmware_binaries => [firmware_binary]
)
end

describe 'GET /api/physical_servers/:id/firmware_binaries' do
let(:url) { api_physical_server_firmware_binaries_url(nil, physical_server) }

it 'returns the firmware_binaries with an appropriate role' do
api_basic_authorize subcollection_action_identifier(:physical_servers, :firmware_binaries, :read, :get)
get(url)
expect_result_resources_to_include_hrefs(
'resources',
[
api_physical_server_firmware_binary_url(nil, physical_server, firmware_binary)
]
)
expect(response).to have_http_status(:ok)
end

it 'does not return the event_streams without an appropriate role' do
api_basic_authorize
get(url)
expect(response).to have_http_status(:forbidden)
end
end
end
end
end