github.com/vmware/govmomi@v0.37.1/gen/gen.sh (about) 1 #!/bin/bash 2 3 # Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 set -e 18 19 ensure_rb_vmodl() { 20 mkdir -p ./rbvmomi 21 [ -f ./rbvmomi/vmodl.db ] || \ 22 curl -sSLo \ 23 ./rbvmomi/vmodl.db \ 24 https://github.com/vmware-archive/rbvmomi/raw/master/vmodl.db 25 } 26 27 generate() { 28 dst="$1" 29 wsdl="$2" 30 modl="$3" 31 32 pkgs=(types methods) 33 if [ -n "$modl" ] ; then 34 pkgs+=(mo) 35 fi 36 37 for p in "${pkgs[@]}" 38 do 39 mkdir -p "$dst/$p" 40 done 41 42 echo "generating $dst/..." 43 44 bundle exec ruby gen_from_wsdl.rb "$dst" "$wsdl" 45 if [ -n "$modl" ] ; then 46 bundle exec ruby gen_from_vmodl.rb "$dst" "$wsdl" "$modl" 47 fi 48 49 for p in "${pkgs[@]}" 50 do 51 pushd "$dst/$p" >/dev/null 52 goimports -w ./*.go 53 go install 54 popd >/dev/null 55 done 56 } 57 58 update_vim_version() { 59 sed -i'.bak' -e 's~^[[:blank:]]\{1,\}Version[[:blank:]]\{1,\}=.\{1,\}$~Version = '"\"${1}\""'~g' ../vim25/client.go 60 rm -f ../vim25/client.go.bak 61 go fmt ../vim25/client.go 62 } 63 64 # 65 # Make sure the vmodl.db file exists. 66 # 67 ensure_rb_vmodl 68 69 # 70 # The VIM API version used by the vim25 client. 71 # 72 VIM_VERSION="${VIM_VERSION:-8.0.2.0}" 73 74 # 75 # Update the vim25 client's VIM version. 76 # 77 update_vim_version "${VIM_VERSION}" 78 79 80 # 81 # All types derive from vSphere 8.0U2 GA, vcenter-all build 22385739. 82 # 83 export COPYRIGHT_DATE_RANGE="2014-2023" 84 85 # 86 # FORCE_BASE_INTERFACE_FOR_TYPES defines the types that we want to 87 # generate base interfaces for. The type names should be comma seperated - 88 # e.g. "TypeA,TypeB,TypeC". 89 # 90 export FORCE_BASE_INTERFACE_FOR_TYPES="AgencyConfigInfo" 91 92 # ./sdk/ contains the contents of wsdl.zip from vimbase build 22026368. 93 generate "../vim25" "vim" "./rbvmomi/vmodl.db" # from github.com/vmware/rbvmomi@v3.0.0 94 generate "../pbm" "pbm" 95 generate "../vslm" "vslm" 96 generate "../sms" "sms" 97 98 # ./sdk/ contains the files eam-messagetypes.xsd and eam-types.xsd from 99 # eam-wsdl.zip, from eam-vcenter build 22026240. 100 # 101 # Please note the EAM files are also available at the following, public URL -- 102 # http://bit.ly/eam-sdk, therefore the WSDL resource for EAM are in fact 103 # public. A specific build was obtained in order to match the same build as 104 # used for the file from above, wsdl.zip. 105 COPYRIGHT_DATE_RANGE="2021-2023" generate "../eam" "eam" 106 107 # originally generated, then manually pruned as there are several vim25 types that are duplicated. 108 # generate "../lookup" "lookup" # lookup.wsdl from build 4571810 109 # originally generated, then manually pruned. 110 # generate "../ssoadmin" "ssoadmin" # ssoadmin.wsdl from PSC