1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00
This commit is contained in:
David Hill
2018-09-24 11:50:56 -05:00
parent 72f514ca54
commit 681cfd34eb
20 changed files with 292 additions and 1245 deletions

View File

@ -1,44 +0,0 @@
#! /bin/sh
# IDBCloudGetIP.sh
# Get IP Address from a Cloud environment
#
# 1. Amazon EC2
prefix=/usr/local
#get instance name from called
instanceName="$1"
ec2=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_HOME`
if [ $ec2 == "unassigned" ]; then
echo "stopped"
exit 1
fi
java=`$prefix/mariadb/columnstore/bin/getConfig Installation JAVA_HOME`
path=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_PATH`
export PATH=$path
export EC2_HOME=$ec2
export JAVA_HOME=$java
# get x509 Certification and Private Key
x509Cert=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonX509Certificate`
x509PriKey=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonX509PrivateKey`
#get instance info
ec2-describe-instances -C $x509Cert -K $x509PriKey $instanceName > /tmp/instanceInfo 2> /dev/null
#check if running
cat /tmp/instanceInfo | grep running > /tmp/instanceStatus
if [ `cat /tmp/instanceStatus | wc -c` -eq 0 ]; then
echo "stopped"
exit 1
fi
#get priviate IP Address
IpAddr=`cat /tmp/instanceInfo | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $15}'`
echo $IpAddr
exit 0

View File

@ -1,574 +0,0 @@
#! /bin/sh
# IDBInstanceCmds.sh
# get-local-instance-ID, get-zone, getPrivateIP from a Cloud environment
#
# 1. Amazon EC2
prefix=/usr/local
#check command
if [ "$1" = "" ]; then
echo "Enter Command Name: {launchInstance|getInstance|getZone|getPrivateIP|getKey|getAMI|getType|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet}
}"
exit 1
fi
if [ "$1" = "getPrivateIP" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$2"
fi
if [ "$1" = "launchInstance" ]; then
if [ "$2" = "" ]; then
IPaddress="unassigned"
else
IPaddress="$2"
fi
if [ "$3" = "" ]; then
instanceType="unassigned"
else
instanceType="$3"
fi
if [ "$4" = "" ]; then
group="unassigned"
else
group="$4"
fi
fi
if [ "$1" = "terminateInstance" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$2"
fi
if [ "$1" = "stopInstance" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$2"
fi
if [ "$1" = "startInstance" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$2"
fi
if [ "$1" = "assignElasticIP" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
else
instanceName="$2"
fi
if [ "$3" = "" ]; then
echo "Enter Elastic IP Address"
exit 1
else
IPAddress="$3"
fi
fi
if [ "$1" = "deassignElasticIP" ]; then
if [ "$2" = "" ]; then
echo "Enter Elastic IP Address"
exit 1
else
IPAddress="$2"
fi
fi
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
ec2=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_HOME`
if [ $ec2 == "unassigned" ]; then
if [ "$1" = "getPrivateIP" ]; then
echo "stopped"
exit 1
else
echo "unknown"
exit 1
fi
fi
java=`$prefix/mariadb/columnstore/bin/getConfig Installation JAVA_HOME`
path=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_PATH`
export PATH=$path
export EC2_HOME=$ec2
export JAVA_HOME=$java
# get Keys and region
AmazonAccessKeyFile=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonAccessKey`
if [ $AmazonAccessKeyFile == "unassigned" ]; then
echo "FAILED: missing Config Setting AmazonAccessKey : $AmazonAccessKeyfile"
exit 1
fi
AmazonSecretKeyFile=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonSecretKey`
if [ $AmazonSecretKeyFile == "unassigned" ]; then
echo "FAILED: missing Config Setting AmazonSecretKeyFile : $AmazonSecretKeyFile"
exit 1
fi
AmazonAccessKey=`cat $AmazonAccessKeyFile`
AmazonSecretKey=`cat $AmazonSecretKeyFile`
Region=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonRegion`
subnet=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonSubNetID`
if test ! -f $AmazonAccessKeyfile ; then
echo "FAILED: missing AmazonAccessKeyfile : $AmazonAccessKeyfile"
exit 1
fi
if test ! -f $AmazonSecretKeyfile ; then
echo "FAILED: missing AmazonSecretKeyfile : $AmazonSecretKeyfile"
exit 1
fi
#default instance to null
instance=""
describeInstanceFile="/tmp/describeInstance.txt"
touch $describeInstanceFile
describeInstance() {
ec2-describe-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region > $describeInstanceFile 2>&1
}
#call at start up
describeInstance
getInstance() {
if [ "$instance" != "" ]; then
echo $instance
return
fi
# first get local IP Address
localIP=`ifconfig eth0 | grep "inet addr:" | awk '{print substr($2,6,20)}'`
#get local Instance ID
instance=`cat $describeInstanceFile | grep -m 1 -w $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
if [ "$instance" == "" ]; then
describeInstance
fi
instance=`cat $describeInstanceFile | grep -m 1 -w $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
echo $instance
return
}
getInstancePrivate() {
if [ "$instance" != "" ]; then
echo $instance
return
fi
# first get local IP Address
localIP=`ifconfig eth0 | grep "inet addr:" | awk '{print substr($2,6,20)}'`
#get local Instance ID
instance=`cat $describeInstanceFile | grep -m 1 -w $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
if [ "$instance" == "" ]; then
describeInstance
fi
instance=`cat $describeInstanceFile | grep -m 1 -w $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
return
}
getZone() {
#get from Columnstore.xml if it's there, if not, get from instance then store
zone=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonZone`
if [ "$zone" = "unassigned" ] || [ "$zone" = "" ]; then
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get zone
if [ "$subnet" == "unassigned" ]; then
zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'`
if [ "$zone" == "" ]; then
describeInstance
fi
zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'`
else
zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'`
if [ "$zone" == "" ]; then
describeInstance
fi
zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'`
fi
$prefix/mariadb/columnstore/bin/setConfig Installation AmazonZone $zone
fi
echo $zone
return
}
getPrivateIP() {
#get instance info
grep -B1 -A4 -m 1 $instanceName $describeInstanceFile > /tmp/instanceInfo_$instanceName 2>&1
if [ `cat /tmp/instanceInfo_$instanceName | wc -c` -eq 0 ]; then
describeInstance
fi
grep -B1 -A4 -m 1 $instanceName $describeInstanceFile > /tmp/instanceInfo_$instanceName 2>&1
#check if running or terminated
cat /tmp/instanceInfo_$instanceName | grep running > /tmp/instanceStatus_$instanceName
if [ `cat /tmp/instanceStatus_$instanceName | wc -c` -eq 0 ]; then
# not running
cat /tmp/instanceInfo_$instanceName | grep pending > /tmp/instanceStatus_$instanceName
if [ `cat /tmp/instanceStatus_$instanceName | wc -c` -ne 0 ]; then
describeInstance
echo "stopped"
exit 1
else
cat /tmp/instanceInfo_$instanceName | grep terminated > /tmp/instanceStatus_$instanceName
if [ `cat /tmp/instanceStatus_$instanceName | wc -c` -ne 0 ]; then
echo "terminated"
exit 1
else
cat /tmp/instanceInfo_$instanceName | grep shutting-down > /tmp/instanceStatus_$instanceName
if [ `cat /tmp/instanceStatus_$instanceName | wc -c` -ne 0 ]; then
echo "terminated"
exit 1
else
echo "stopped"
exit 1
fi
fi
fi
fi
#running, get priviate IP Address
if [ "$subnet" == "unassigned" ]; then
IpAddr=`head -n 2 /tmp/instanceInfo_$instanceName | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $15}'`
else
IpAddr=`head -n 2 /tmp/instanceInfo_$instanceName | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $14}'`
fi
echo $IpAddr
exit 0
}
getType() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get Type
if [ "$subnet" == "unassigned" ]; then
instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'`
if [ "$instanceType" == "" ]; then
describeInstance
fi
instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'`
else
instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'`
if [ "$instanceType" == "" ]; then
describeInstance
fi
instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'`
fi
echo $instanceType
return
}
getKey() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get Key
if [ "$subnet" == "unassigned" ]; then
key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'`
if [ "$key" == "" ]; then
describeInstance
fi
key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'`
else
key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'`
if [ "$key" == "" ]; then
describeInstance
fi
key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'`
fi
echo $key
return
}
getAMI() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get AMI
ami=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $3}'`
if [ "$ami" == "" ]; then
describeInstance
fi
ami=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $3}'`
echo $ami
return
}
getGroup() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get group
if [ "$subnet" == "unassigned" ]; then
group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 RESERVATION | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $4}'`
if [ "$group" == "" ]; then
describeInstance
fi
group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 RESERVATION | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $4}'`
if [ "$group" == "" ]; then
group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $22}'`
fi
else
group=`grep -B1 -A6 -m 1 $instance $describeInstanceFile | grep -m 1 GROUP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
if [ "$group" == "" ]; then
describeInstance
fi
group=`grep -B1 -A6 -m 1 $instance $describeInstanceFile | grep -m 1 GROUP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
if [ "$group" == "" ]; then
group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $21}'`
fi
fi
echo $group
return
}
getProfile() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get Type
if [ "$subnet" == "unassigned" ]; then
instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $23}'`
if [ "$instanceProfile" == "" ]; then
describeInstance
fi
instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $23}'`
else
instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $22}'`
if [ "$instanceProfile" == "" ]; then
describeInstance
fi
instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $22}'`
fi
echo $instanceProfile
return
}
launchInstance() {
#get publickey
getKey >/dev/null 2>&1
if [ "$group" = "unassigned" ]; then
#get group
getGroup >/dev/null 2>&1
fi
#get AMI
getAMI >/dev/null 2>&1
#get Zone
getZone >/dev/null 2>&1
if [ "$instanceType" = "unassigned" ]; then
#get type
getType >/dev/null 2>&1
fi
#get AMI Profile
getProfile >/dev/null 2>&1
if [ "$subnet" == "unassigned" ]; then
#NOT VPC
if [ "$instanceProfile" = "" ] || [ "$instanceProfile" = "default" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone --region $Region $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone -p $instanceProfile --region $Region $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
else # VPC
if [ "$instanceProfile" = "" ] || [ "$instanceProfile" = "default" ]; then
if [ "$group" != "default" ]; then
if [ "$IPaddress" = "autoassign" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone --region $Region -s $subnet --private-ip-address $IPaddress $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
else
if [ "$IPaddress" = "autoassign" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -t $instanceType -z $zone --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances --O $AmazonAccessKey -W $AmazonSecretKey -k $key -t $instanceType -z $zone --region $Region -s $subnet --private-ip-address $IPaddress $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
fi
else
if [ "$group" != "default" ]; then
if [ "$IPaddress" = "autoassign" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet --private-ip-address $IPaddress $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
else
if [ "$IPaddress" = "autoassign" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet --private-ip-address $IPaddress $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
fi
fi
fi
echo $newInstance
return
}
terminateInstance() {
#terminate Instance
ec2-terminate-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $instanceName > /tmp/termInstanceInfo_$instanceName 2>&1
return
}
stopInstance() {
#terminate Instance
ec2-stop-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $instanceName > /tmp/stopInstanceInfo_$instanceName 2>&1
return
}
startInstance() {
#terminate Instance
ec2-start-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $instanceName > /tmp/startInstanceInfo_$instanceName 2>&1
cat /tmp/startInstanceInfo_$instanceName | grep INSTANCE > /tmp/startInstanceStatus_$instanceName
if [ `cat /tmp/startInstanceStatus_$instanceName | wc -c` -eq 0 ]; then
echo "Failed, check /tmp/startInstanceInfo_$instanceName"
exit 1
fi
echo "Success"
exit 0
}
assignElasticIP() {
#terminate Instance
if [ "$subnet" == "unassigned" ]; then
ec2-associate-address -O $AmazonAccessKey -W $AmazonSecretKey -i $instanceName $IPAddress > /tmp/assignElasticIPInfo_$IPAddress 2>&1
else
EIP=`ec2-describe-addresses -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $IPAddress | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $4}'`
ec2-associate-address -O $AmazonAccessKey -W $AmazonSecretKey --region $Region -i $instanceName -a $EIP > /tmp/assignElasticIPInfo_$IPAddress 2>&1
fi
cat /tmp/assignElasticIPInfo_$IPAddress | grep ADDRESS > /tmp/assignElasticIPStatus_$IPAddress
if [ `cat /tmp/assignElasticIPStatus_$IPAddress | wc -c` -eq 0 ]; then
echo "Failed, check /tmp/assignElasticIPInfo_$IPAddress"
exit 1
fi
echo "Success"
exit 0
}
deassignElasticIP() {
#terminate Instance
ec2-disassociate-address -O $AmazonAccessKey -W $AmazonSecretKey $IPAddress > /tmp/deassignElasticIPInfo_$IPAddress 2>&1
cat /tmp/deassignElasticIPInfo_$IPAddress | grep ADDRESS > /tmp/deassignElasticIPStatus_$IPAddress
if [ `cat /tmp/deassignElasticIPStatus_$IPAddress | wc -c` -eq 0 ]; then
echo "Failed, check /tmp/deassignElasticIPStatus_$IPAddress"
exit 1
fi
echo "Success"
exit 0
}
getSubnet() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get Subnet
subnet=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $16}'`
if [ "$subnet" == "" ]; then
describeInstance
fi
subnet=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $16}'`
if [[ $subnet == *"subnet"* ]]
then
echo $subnet
else
echo "failed"
fi
return
}
case "$1" in
getInstance)
getInstance
;;
getZone)
getZone
;;
getPrivateIP)
getPrivateIP
;;
getKey)
getKey
;;
getAMI)
getAMI
;;
getType)
getType
;;
launchInstance)
launchInstance
;;
terminateInstance)
terminateInstance
;;
stopInstance)
stopInstance
;;
startInstance)
startInstance
;;
assignElasticIP)
assignElasticIP
;;
deassignElasticIP)
deassignElasticIP
;;
getProfile)
getProfile
;;
getGroup)
getGroup
;;
getSubnet)
getSubnet
;;
*)
echo $"Usage: $0 {launchInstance|getInstance|getZone|getPrivateIP|getType|getKey|getAMI|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet}"
exit 1
esac
exit $?

View File

@ -1,337 +0,0 @@
#! /bin/sh
# IDBVolumeCmds.sh
# describe, detach and attach Volume Storage from a Cloud environment
#
# 1. Amazon EC2
prefix=/usr/local
#check command
if [ "$1" = "" ]; then
echo "Enter Command Name: {create|describe|detach|attach|delete|createTag}"
exit 1
fi
if [ "$1" = "create" ]; then
if [ "$2" = "" ]; then
echo "Enter size of the volume, in GiB (1-1024)"
exit 1
fi
volumeSize="$2"
#get module-type
if [ "$3" = "" ]; then
echo "Enter Module Type"
exit 1
fi
moduleType="$3"
fi
if [ "$1" = "describe" ]; then
if [ "$2" = "" ]; then
echo "Enter Volume Name"
exit 1
fi
volumeName="$2"
fi
if [ "$1" = "detach" ]; then
if [ "$2" = "" ]; then
echo "Enter Volume Name"
exit 1
fi
volumeName="$2"
fi
if [ "$1" = "attach" ]; then
if [ "$2" = "" ]; then
echo "Enter Volume Name"
exit 1
fi
volumeName="$2"
#get instance-name and device-name
if [ "$3" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$3"
if [ "$4" = "" ]; then
echo "Enter Device Name"
exit 1
fi
deviceName="$4"
fi
if [ "$1" = "delete" ]; then
if [ "$2" = "" ]; then
echo "Enter Volume Name"
exit 1
fi
volumeName="$2"
fi
if [ "$1" = "createTag" ]; then
if [ "$2" = "" ]; then
echo "Enter Resource Name"
exit 1
fi
resourceName="$2"
if [ "$3" = "" ]; then
echo "Enter Tag Name"
exit 1
fi
tagName="$3"
if [ "$4" = "" ]; then
echo "Enter Tag Value"
exit 1
fi
tagValue="$4"
fi
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
ec2=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_HOME`
if [ $ec2 == "unassigned" ]; then
STATUS="unknown"
RETVAL=1
fi
java=`$prefix/mariadb/columnstore/bin/getConfig Installation JAVA_HOME`
path=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_PATH`
export PATH=$path
export EC2_HOME=$ec2
export JAVA_HOME=$java
# get Keys and region
AmazonAccessKeyFile=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonAccessKey`
if [ $AmazonAccessKeyFile == "unassigned" ]; then
echo "FAILED: missing Config Setting AmazonAccessKey : $AmazonAccessKeyfile"
exit 1
fi
AmazonSecretKeyFile=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonSecretKey`
if [ $AmazonSecretKeyFile == "unassigned" ]; then
echo "FAILED: missing Config Setting AmazonSecretKeyFile : $AmazonSecretKeyFile"
exit 1
fi
AmazonAccessKey=`cat $AmazonAccessKeyFile`
AmazonSecretKey=`cat $AmazonSecretKeyFile`
if test ! -f $AmazonAccessKeyfile ; then
echo "FAILED: missing AmazonAccessKeyfile : $AmazonAccessKeyfile"
exit 1
fi
if test ! -f $AmazonSecretKeyfile ; then
echo "FAILED: missing AmazonSecretKeyfile : $AmazonSecretKeyfile"
exit 1
fi
Region=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonRegion`
checkInfostatus() {
#check if attached
cat /tmp/volumeInfo_$volumeName | grep attached > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="attached"
RETVAL=0
return
fi
#check if available
cat /tmp/volumeInfo_$volumeName | grep available > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="available"
RETVAL=0
return
fi
#check if detaching
cat /tmp/volumeInfo_$volumeName | grep detaching > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="detaching"
RETVAL=0
return
fi
#check if attaching
cat /tmp/volumeInfo_$volumeName | grep attaching > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="attaching"
RETVAL=0
return
fi
#check if doesn't exist
cat /tmp/volumeInfo_$volumeName | grep "does not exist" > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="does-not-exist"
RETVAL=1
return
fi
#check if reports already attached from attach command
cat /tmp/volumeInfo_$volumeName | grep "already attached" > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="already-attached"
RETVAL=1
return
fi
#any other, unknown error
STATUS="unknown"
RETVAL=1
return
}
createvolume() {
# get zone
zone=`$prefix/mariadb/columnstore/bin/IDBInstanceCmds.sh getZone`
if [ $moduleType == "um" ]; then
# get type
volumeType=`$prefix/mariadb/columnstore/bin/getConfig Installation UMVolumeType`
if [ $volumeType == "io1" ]; then
# get IOPS
volumeIOPS=`$prefix/mariadb/columnstore/bin/getConfig Installation UMVolumeIOPS`
fi
else # pm
# get type
volumeType=`$prefix/mariadb/columnstore/bin/getConfig Installation PMVolumeType`
if [ $volumeType == "io1" ]; then
# get IOPS
volumeIOPS=`$prefix/mariadb/columnstore/bin/getConfig Installation PMVolumeIOPS`
fi
fi
#create volume
if [ $volumeType == "io1" ]; then
volume=`ec2-create-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region -z $zone -s $volumeSize -t $volumeType -iops $volumeIOPS | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
volume=`ec2-create-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region -z $zone -s $volumeSize -t $volumeType | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
echo $volume
return
}
describevolume() {
#describe volume
ec2-describe-volumes -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1
checkInfostatus
echo $STATUS
return
}
detachvolume() {
#detach volume
ec2-detach-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "detaching" ]; then
retries=1
while [ $retries -ne 60 ]; do
#retry until it's attached
ec2-detach-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "available" ]; then
echo "available"
exit 0
fi
((retries++))
sleep 1
done
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
cplogger -w 100 "detachvolume failed: $STATUS"
echo "failed"
exit 1
fi
if [ $STATUS == "available" ]; then
echo "available"
exit 0
fi
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
cplogger -w 100 "detachvolume failed status: $STATUS"
echo $STATUS
exit 1
}
attachvolume() {
#detach volume
ec2-attach-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName -i $instanceName -d $deviceName > /tmp/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "attaching" -o $STATUS == "already-attached" ]; then
retries=1
while [ $retries -ne 60 ]; do
#check status until it's attached
describevolume
if [ $STATUS == "attached" ]; then
echo "attached"
exit 0
fi
((retries++))
sleep 1
done
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
cplogger -w 100 "attachvolume failed: $STATUS"
echo "failed"
exit 1
fi
if [ $STATUS == "attached" ]; then
echo "attached"
exit 0
fi
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
cplogger -w 100 "attachvolume failed: $STATUS"
echo $STATUS
exit 1
}
deletevolume() {
#delete volume
ec2-delete-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/deletevolume_$volumeName 2>&1
return
}
createTag() {
#create tag
ec2-create-tags -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $resourceName --tag $tagName=$tagValue > /tmp/createTag_$volumeName 2>&1
return
}
case "$1" in
create)
createvolume
;;
describe)
describevolume
;;
detach)
detachvolume
;;
attach)
attachvolume
;;
delete)
deletevolume
;;
createTag)
createTag
;;
*)
echo $"Usage: $0 {create|describe|detach|attach|delete|}"
exit 1
esac
exit $?

View File

@ -10,6 +10,8 @@ fi
export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR
#get temp directory
tmpDir=`$COLUMNSTORE_INSTALL_DIR/bin/getConfig SystemConfig SystemTempFileDir`
#check command
if [ "$1" = "" ]; then
@ -310,7 +312,7 @@ terminateInstance() {
getRegion >/dev/null 2>&1
#terminate Instance
$AWSCLI terminate-instances --instance-ids $instanceName --region $Region > /tmp/termInstanceInfo_$instanceName 2>&1
$AWSCLI terminate-instances --instance-ids $instanceName --region $Region > ${tmpdir}/termInstanceInfo_$instanceName 2>&1
return
}
@ -319,7 +321,7 @@ stopInstance() {
getRegion >/dev/null 2>&1
#terminate Instance
$AWSCLI stop-instances --instance-ids $instanceName --region $Region > /tmp/stopInstanceInfo_$instanceName 2>&1
$AWSCLI stop-instances --instance-ids $instanceName --region $Region > ${tmpdir}/stopInstanceInfo_$instanceName 2>&1
return
}
@ -328,11 +330,11 @@ startInstance() {
getRegion >/dev/null 2>&1
#terminate Instance
$AWSCLI start-instances --instance-ids $instanceName --region $Region > /tmp/startInstanceInfo_$instanceName 2>&1
$AWSCLI start-instances --instance-ids $instanceName --region $Region > ${tmpdir}/startInstanceInfo_$instanceName 2>&1
cat /tmp/startInstanceInfo_$instanceName | grep InstanceId > /tmp/startInstanceStatus_$instanceName
if [ `cat /tmp/startInstanceStatus_$instanceName | wc -c` -eq 0 ]; then
echo "Failed, check /tmp/startInstanceInfo_$instanceName"
cat ${tmpdir}/startInstanceInfo_$instanceName | grep InstanceId > ${tmpdir}/startInstanceStatus_$instanceName
if [ `cat ${tmpdir}/startInstanceStatus_$instanceName | wc -c` -eq 0 ]; then
echo "Failed, check ${tmpdir}/startInstanceInfo_$instanceName"
exit 1
fi
echo "Success"
@ -345,11 +347,11 @@ assignElasticIP() {
EIP=`$AWSCLI describe-addresses --region $Region --public-ips $IPAddress --query 'Addresses[*].AllocationId' --output text`
$AWSCLI associate-address --region $Region --instance-id $instanceName --allocation-id $EIP > /tmp/assignElasticIPInfo_$IPAddress 2>&1
$AWSCLI associate-address --region $Region --instance-id $instanceName --allocation-id $EIP > ${tmpdir}/assignElasticIPInfo_$IPAddress 2>&1
cat /tmp/assignElasticIPInfo_$IPAddress | grep error > /tmp/assignElasticIPStatus_$IPAddress
if [ `cat /tmp/assignElasticIPStatus_$IPAddress | wc -c` -ne 0 ]; then
echo "Failed, check /tmp/assignElasticIPInfo_$IPAddress"
cat ${tmpdir}/assignElasticIPInfo_$IPAddress | grep error > ${tmpdir}/assignElasticIPStatus_$IPAddress
if [ `cat ${tmpdir}/assignElasticIPStatus_$IPAddress | wc -c` -ne 0 ]; then
echo "Failed, check ${tmpdir}/assignElasticIPInfo_$IPAddress"
exit 1
fi
@ -363,10 +365,10 @@ deassignElasticIP() {
EIP=`$AWSCLI describe-addresses --region $Region --public-ips $IPAddress --query 'Addresses[*].AssociationId' --output text`
$AWSCLI disassociate-address --region $Region --association-id $EIP > /tmp/deassignElasticIPInfo_$IPAddress 2>&1
cat /tmp/deassignElasticIPInfo_$IPAddress | grep error > /tmp/deassignElasticIPStatus_$IPAddress
if [ `cat /tmp/deassignElasticIPStatus_$IPAddress | wc -c` -ne 0 ]; then
echo "Failed, check /tmp/deassignElasticIPStatus_$IPAddress"
$AWSCLI disassociate-address --region $Region --association-id $EIP > ${tmpdir}/deassignElasticIPInfo_$IPAddress 2>&1
cat ${tmpdir}/deassignElasticIPInfo_$IPAddress | grep error > ${tmpdir}/deassignElasticIPStatus_$IPAddress
if [ `cat ${tmpdir}/deassignElasticIPStatus_$IPAddress | wc -c` -ne 0 ]; then
echo "Failed, check ${tmpdir}/deassignElasticIPStatus_$IPAddress"
exit 1
fi

View File

@ -10,6 +10,9 @@ fi
export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR
#get temp directory
tmpDir=`$COLUMNSTORE_INSTALL_DIR/bin/getConfig SystemConfig SystemTempFileDir`
#check command
if [ "$1" = "" ]; then
echo "Enter Command Name: {create|describe|detach|attach|delete|createTag}"
@ -108,43 +111,43 @@ Region=`$COLUMNSTORE_INSTALL_DIR/bin/MCSInstanceCmds.sh getRegion`
checkInfostatus() {
#check if attached
cat /tmp/volumeInfo_$volumeName | grep attached > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep attached > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="attached"
RETVAL=0
return
fi
#check if available
cat /tmp/volumeInfo_$volumeName | grep available > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep available > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="available"
RETVAL=0
return
fi
#check if detaching
cat /tmp/volumeInfo_$volumeName | grep detaching > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep detaching > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="detaching"
RETVAL=0
return
fi
#check if attaching
cat /tmp/volumeInfo_$volumeName | grep attaching > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}volumeInfo_$volumeName | grep attaching > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="attaching"
RETVAL=0
return
fi
#check if doesn't exist
cat /tmp/volumeInfo_$volumeName | grep "does not exist" > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep "does not exist" > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="does-not-exist"
RETVAL=1
return
fi
#check if reports already attached from attach command
cat /tmp/volumeInfo_$volumeName | grep "already attached" > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep "already attached" > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="already-attached"
RETVAL=1
return
@ -188,7 +191,7 @@ createvolume() {
describevolume() {
#describe volume
$AWSCLI describe-volumes --volume-ids $volumeName --region $Region > /tmp/volumeInfo_$volumeName 2>&1
$AWSCLI describe-volumes --volume-ids $volumeName --region $Region > ${tmpdir}/volumeInfo_$volumeName 2>&1
checkInfostatus
echo $STATUS
@ -197,14 +200,14 @@ describevolume() {
detachvolume() {
#detach volume
$AWSCLI detach-volume --volume-id $volumeName --region $Region > /tmp/volumeInfo_$volumeName 2>&1
$AWSCLI detach-volume --volume-id $volumeName --region $Region > ${tmpdir}/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "detaching" ]; then
retries=1
while [ $retries -ne 10 ]; do
#retry until it's attached
$AWSCLI detach-volume --volume-id $volumeName --region $Region > /tmp/volumeInfo_$volumeName 2>&1
$AWSCLI detach-volume --volume-id $volumeName --region $Region > ${tmpdir}/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "available" ]; then
@ -234,7 +237,7 @@ detachvolume() {
attachvolume() {
#detach volume
$AWSCLI attach-volume --volume-id $volumeName --instance-id $instanceName --device $deviceName --region $Region > /tmp/volumeInfo_$volumeName 2>&1
$AWSCLI attach-volume --volume-id $volumeName --instance-id $instanceName --device $deviceName --region $Region > ${tmpdir}/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "attaching" -o $STATUS == "already-attached" ]; then
@ -268,13 +271,13 @@ attachvolume() {
deletevolume() {
#delete volume
$AWSCLI delete-volume --volume-id $volumeName --region $Region > /tmp/deletevolume_$volumeName 2>&1
$AWSCLI delete-volume --volume-id $volumeName --region $Region > ${tmpdir}/deletevolume_$volumeName 2>&1
return
}
createTag() {
#create tag
$AWSCLI create-tags --resources $resourceName --tags Key=$tagName,Value=$tagValue --region $Region > /tmp/createTag_$volumeName 2>&1
$AWSCLI create-tags --resources $resourceName --tags Key=$tagName,Value=$tagValue --region $Region > ${tmpdir}/createTag_$volumeName 2>&1
return
}