1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-07 03:22:57 +03:00
This commit is contained in:
David Hill
2017-01-05 16:19:05 -06:00
parent 76876ff193
commit 9a7b048ba3
3 changed files with 88 additions and 52 deletions

View File

@@ -8,8 +8,7 @@ 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|getVpc|getRegion}
}"
echo "Enter Command Name: {launchInstance|getInstance|getZone|getPrivateIP|getKey|getAMI|getType|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet|getVpc|getRegion|getRole}"
exit 1
fi
@@ -104,6 +103,24 @@ getRegion() {
return
}
getRole() {
#check for iam folder
iam=`curl -s http://169.254.169.254/latest/meta-data/ | grep iam`
if [ -z "$iam" ]; then
exit 1;
fi
Role=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/`
if [ -z "$role" ]; then
exit 1;
fi
echo $Role
return
}
getInstance() {
if [ "$instanceName" != "" ]; then
echo $instanceName
@@ -232,49 +249,52 @@ launchInstance() {
#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
#get Subnet
getSubnet >/dev/null 2>&1
if [ "$instanceProfile" = "" ] || [ "$instanceProfile" = "default-hvm" ]; then
if [ "$groupid" != "default" ]; then
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ] ; then
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --image-id $ami --security-group-ids $groupid --query 'Instances[*].InstanceId' --output text`
else
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
fi
#get IAM Role
getRole >/dev/null 2>&1
if [ "$Role" = "" ] || [ "$Role" = "default" ]; then
if [ "$groupid" != "default" ]; then
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ] ; then
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --image-id $ami --security-group-ids $groupid --query 'Instances[*].InstanceId' --output text`
else
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
else
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
fi
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
fi
else
if [ "$groupid" != "default" ]; then
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $instanceProfile --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
else
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $instanceProfile --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
fi
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
else
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $instanceProfile --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
else
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $instanceProfile --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
fi
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
fi
fi
else
if [ "$groupid" != "default" ]; then
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $Role --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
else
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $Role --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
fi
else
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $Role --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
else
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $Role --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
fi
fi
fi
echo $newInstance
return
@@ -421,9 +441,11 @@ case "$1" in
getRegion)
getRegion
;;
getRole)
getRole
;;
*)
echo $"Usage: $0 {launchInstance|getInstance|getZone|getPrivateIP|getType|getKey|getAMI|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet|getVpc|getRegion}"
echo $"Usage: $0 {launchInstance|getInstance|getZone|getPrivateIP|getType|getKey|getAMI|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet|getVpc|getRegion|getRole}"
exit 1
esac

View File

@@ -6,28 +6,20 @@ if [ -f $HOME/.aws/credentials ]; then
exit 0
fi
#check for iam folder
iam=`curl -s http://169.254.169.254/latest/meta-data/ | grep iam`
#get IAM Role
Role=`$prefix/mariadb/columnstore/bin/MCSInstanceCmds.sh getRole`
if [ -z "$iam" ]; then
if [ -z "$Role" ]; then
exit 1;
fi
instance_profile=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/`
#
if [ -z "$instance_profile" ]; then
exit 1;
fi
aws_access_key_id=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_access_key_id=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${Role} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
if [ -z "$aws_access_key_id" ]; then
exit 1;
fi
aws_secret_access_key=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
aws_secret_access_key=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${Role} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
if [ -z "$aws_secret_access_key" ]; then
exit 1;

View File

@@ -5967,11 +5967,22 @@ namespace oam
cout << " Create AWS Volume for UM #" << itoa(moduleID) << endl;
volumeName = createEC2Volume(UMVolumeSize, "um");
if ( volumeName == "failed" ) {
writeLog("addModule: create volume failed", LOG_TYPE_CRITICAL);
exceptionControl("addUMdisk", API_FAILURE);
}
int retry = 0;
for ( ; retry < 5 ; retry++ )
{
volumeName = createEC2Volume(UMVolumeSize, "um");
if ( volumeName == "failed" || volumeName.empty() )
retry = retry;
else
break;
}
if ( retry >= 5 )
{
cout << " *** ERROR: Failed to create a Volume for um1 " << moduleID << endl;
exceptionControl("addUMdisk", API_FAILURE);
}
//attach and format volumes
device = "/dev/sdf";
@@ -5979,11 +5990,22 @@ namespace oam
string localInstance = getEC2LocalInstance();
//attach volumes to local instance
writeLog("addUMdisk - Attach new Volume to local instance: " + volumeName, LOG_TYPE_DEBUG);
if (!attachEC2Volume(volumeName, device, localInstance)) {
writeLog("addUMdisk: volume failed to attach to local instance", LOG_TYPE_CRITICAL);
exceptionControl("addUMdisk", API_FAILURE);
}
writeLog("addUMdisk - Attach new Volume to local instance: " + volumeName, LOG_TYPE_DEBUG);
retry = 0;
for ( ; retry < 5 ; retry++ )
{
if (!attachEC2Volume(volumeName, device, localInstance))
detachEC2Volume(volumeName);
else
break;
}
if ( retry >= 5 )
{
cout << " *** ERROR: Volume " << volumeName << " failed to attach to local instance" << endl;
exceptionControl("addUMdisk", API_FAILURE);
}
//format attached volume
writeLog("addUMdisk - Format new Volume for: " + volumeName, LOG_TYPE_DEBUG);