forked from ManageIQ/manageiq-providers-lenovo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
269 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/models/manageiq/providers/lenovo/physical_infra_manager/parser/physical_disk_parser.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module ManageIQ::Providers::Lenovo | ||
class PhysicalInfraManager::Parser::PhysicalDiskParser < PhysicalInfraManager::Parser::ComponentParser | ||
class << self | ||
# Mapping between fields inside a [XClarityClient::Storage] to a [Hash] with symbols of PhysicalDisk fields | ||
PHYSICAL_DISK = { | ||
:model => 'model', | ||
:vendor => 'vendorName', | ||
:status => 'status', | ||
:location => 'location', | ||
:serial_number => 'serialNumber', | ||
:health_state => 'health', | ||
:controller_type => 'type', | ||
:disk_size => :disk_size | ||
}.freeze | ||
|
||
# | ||
# Parse disk into a hash | ||
# | ||
# @param [Hash] disk_hash - hash containing physical disk raw data | ||
# @param [Hash] canister - parsed canister data | ||
# | ||
# @return [Hash] containing the physical disk information | ||
# | ||
def parse_physical_disk(disk, canister: nil) | ||
result = parse(disk, PHYSICAL_DISK) | ||
result[:canister] = canister if canister | ||
|
||
result | ||
end | ||
|
||
def disk_size(disk) | ||
disk['size'] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
spec/models/manageiq/providers/lenovo/physical_infra_manager/physical_infra_spec_common.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module PhysicalInfraSpecCommon | ||
extend ActiveSupport::Concern | ||
|
||
MODELS = %i( | ||
ext_management_system physical_rack physical_chassis physical_server | ||
physical_switch physical_storage physical_disk customization_script | ||
).freeze | ||
|
||
def serialize_inventory | ||
skip_atributes = %w(created_at updated_at last_refresh_date updated_on) | ||
inventory = {} | ||
PhysicalInfraSpecCommon::MODELS.each do |rel| | ||
inventory[rel] = rel.to_s.classify.constantize.all.collect do |e| | ||
e.attributes.except(*skip_atributes) | ||
end | ||
end | ||
|
||
inventory | ||
end | ||
|
||
def assert_models_not_changed(inventory_before, inventory_after) | ||
aggregate_failures do | ||
PhysicalInfraSpecCommon::MODELS.each do |model| | ||
expect(inventory_after[model].count).to eq(inventory_before[model].count), "#{model} count"\ | ||
" doesn't fit \nexpected: #{inventory_before[model].count}\ngot#{inventory_after[model].count}" | ||
|
||
inventory_after[model].each do |item_after| | ||
item_before = inventory_before[model].detect { |i| i["id"] == item_after["id"] } | ||
expect(item_after).to eq(item_before), \ | ||
"class: #{model.to_s.classify}\nexpected: #{item_before}\ngot: #{item_after}" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.