Skip to content

Commit

Permalink
api: Prep to update types to vSphere 8.0U2 GA
Browse files Browse the repository at this point in the history
This patch updates the gen.sh file with the information necessary to
generate the types for vSphere 8.0U2 GA.
  • Loading branch information
akutz committed Sep 22, 2023
1 parent c59c149 commit b7ceede
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 18 deletions.
8 changes: 4 additions & 4 deletions gen/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ensure_rb_vmodl
#
# The VIM API version used by the vim25 client.
#
VIM_VERSION="${VIM_VERSION:-8.0.1.0}"
VIM_VERSION="${VIM_VERSION:-8.0.2.0}"

#
# Update the vim25 client's VIM version.
Expand All @@ -78,7 +78,7 @@ update_vim_version "${VIM_VERSION}"


#
# All types derive from vSphere 8.0U1c GA, vcenter-all build 22088981.
# All types derive from vSphere 8.0U2 GA, vcenter-all build 22385739.
#
export COPYRIGHT_DATE_RANGE="2014-2023"

Expand All @@ -89,14 +89,14 @@ export COPYRIGHT_DATE_RANGE="2014-2023"
#
export FORCE_BASE_INTERFACE_FOR_TYPES="AgencyConfigInfo"

# ./sdk/ contains the contents of wsdl.zip from vimbase build 21886307.
# ./sdk/ contains the contents of wsdl.zip from vimbase build 22026368.
generate "../vim25" "vim" "./rbvmomi/vmodl.db" # from github.com/vmware/[email protected]
generate "../pbm" "pbm"
generate "../vslm" "vslm"
generate "../sms" "sms"

# ./sdk/ contains the files eam-messagetypes.xsd and eam-types.xsd from
# eam-wsdl.zip, from eam-vcenter build 21054104.
# eam-wsdl.zip, from eam-vcenter build 22026240.
#
# Please note the EAM files are also available at the following, public URL --
# http://bit.ly/eam-sdk, therefore the WSDL resource for EAM are in fact
Expand Down
2 changes: 1 addition & 1 deletion gen/gen_from_vmodl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def var_type
end

def var_tag
"mo:\"%s\"" % name
"json:\"%s\"" % name
end

def dump(io)
Expand Down
30 changes: 19 additions & 11 deletions gen/vim_wsdl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# SINCE_API_FORMAT is used to capture the minimum API version for which some API
# symbol is valid.
SINCE_API_FORMAT = /^\*\*\*Since:\*\*\* \w+? API (.+)$/
SINCE_API_FORMAT = /^\*\*\*Since:\*\*\* \w+? API (?:Release )?(.+)$/

# ENCLOSED_BY_ASTERIK_FORMAT is used to capture words enclosed by a single
# asterik on either side.
Expand Down Expand Up @@ -58,23 +58,31 @@ def init_type(io, name, kind, minApiVersion=nil, minApiVersionsForValues=nil)

io.print "func init() {\n"

if minApiVersion != nil
io.print "minAPIVersionForType[\"#{name}\"] = \"#{minApiVersion}\"\n"
end
if minApiVersionsForValues != nil
io.print "minAPIVersionForEnumValue[\"#{name}\"] = map[string]string{\n"
minApiVersionsForValues.each do |k, v|
io.print "\t\t\"#{k}\": \"#{v}\",\n"
end
io.print "}\n"
end
if $target == "vim25"
io.print "t[\"#{name}\"] = #{t}\n"
if minApiVersion != nil
io.print "minAPIVersionForType[\"#{name}\"] = \"#{minApiVersion}\"\n"
end
if minApiVersionsForValues != nil
io.print "minAPIVersionForEnumValue[\"#{name}\"] = map[string]string{\n"
minApiVersionsForValues.each do |k, v|
io.print "\t\t\"#{k}\": \"#{v}\",\n"
end
io.print "}\n"
end
else
unless name.start_with? "Base"
name = "#{$target}:#{name}"
end
io.print "types.Add(\"#{name}\", #{t})\n"
if minApiVersion != nil
io.print "types.AddMinAPIVersionForType(\"#{name}\", \"#{minApiVersion}\")\n"
end
if minApiVersionsForValues != nil
minApiVersionsForValues.each do |k, v|
io.print "types.AddMinAPIVersionForEnumValue(\"#{name}\", \"#{k}\", \"#{v}\")\n"
end
end
end

io.print "}\n\n"
Expand Down
2 changes: 1 addition & 1 deletion govc/test/cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ load test_helper
assert_success

version=$(govc about -json -c | jq -r .Client.Version)
assert_equal 8.0.1.0 "$version" # govc's default version
assert_equal 8.0.2.0 "$version" # govc's default version

version=$(govc about -json -c -vim-version "" | jq -r .Client.Version)
assert_equal uE53DA "$version" # vcsim's service version
Expand Down
2 changes: 1 addition & 1 deletion vim25/mo/type_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func buildName(fn string, f reflect.StructField) string {
fn += "."
}

motag := f.Tag.Get("mo")
motag := f.Tag.Get("json")
if motag != "" {
return fn + motag
}
Expand Down
14 changes: 14 additions & 0 deletions vim25/types/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ func Add(name string, kind reflect.Type) {
t[name] = kind
}

func AddMinAPIVersionForType(name, minAPIVersion string) {
minAPIVersionForType[name] = minAPIVersion
}

func AddMinAPIVersionForEnumValue(enumName, enumValue, minAPIVersion string) {
if v, ok := minAPIVersionForEnumValue[enumName]; ok {
v[enumValue] = minAPIVersion
} else {
minAPIVersionForEnumValue[enumName] = map[string]string{
enumValue: minAPIVersion,
}
}
}

type Func func(string) (reflect.Type, bool)

func TypeFunc() Func {
Expand Down

0 comments on commit b7ceede

Please sign in to comment.