Created
December 22, 2015 20:29
-
-
Save jessepeterson/9ac458875be09aa4346c to your computer and use it in GitHub Desktop.
ESXi datastore upload helper (uses curl)
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/sh | |
if [ $# -lt 5 ]; then | |
echo "$0 <host> <user> <datastore> <folder> <filepath>" | |
echo | |
echo " examples:" | |
echo " $0 10.0.0.1 root datastore1 ISOs /tmp/Linux.iso" | |
exit 1 | |
fi | |
host="$1" | |
user="$2" | |
datastore="$3" | |
folder="$4" | |
filepath="$5" | |
filename="`basename $filepath`" | |
url="https://${host}/folder/${folder}/${filename}?dcPath=ha-datacenter&dsName=${datastore}" | |
echo "Uploading $filepath" | |
echo " to $datastore/$folder" | |
echo " on $host as $user" | |
curl -v \ | |
-k \ | |
-X PUT \ | |
-T "$filepath" \ | |
-u "$user" \ | |
"$url" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment