diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ac4922db..ee3197e1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,7 @@ ### All Submissions: * [ ] Have you followed the guidelines in our Contributing document? -* [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/vmware/rbvmomi/pulls) for the same update/change? +* [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/ManageIQ/rbvmomi2/pulls) for the same update/change? diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1604e242..0496106e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,7 @@ do so. * Open a [pull request][4] that relates to *only* one subject with a clear title and description in grammatically correct, complete sentences. -[1]: https://github.com/vmware/rbvmomi/issues +[1]: https://github.com/ManageIQ/rbvmomi2/issues [2]: https://guides.github.com/activities/forking/ [3]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html [4]: https://help.github.com/articles/about-pull-requests diff --git a/README.md b/README.md index 87d9c7eb..04231e9d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ -# VMware has ended active development of this project, this repository will no longer be updated. # RbVmomi -[gem-version](https://rubygems.org/gems/rbvmomi) -![Test](https://github.com/vmware/rbvmomi/workflows/Test/badge.svg) -![Lint](https://github.com/vmware/rbvmomi/workflows/Lint/badge.svg) +[gem-version](https://rubygems.org/gems/rbvmomi2) +![Test](https://github.com/ManageIQ/rbvmomi2/workflows/Test/badge.svg) +![Lint](https://github.com/ManageIQ/rbvmomi2/workflows/Lint/badge.svg) [](https://gitter.im/vmware/rbvmomi) -This is a community-supported, open source project at VMware. It is built and +This is a community-supported, open source project at ManageIQ. It is built and maintained by programmers like you! ## Introduction @@ -14,12 +13,12 @@ maintained by programmers like you! RbVmomi is a Ruby interface to the vSphere API. Like the Perl and Java SDKs, you can use it to manage ESX and vCenter servers. The current release supports the vSphere 7.0 API. RbVmomi specific documentation is -[online](http://rdoc.info/github/vmware/rbvmomi/master/frames) and is meant to +[online](http://rdoc.info/github/ManageIQ/rbvmomi2/master/frames) and is meant to be used alongside the official [documentation](http://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.wssdk.apiref.doc/right-pane.html). ## Installation - gem install rbvmomi + gem install rbvmomi2 ## Usage @@ -88,14 +87,14 @@ A few important points: Built-in extensions are under `lib/rbvmomi/vim/`. You are encouraged to reopen VIM classes in your applications and add extensions of your own. If you write -something generally useful please open a [pull request](https://github.com/vmware/rbvmomi/pulls) so it can be merged back in +something generally useful please open a [pull request](https://github.com/ManageIQ/rbvmomi2/pulls) so it can be merged back in ## Development -Open an issue on the [issues page](https://github.com/vmware/rbvmomi/issues) -or fork the project on [GitHub](https://github.com/vmware/rbvmomi) and send a -[pull request](https://github.com/vmware/rbvmomi/pulls). +Open an issue on the [issues page](https://github.com/ManageIQ/rbvmomi2/issues) +or fork the project on [GitHub](https://github.com/ManageIQ/rbvmomi2) and send a +[pull request](https://github.com/ManageIQ/rbvmomi2/pulls). ## Support -You can chat on [Gitter](https://gitter.im/vmware/rbvmomi) or join the [VMware {code} Slack team](https://vmwarecode.slack.com/) and join the [#rbvmomi channel](https://vmwarecode.slack.com/messages/rbvmomi). +You can chat on [Gitter](https://gitter.im/vmware/rbvmomi) diff --git a/devel/verify-vim-wsdl.rb b/devel/verify-vim-wsdl.rb index 5bdde204..695544a8 100755 --- a/devel/verify-vim-wsdl.rb +++ b/devel/verify-vim-wsdl.rb @@ -45,6 +45,20 @@ def dump_vmodl(vmodl, path) File.write(path, Marshal.dump(vmodl)) end +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 + # Normalize the type, some of these don't have RbVmomi equivalents such as xsd:long # and RbVmomi uses ManagedObjects not ManagedObjectReferences as parameters def wsdl_constantize(type) @@ -65,15 +79,44 @@ def wsdl_constantize(type) # Loop through the ComplexTypes in the WSDL and compare their types # to the types which are defined in the vmodl.db -vim.collect_complextypes.each do |type| +wsdl_types_by_name = vim.collect_complextypes.index_by { |type| type.name.name } + +wsdl_types_by_name.each_value do |type| type_name = type.name.name + next if type_name.match?(/^ArrayOf/) || type_name.match(/RequestType$/) + vmodl_data = vmodl[type_name] - # If a type exists in the WSDL but not in the vmodl.db just skip it, this - # can be for a few reasons including: - # 1. ArrayOf... types are not needed in the vmodl - # 2. A newer wsdl might have some types which haven't been added yet - next if vmodl_data.nil? + # If a type exists in the WSDL but not in the vmodl.db this usually + # indicates that it was added in a newer version than the current + # vmodl.db supports. + # + # Print a warning that the type is missing and skip it. + if vmodl_data.nil? + puts " #{type_name} is missing" + next unless options[:fix] + + base_class = wsdl_types_by_name[type.complexcontent.extension.base.name] + inherited_properties = base_class.elements.map { |element| element.name.name } + properties = type.elements.reject { |e| inherited_properties.include?(e.name.name) } + + vmodl_data = { + 'kind' => 'data', + 'props' => properties.map do |element| + { + 'name' => element.name.name, + 'is-optional' => element.minoccurs == 0, + 'is-array' => element.maxoccurs != 1, + 'version-id-ref' => nil, + 'wsdl_type' => wsdl_to_vmodl_type(element.type) + } + end, + 'wsdl_base' => type.complexcontent.extension.base.name + } + + vmodl[type_name] = vmodl_data + vmodl['_typenames']['_typenames'] << type_name + end # Index the properties by name to make it simpler to find later elements_by_name = type.elements.index_by { |e| e.name.name } diff --git a/lib/rbvmomi2.rb b/lib/rbvmomi2.rb new file mode 100644 index 00000000..f48a7f73 --- /dev/null +++ b/lib/rbvmomi2.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative './rbvmomi' diff --git a/rbvmomi.gemspec b/rbvmomi2.gemspec similarity index 86% rename from rbvmomi.gemspec rename to rbvmomi2.gemspec index 01fccdd6..06892e2c 100644 --- a/rbvmomi.gemspec +++ b/rbvmomi2.gemspec @@ -7,13 +7,13 @@ $LOAD_PATH.unshift(File.expand_path('lib', __dir__)) require 'rbvmomi/version' Gem::Specification.new do |spec| - spec.name = 'rbvmomi' + spec.name = 'rbvmomi2' spec.summary = 'Ruby interface to the VMware vSphere API' spec.version = RbVmomi::VERSION - spec.authors = ['Rich Lane', 'Christian Dickmann'] - spec.email = 'jrg@vmware.com' - spec.homepage = 'https://github.com/vmware/rbvmomi' + spec.authors = ['Adam Grare', 'Jason Frey'] + spec.email = ['adam@grare.com', 'fryguy9@gmail.com'] + spec.homepage = 'https://github.com/ManageIQ/rbvmomi2' spec.license = 'MIT' spec.bindir = 'exe' diff --git a/test/test_helper.rb b/test/test_helper.rb index 53f0369b..6f5348d2 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -5,7 +5,7 @@ require 'simplecov' SimpleCov.start { add_filter '/test/' } -require 'rbvmomi' +require 'rbvmomi2' VIM = RbVmomi::VIM require 'test/unit' diff --git a/vmodl.db b/vmodl.db index fd261a67..15fc8742 100644 Binary files a/vmodl.db and b/vmodl.db differ