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

Fixes Azure Instance container display of file name and mode descriptions #3373

Merged
merged 1 commit into from
Feb 8, 2018
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
25 changes: 15 additions & 10 deletions app/helpers/textual_mixins/textual_devices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ def disks_attributes

# HDDs
disks = @record.hardware.hard_disks.map do |disk|
ctrl_type = disk.controller_type.upcase
location = disk.location
size = disk.size
prov = disk.size_on_disk.nil? ? 'N/A' : disk.used_percent_of_provisioned
device_name = _("Hard Disk (%{controller_type} %{location}), Size %{size}, " \
"Percent Used Provisioned Space %{space}") % {:controller_type => ctrl_type,
:location => location,
:size => size,
:space => prov}
description = _("%{filename}, Mode: %{mode}") % {:filename => disk.filename, :mode => disk.mode}
device_name = _("Hard Disk")

hd_name = disk.device_name.upcase
location = disk.location.presence || _("N/A")
size = disk.size.presence || _("N/A")
pct_prov = disk.size_on_disk.nil? ? _("N/A") : disk.used_percent_of_provisioned
filename = disk.filename.presence || _("N/A")
mode = disk.mode.presence || _("N/A")
description = _("Name: %{hd_name}, Location: %{location}, Size: %{size}, Percent Used Provisioned Space: %{prov}, " \
"Filename: %{filename}, Mode: %{mode}") % {:hd_name => hd_name,
:location => location,
:size => size,
:prov => pct_prov,
:filename => filename,
:mode => mode}
Device.new(device_name, description, nil, :disk)
end

Expand Down
30 changes: 29 additions & 1 deletion spec/helpers/textual_mixins/textual_devices_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
FactoryGirl.create(:hardware,
:disks => [FactoryGirl.create(:disk,
:device_type => "disk",
:device_name => "HD01",
:controller_type => "scsi")])
end
it { is_expected.not_to be_empty }
Expand All @@ -41,10 +42,37 @@
FactoryGirl.create(:hardware,
:disks => [FactoryGirl.create(:disk,
:device_type => "disk",
:device_name => "HD01",
:size => "1072693248",
:controller_type => "AZURE")])
end
it { expect(subject[0][:name]).to include("Hard Disk (AZURE ), Size 1072693248, Percent Used Provisioned Space N/A") }
it { expect(subject[0][:name]).to include("Hard Disk") }
it { expect(subject[0][:description]).to include("Name: HD01, Location: N/A, Size: 1072693248, Percent Used Provisioned Space: N/A, Filename: N/A, Mode: N/A") }
end

context "with hdd with size_on_disk and percent provisioned collected (AZURE)" do
let(:hw) do
FactoryGirl.create(:hardware,
:disks => [FactoryGirl.create(:disk,
:device_type => "disk",
:device_name => "CLIA566D60F38FB9ECC",
:location => "https://jdg.blob.core.windows.net/vhds/clia566d60f38fb9ecc.vhd",
:size => "1072693248",
:size_on_disk => "357564416",
:controller_type => "AZURE")])
end
it { expect(subject[0][:name]).to include("Hard Disk") }

it "expect hard disk description with percent provisioned " do
expected_description = "Name: CLIA566D60F38FB9ECC, " \
"Location: https://jdg.blob.core.windows.net/vhds/clia566d60f38fb9ecc.vhd, " \
"Size: 1072693248, " \
"Percent Used Provisioned Space: 33.3, " \
"Filename: N/A, " \
"Mode: N/A"

expect(subject[0][:description]).to include(expected_description)
end
end
end

Expand Down