Skip to content

Commit

Permalink
Parse if a datastore is accessible from a host
Browse files Browse the repository at this point in the history
Parse if a datastore is able to be accessed from a host into the
host_storage record.

https://bugzilla.redhat.com/show_bug.cgi?id=1668020
  • Loading branch information
agrare committed Jan 24, 2019
1 parent f664742 commit b36aa0b
Show file tree
Hide file tree
Showing 4 changed files with 299 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ def parse_datastore_capability(storage_hash, props)
def parse_datastore_host_mount(storage, datastore_ref, props)
props[:host].to_a.each do |host_mount|
persister.host_storages.build(
:storage => storage,
:host => persister.hosts.lazy_find(host_mount.key._ref),
:ems_ref => datastore_ref,
:read_only => host_mount.mountInfo.accessMode == "readOnly",
:storage => storage,
:host => persister.hosts.lazy_find(host_mount.key._ref),
:ems_ref => datastore_ref,
:read_only => host_mount.mountInfo.accessMode == "readOnly",
:accessible => host_mount.mountInfo.accessible,
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,12 +770,15 @@ def self.host_inv_to_host_storages_hashes(inv, storage_inv, storage_uids)
host_mount = Array.wrap(s_inv["host"]).detect { |host| host["key"] == inv["MOR"] }
next if host_mount.nil?

read_only = host_mount.fetch_path("mountInfo", "accessMode") == "readOnly"
mount_info = host_mount["mountInfo"] || {}
read_only = mount_info["accessMode"] == "readOnly"
accessible = mount_info["accessible"].present? ? mount_info["accessible"].to_s.downcase == "true" : true

result << {
:storage => storage_uids[s_mor],
:read_only => read_only,
:ems_ref => s_mor
:storage => storage_uids[s_mor],
:read_only => read_only,
:accessible => accessible,
:ems_ref => s_mor
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,13 @@ def assert_specific_host
:location => "4dce5b88-623e8e7e-0dc0-00188b404015"
)

expect(@host.host_storages.where(:accessible => false).count).to eq(1)
inaccessible_host_storage = @host.host_storages.where(:accessible => false).first
expect(inaccessible_host_storage.storage).to have_attributes(
:ems_ref => "datastore-12281",
:name => "StarM1-Backup1",
)

expect(@host.operating_system).to have_attributes(
:name => "VI4ESXM1.manageiq.com",
:product_name => "ESXi",
Expand Down
Loading

0 comments on commit b36aa0b

Please sign in to comment.