Last active
July 5, 2023 12:11
-
-
Save rsp2k/a8bd0ea5d3699597c40f4ee533c0adbe to your computer and use it in GitHub Desktop.
Install VMWare vSAN Management SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install VMWare vSAN Management SDK, which needs to be downloaded from VMware and installed manually. | |
# [email protected] 2023-07-04 | |
# Created for bootstrapping the Ansible vmware_cluster_vsan module on posix systems: | |
# https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_cluster_vsan_module.html | |
# The info here was helpful (thanks!): | |
# https://sky-jokerxx.medium.com/how-to-use-vsan-modules-for-community-vmware-with-ansible-664702e097c4 | |
# | |
# Then I found the right way to do it (doh)! | |
# http://dnaeon.github.io/packaging-the-vsan-sdk-for-python/ | |
# | |
SDK_ZIP=vsan-sdk-python.zip | |
if [ ! -f $SDK_ZIP ] | |
then | |
echo " | |
Manually download vSAN Python SDK from vmware | |
NB: CHECK THE VERSION DROP-DOWN IN THE TOP RIGHT CORNER! | |
7.0 U3 https://developer.vmware.com/web/sdk/7.0%20U3/vsan-python | |
6.7 U3 - https://developer.vmware.com/web/sdk/6.7U3/vsan-python | |
Put the downloaded zip in ${PWD}/${SDK_ZIP} and run me again " | |
exit 1 | |
fi | |
SITE_PACKAGES=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])') | |
echo "Site Packages: ${SITE_PACKAGES}" | |
if [[ -f ${SITE_PACKAGES}/vsanapiutils.py ]] && [[ -f ${SITE_PACKAGES}/vsanapiutils.py ]] | |
then | |
echo Already installed in ${SITE_PACKAGES} >&2 | |
exit 0 | |
fi | |
TMP=.vsan-sdk-install-${RANDOM} | |
echo "Creating a tmpdir ${TMP}" | |
mkdir ${TMP} | |
echo "Unzipping SDK_ZIP" | |
unzip -d ${TMP} -qq ${SDK_ZIP} | |
echo "Installing vsan-sdk into ${SITE_PACKAGES}" | |
find ${TMP}/vsan-sdk-python/ -type f | grep -e vsanmgmtObjects -e vsanapiutils | xargs -n 1 -i cp {} $SITE_PACKAGES | |
rm -rf ${TMP} | |
echo "Installing defusedxml dependency package with pip3" | |
pip3 install defusedxml | |
TEST_COMMAND="python3 -c 'import vsanapiutils; import vsanmgmtObjects'" | |
set -e | |
echo "Testing python import of vsanapiutils and vsanmgmtObjects: ${TEST_COMMAND}" | |
echo "It worked!" | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment