github.com/vmware/govmomi@v0.51.0/gen/gen.sh (about)

     1  #!/bin/bash
     2  
     3  # © Broadcom. All Rights Reserved.
     4  # The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
     5  # SPDX-License-Identifier: Apache-2.0
     6  
     7  set -e
     8  
     9  ensure_rb_vmodl() {
    10    mkdir -p ./rbvmomi
    11    [ -f ./rbvmomi/vmodl.db ] || \
    12      curl -sSLo \
    13        ./rbvmomi/vmodl.db \
    14        https://github.com/vmware-archive/rbvmomi/raw/master/vmodl.db
    15  }
    16  
    17  generate() {
    18    dst="$1"
    19    wsdl="$2"
    20    modl="$3"
    21  
    22    pkgs=(types methods)
    23    if [ -n "$modl" ] ; then
    24      pkgs+=(mo)
    25    fi
    26  
    27    for p in "${pkgs[@]}"
    28    do
    29      mkdir -p "$dst/$p"
    30    done
    31  
    32    echo "generating $dst/..."
    33  
    34    bundle exec ruby gen_from_wsdl.rb "$dst" "$wsdl"
    35    if [ -n "$modl" ] ; then
    36      bundle exec ruby gen_from_vmodl.rb "$dst" "$wsdl" "$modl"
    37    fi
    38  
    39    for p in "${pkgs[@]}"
    40    do
    41      pushd "$dst/$p" >/dev/null
    42      goimports -w ./*.go
    43      go install
    44      popd >/dev/null
    45    done
    46  }
    47  
    48  update_vim_version() {
    49    sed -i'.bak' -e 's~^[[:blank:]]\{1,\}Version[[:blank:]]\{1,\}=.\{1,\}$~Version = '"\"${1}\""'~g' ../vim25/client.go
    50    rm -f ../vim25/client.go.bak
    51    go fmt ../vim25/client.go
    52  
    53    sed -i'.bak' -e 's/assert_equal .* ".*govc'"'"'s default version/assert_equal '"${1}"' "$version" # govc'"'"'s default version/' ../govc/test/cli.bats
    54    rm -f ../govc/test/cli.bats.bak
    55  }
    56  
    57  #
    58  # Make sure the vmodl.db file exists.
    59  #
    60  ensure_rb_vmodl
    61  
    62  #
    63  # The VIM API version used by the vim25 client.
    64  #
    65  VIM_VERSION="${VIM_VERSION:-9.0.0.0}"
    66  
    67  #
    68  # Update the vim25 client's VIM version.
    69  #
    70  update_vim_version "${VIM_VERSION}"
    71  
    72  
    73  #
    74  # All types derive from vSphere 9.0.0.0.rc1, vcenter-all build 24472083.
    75  #
    76  export COPYRIGHT_DATE_RANGE="2014-2025"
    77  
    78  #
    79  # FORCE_BASE_INTERFACE_FOR_TYPES defines the types that we want to
    80  # generate base interfaces for. The type names should be comma seperated -
    81  # e.g. "TypeA,TypeB,TypeC".
    82  #
    83  export FORCE_BASE_INTERFACE_FOR_TYPES="AgencyConfigInfo"
    84  
    85  # ./sdk/ contains the contents of wsdl.zip from vimbase build 24471874.
    86  generate "../vim25" "vim" "./rbvmomi/vmodl.db" # from github.com/vmware/rbvmomi@v3.0.0
    87  generate "../pbm" "pbm"
    88  generate "../vslm" "vslm"
    89  generate "../sms" "sms"
    90  
    91  # ./sdk/ contains the files eam-messagetypes.xsd and eam-types.xsd from
    92  # eam-wsdl.zip, from eam-vcenter build 24472222.
    93  #
    94  # Please note the EAM files are also available at the following, public URL --
    95  # http://bit.ly/eam-sdk, therefore the WSDL resource for EAM are in fact
    96  # public. A specific build was obtained in order to match the same build as
    97  # used for the file from above, wsdl.zip.
    98  COPYRIGHT_DATE_RANGE="2021-2025" generate "../eam" "eam"
    99  
   100  # originally generated, then manually pruned as there are several vim25 types
   101  # that are duplicated.
   102  #
   103  # generate "../lookup" "lookup" # lookup.wsdl from build 4571810
   104  # originally generated, then manually pruned.
   105  # generate "../ssoadmin" "ssoadmin" # ssoadmin.wsdl from PSC