Created
June 16, 2017 22:10
-
-
Save j-griffith/c12b334e5328f175f65ec895deb18d8c to your computer and use it in GitHub Desktop.
basic wget to create sf vol, map access group and iscsi connect
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 | |
######################################################################## | |
# Script: CreateAttachSFVol.bash | |
# Author: John Griffith ([email protected]) | |
# | |
# Simple script to: | |
# 1. Create a volume on a SolidFire Cluster | |
# 2. Add volume to an existing Access Group (by ID) | |
# 3. Issue iscsi discovery on the newly created volume | |
# 4. Perfrom an iscsi login to the newly created volume | |
# | |
# Currently we accept arguments for 'volume-name' and 'access-group-id' | |
# if you'd like anything else to be passed in this script can be modified | |
# Things like size is hard-coded and QoS is default. | |
# | |
# Be sure to replace "user:password" in the wget calls below with valid | |
# credentials for your cluster! | |
# | |
# Required packages: | |
# open-iscsi | |
# existing VolumeAccessGroup with node iqn added | |
# jq (apt-get install jq) | |
######################################################################## | |
NAME=$1 | |
AG=$2 | |
RESULT=`wget --no-check-certificate -O - 'https://user:[email protected]:443/json-rpc/8.0' \ | |
--post-data='{"method": "CreateVolume", "params": {"name": "'"$NAME"'", | |
"accountID": 1706, \ | |
"totalSize": 10000000000, "enable512e": true}}'` | |
echo $RESULT | jq '.' | |
VOLID=`echo "${RESULT}" | jq '.result.volumeID'` | |
echo "volid is: ${VOLID}" | |
RESULT=`wget --no-check-certificate -O - 'https://user:[email protected]:443/json-rpc/8.0' \ | |
--post-data='{"method": "AddVolumesToVolumeAccessGroup", \ | |
"params": {"volumeAccessGroupID": "'"$AG"'", \ | |
"volumes": ['"$VOLID"']}}'` | |
echo $RESULT | jq '.' | |
TGT=`sudo iscsiadm -m discovery -t sendtargets -p 10.117.37.101:3260 | grep ${VOLID}` | |
echo target=$TGT | |
tgtarray=($TGT) | |
IQN=${tgtarray[1]} | |
echo iqn=$IQN | |
sudo iscsiadm -m node --targetname=$IQN --login |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment