Skip to content

Commit

Permalink
Fixes Azure Instance display file name and mode descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
GregP committed Feb 7, 2018
1 parent a9a6036 commit 4d41f8d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
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
35 changes: 34 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,42 @@
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
pct_prov = hw.disks[0].used_percent_of_provisioned

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

0 comments on commit 4d41f8d

Please sign in to comment.