Skip to content

Commit

Permalink
Merge pull request #444 from jameswnl/contents
Browse files Browse the repository at this point in the history
VMware content library refresh
  • Loading branch information
agrare committed Sep 6, 2019
2 parents 045818d + 835b747 commit 006fbaa
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/manageiq/providers/vmware/infra_manager.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ManageIQ::Providers
class Vmware::InfraManager < InfraManager
require_nested :DistributedVirtualSwitch
require_nested :OrchestrationTemplate
require_nested :EventCatcher
require_nested :EventParser
require_nested :RefreshWorker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def full_refresh(vim, property_filter)

parse_updates(vim, parser, updated_objects)
parse_storage_profiles(vim, parser)
if vim.rev >= '6.0' && vim.serviceContent.about.apiType == 'VirtualCenter'
parse_content_libraries(parser)
end
save_inventory(persister)

self.last_full_refresh = Time.now.utc
Expand Down Expand Up @@ -239,6 +242,31 @@ def uncached_prop_set(obj)
@uncached_prop_set[obj.class.wsdl_name]
end

def parse_content_libraries(parser)
require 'vsphere-automation-content'
require 'vsphere-automation-cis'

configuration = VSphereAutomation::Configuration.new.tap do |c|
c.host = ems.hostname
c.username = ems.auth_user_pwd.first
c.password = ems.auth_user_pwd.last
c.scheme = 'https'
c.verify_ssl = false
c.verify_ssl_host = false
end

api_client = VSphereAutomation::ApiClient.new(configuration)
VSphereAutomation::CIS::SessionApi.new(api_client).create('')
api_libs = VSphereAutomation::Content::LibraryApi.new(api_client)
api_items = VSphereAutomation::Content::LibraryItemApi.new(api_client)

api_libs.list.value.each do |lib_id|
api_items.list(lib_id).value.each do |item_id|
parser.parse_content_library_item(api_items.get(item_id).value)
end
end
end

def parse_storage_profiles(vim, parser)
pbm = pbm_connect(vim)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@ def parse_virtual_machine(object, kind, props)
parse_virtual_machine_snapshots(vm, props)
end

def parse_content_library_item(library_item)
props = {
:ems_ref => library_item.id,
:name => library_item.name,
:description => library_item.description,
:content => library_item.type # TODO: currently 'ovf|iso|file'
}
persister.orchestration_templates.build(props)
end

def lazy_find_managed_object(managed_object)
return if managed_object.nil?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def initialize_inventory_collections
add_collection(infra, :vm_parent_blue_folders)
add_collection(infra, :vm_resource_pools)
add_collection(infra, :root_folder_relationship)
add_collection(infra, :orchestration_templates, &:add_common_default_values)
end

def vim_class_to_collection(managed_object)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ManageIQ::Providers::Vmware::InfraManager::OrchestrationTemplate < OrchestrationTemplate
def unique_md5?
false
end
end
1 change: 1 addition & 0 deletions manageiq-providers-vmware.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Gem::Specification.new do |s|
s.add_dependency("fog-vcloud-director", ["~> 0.3.0"])
s.add_dependency "vmware_web_service", "~>0.4.3"
s.add_dependency "rbvmomi", "~>2.0.0"
s.add_dependency "vsphere-automation-sdk", "~>0.2.1"

s.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
s.add_development_dependency "simplecov"
Expand Down

0 comments on commit 006fbaa

Please sign in to comment.