Skip to content

Commit

Permalink
Support firmware update
Browse files Browse the repository at this point in the history
With this commit we expose neccessary operations for UI to be
able to render a functional "Firmware Update" modal. User has
to pick a firmware binary from the drop-down to apply it to
selected server(s). Eventually, when she submits the modal, a
new Request of type PhysicalServerFirmwareUpdateRequest is created
by means of POSTing to `/api/request`.

Signed-off-by: Miha Pleško <[email protected]>
  • Loading branch information
miha-plesko committed Jul 9, 2019
1 parent 48157cd commit 1d5f4a1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/api/physical_servers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def apply_config_pattern_resource(type, id, data)
action_result(false, err.to_s)
end

def firmware_binaries_query_resource(object)
object.compatible_firmware_binaries
end

private

def change_resource_state(state, type, id, data = [])
Expand Down
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

0 comments on commit 1d5f4a1

Please sign in to comment.