diff --git a/oam/cloud/IDBInstanceCmds.sh b/oam/cloud/IDBInstanceCmds.sh old mode 100755 new mode 100644 index 4cb70b59f..1a33c8328 --- a/oam/cloud/IDBInstanceCmds.sh +++ b/oam/cloud/IDBInstanceCmds.sh @@ -111,9 +111,20 @@ export JAVA_HOME=$java # get Keys and region AmazonAccessKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` +if [ $AmazonAccessKeyfile == "unassigned" ]; then + echo "FAILED: missing Config Setting AmazonAccessKey : $AmazonAccessKeyfile" + exit 1 +fi + AmazonSecretKeyFile=`$prefix/Calpont/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/Calpont/bin/getConfig Installation AmazonRegion` subnet=`$prefix/Calpont/bin/getConfig Installation AmazonSubNetID` diff --git a/oam/cloud/IDBVolumeCmds.sh b/oam/cloud/IDBVolumeCmds.sh index b5a11ab10..02482b43b 100644 --- a/oam/cloud/IDBVolumeCmds.sh +++ b/oam/cloud/IDBVolumeCmds.sh @@ -18,6 +18,13 @@ if [ "$1" = "create" ]; then 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 @@ -104,12 +111,20 @@ export JAVA_HOME=$java # get Keys and region AmazonAccessKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` +if [ $AmazonAccessKeyfile == "unassigned" ]; then + echo "FAILED: missing Config Setting AmazonAccessKey : $AmazonAccessKeyfile" + exit 1 +fi + AmazonSecretKeyFile=`$prefix/Calpont/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/Calpont/bin/getConfig Installation AmazonRegion` - if test ! -f $AmazonAccessKeyfile ; then echo "FAILED: missing AmazonAccessKeyfile : $AmazonAccessKeyfile" exit 1 @@ -120,6 +135,8 @@ if test ! -f $AmazonSecretKeyfile ; then exit 1 fi +Region=`$prefix/Calpont/bin/getConfig Installation AmazonRegion` + checkInfostatus() { #check if attached @@ -173,11 +190,29 @@ checkInfostatus() { createvolume() { # get zone zone=`$prefix/Calpont/bin/IDBInstanceCmds.sh getZone` - #create volume - volume=`ec2-create-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region -z $zone -s $volumeSize | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` -# #get volume name -# volume=`cat /tmp/volumeCreate_$resourceName | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` + if [ $moduleType == "um" ]; then + # get type + volumeType=`$prefix/Calpont/bin/IDBInstanceCmds.sh UMVolumeType` + if [ $volumeType == "io1" ]; then + # get IOPS + volumeIOPS=`$prefix/Calpont/bin/IDBInstanceCmds.sh UMVolumeIOPS` + fi + else # pm + # get type + volumeType=`$prefix/Calpont/bin/IDBInstanceCmds.sh PMVolumeType` + if [ $volumeType == "io1" ]; then + # get IOPS + volumeIOPS=`$prefix/Calpont/bin/IDBInstanceCmds.sh 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}'` + echo $volume return } diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 0a391379b..280e164e1 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -5939,7 +5939,7 @@ namespace oam catch(...) {} writeLog("addUMdisk - Create new Volume for um" + itoa(moduleID), LOG_TYPE_DEBUG); - volumeName = createEC2Volume(UMVolumeSize); + volumeName = createEC2Volume(UMVolumeSize, "um"); if ( volumeName == "failed" ) { writeLog("addModule: create volume failed", LOG_TYPE_CRITICAL); exceptionControl("addUMdisk", API_FAILURE); @@ -6120,7 +6120,7 @@ namespace oam int retry = 0; for ( ; retry < 5 ; retry++ ) { - volumeName = createEC2Volume(volumeSize); + volumeName = createEC2Volume(volumeSize, "pm"); if ( volumeName == "failed" || volumeName.empty() ) retry = retry; @@ -7839,7 +7839,7 @@ namespace oam std::string Oam::createEC2Volume(std::string size, std::string name) { // run script to get Volume Status - string cmd = InstallDir + "/bin/IDBVolumeCmds.sh create " + size + " > /tmp/createVolumeStatus_" + name; + string cmd = InstallDir + "/bin/IDBVolumeCmds.sh create " + size + " " + name + " > /tmp/createVolumeStatus_" + name; int ret = system(cmd.c_str()); if (WEXITSTATUS(ret) != 0 ) return "failed";