Skip to content

Commit

Permalink
Merge pull request #170 from agrare/bz_1529725_refresh_storages_throu…
Browse files Browse the repository at this point in the history
…gh_ems

Refresh datastore files through EMS
(cherry picked from commit 95d1303)

https://bugzilla.redhat.com/show_bug.cgi?id=1534753
  • Loading branch information
Fryguy authored and simaishi committed Jan 15, 2018
1 parent 5203b54 commit 0f1be92
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
28 changes: 28 additions & 0 deletions app/models/manageiq/providers/vmware/infra_manager.rb
Expand Up @@ -514,5 +514,33 @@ def find_vm_create_events(vms_list)
# Return list of VMs that we found create events for
found
end

def get_files_on_datastore(datastore)
with_provider_connection do |vim|
begin
vim_ds = vim.getVimDataStore(datastore.name)
return vim_ds.dsFolderFileList
rescue Handsoap::Fault, StandardError, Timeout::Error, DRb::DRbConnError => err
_log.log_backtrace(err)
raise MiqException::MiqStorageError, "Error communicating with Host: [#{name}]"
ensure
begin
vim_ds.release if vim_ds
rescue
# TODO: specify what to rescue
# TODO: log it
nil
end
end
end

nil
end

def refresh_files_on_datastore(datastore)
hashes = self.class::RefreshParser.datastore_file_inv_to_hashes(
get_files_on_datastore(datastore), datastore.vm_ids_by_path)
EmsRefresh.save_storage_files_inventory(datastore, hashes)
end
end
end
27 changes: 2 additions & 25 deletions app/models/manageiq/providers/vmware/infra_manager/host.rb
Expand Up @@ -24,32 +24,9 @@ def provider_object_release(handle)
handle.release if handle rescue nil
end

def get_files_on_datastore(datastore)
with_provider_connection do |vim|
begin
vim_ds = vim.getVimDataStore(datastore.name)
return vim_ds.dsFolderFileList
rescue Handsoap::Fault, StandardError, Timeout::Error, DRb::DRbConnError => err
_log.log_backtrace(err)
raise MiqException::MiqStorageError, "Error communicating with Host: [#{name}]"
ensure
begin
vim_ds.release if vim_ds
rescue
# TODO: specify what to rescue
# TODO: log it
nil
end
end
end

nil
end

def refresh_files_on_datastore(datastore)
hashes = ManageIQ::Providers::Vmware::InfraManager::RefreshParser.datastore_file_inv_to_hashes(
get_files_on_datastore(datastore), datastore.vm_ids_by_path)
EmsRefresh.save_storage_files_inventory(datastore, hashes)
raise _("Host must be connected to an EMS to refresh datastore files") if ext_management_system.nil?
ext_management_system.refresh_files_on_datastore(datastore)
end

def reserve_next_available_vnc_port
Expand Down

0 comments on commit 0f1be92

Please sign in to comment.