Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Improve wsdl to vmodl type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jun 15, 2021
1 parent 3b227f1 commit 0aaed65
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions devel/verify-vim-wsdl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ def dump_vmodl(vmodl, path)
File.write(path, Marshal.dump(vmodl))
end

def wsdl_to_vmodl_type(wsdl_type)
vmodl_type = 'ManagedObject' if wsdl_type == 'ManagedObjectReference'
vmodl_type ||= "xsd:#{wsdl_type}" if %w[boolean byte dateTime int long string].include?(wsdl_type)
vmodl_type ||= wsdl_type if "RbVmomi::BasicTypes::#{wsdl_type}".safe_constantize || "RbVmomi::VIM::#{wsdl_type}".safe_constantize
raise if vmodl_type.nil?
def wsdl_to_vmodl_type(type)
case type.source
when /vim25:/
vmodl_type = type.name
vmodl_type = 'ManagedObject' if vmodl_type == 'ManagedObjectReference'
when /xsd:/
vmodl_type = type.source
else
raise ArgumentError, "Unrecognized wsdl type: [#{type}]"
end

vmodl_type
end
Expand Down Expand Up @@ -103,7 +108,7 @@ def wsdl_constantize(type)
'is-optional' => element.minoccurs == 0,
'is-array' => element.maxoccurs != 1,
'version-id-ref' => nil,
'wsdl_type' => wsdl_to_vmodl_type(element.type.name)
'wsdl_type' => wsdl_to_vmodl_type(element.type)
}
end,
'wsdl_base' => type.complexcontent.extension.base.name
Expand Down

0 comments on commit 0aaed65

Please sign in to comment.