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

Update vmodl.db for vSphere 7.0U2 #209

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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?

<!-- You can erase any parts of this template not applicable to your Pull Request. -->

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# VMware has ended active development of this project, this repository will no longer be updated.
# RbVmomi

[<img src="https://badge.fury.io/rb/rbvmomi.svg" alt="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)
[<img src="https://badge.fury.io/rb/rbvmomi2.svg" alt="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)
[<img src="https://badges.gitter.im/vmware/rbvmomi.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

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

Expand Down Expand Up @@ -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)
55 changes: 49 additions & 6 deletions devel/verify-vim-wsdl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 }
Expand Down
3 changes: 3 additions & 0 deletions lib/rbvmomi2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require_relative './rbvmomi'
8 changes: 4 additions & 4 deletions rbvmomi.gemspec → rbvmomi2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]']
spec.homepage = 'https://github.com/ManageIQ/rbvmomi2'
spec.license = 'MIT'

spec.bindir = 'exe'
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'simplecov'
SimpleCov.start { add_filter '/test/' }

require 'rbvmomi'
require 'rbvmomi2'
VIM = RbVmomi::VIM

require 'test/unit'
Binary file modified vmodl.db
Binary file not shown.