vmware-archive / rbvmomi

Ruby interface to the VMware vSphere API.
MIT License
302 stars 175 forks source link

Add a script to verify vmodl.db from a wsdl file #177

Closed agrare closed 4 years ago

agrare commented 4 years ago

This script parses the main vimService.wsdl and iterates through all of the ComplexTypes and checks that the params in the vmodl.db match the types from the WSDL.

It uses soap4r-ng which appears to be the only ruby soap wsdl parser that handles xsd:import/include directives which the VIM wsdls use extensively. This saved me a lot of manual parsing and recursive xml walking.

Example:

HostProxySwitch.pnic xsd:string doesn't match PhysicalNic
HostMultipathInfoLogicalUnit.lun xsd:string doesn't match ScsiLun
HostMultipathInfoPath.adapter xsd:string doesn't match HostHostBusAdapter
HostMultipathInfoPath.lun xsd:string doesn't match HostMultipathInfoLogicalUnit
HostOpaqueSwitch.pnic xsd:string doesn't match PhysicalNic
HostPlugStoreTopologyAdapter.adapter xsd:string doesn't match HostHostBusAdapter
HostPlugStoreTopologyAdapter.path xsd:string doesn't match HostPlugStoreTopologyPath
HostPlugStoreTopologyPath.adapter xsd:string doesn't match HostPlugStoreTopologyAdapter
HostPlugStoreTopologyPath.target xsd:string doesn't match HostPlugStoreTopologyTarget
HostPlugStoreTopologyPath.device xsd:string doesn't match HostPlugStoreTopologyDevice
HostPlugStoreTopologyDevice.lun xsd:string doesn't match ScsiLun
HostPlugStoreTopologyDevice.path xsd:string doesn't match HostPlugStoreTopologyPath
HostPlugStoreTopologyPlugin.device xsd:string doesn't match HostPlugStoreTopologyDevice
HostPlugStoreTopologyPlugin.claimedPath xsd:string doesn't match HostPlugStoreTopologyPath
HostPortGroup.vswitch xsd:string doesn't match HostVirtualSwitch
HostVMotionNetConfig.selectedVnic xsd:string doesn't match HostVirtualNic
HostVirtualNic.port xsd:string doesn't match HostPortGroupPort
VirtualNicManagerNetConfig.selectedVnic xsd:string doesn't match HostVirtualNic
jrgarcia commented 4 years ago

@agrare Is this using the stdlib wsdl/parser? If so, that was removed after 1.8.7 and I'm actually planning on dropping support for any non-stable Ruby versions in the very near future. If not, which library is it using?

agrare commented 4 years ago

Hey @jrgarcia this is using soap4r-ng (https://github.com/rubyjedi/soap4r), this was the only wsdl parser that I found that would follow the xsd:import and xsd:include directives and works on rubies at least as new as 2.5.7 which is what I have locally

agrare commented 4 years ago

With https://github.com/vmware/rbvmomi/pull/176 merged running this script results in 0 incorrect wsdl_types for the vsphere-ws and spbm service WSDLs

Fryguy commented 4 years ago

I could see this being added to CI as well, so that if someone makes a PR with updates to the wsdl file it will immediately fail the PR.

agrare commented 4 years ago

Yeah that would be nice, my goal is to actually turn this into a rake task that will actually generate the whole vmodl file repeatably.

Fryguy commented 4 years ago

@jrgarcia I think now that we are on newer rubies, this one is ready to go.

jrgarcia commented 4 years ago

I'll revisit this at some point this week. Thanks for the nudge!

jrgarcia commented 4 years ago

Hey @agrare! I'd love to accept this now that we've dropped those nasty, old Ruby versions. Can you do me a favor and add activesupport and soap4r-ng to the development (since they are only in this dev script) dependencies in the Gemspec? After that, I think this looks great and will be extremely helpful.

agrare commented 4 years ago

@jrgarcia Its a deal ;)