From 71b456438c4d2d50ea4b3f19e0efd9f7a72f267f Mon Sep 17 00:00:00 2001 From: david hill Date: Tue, 1 Mar 2016 14:38:02 -0600 Subject: [PATCH 1/6] fix use of the amazon keys --- oam/cloud/IDBInstanceCmds.sh | 38 +-- oam/cloud/IDBVolumeCmds.sh | 21 +- oam/etc/Calpont.xml | 4 +- oam/etc/Calpont.xml.singleserver | 4 +- oam/etc/ConsoleCmds.xml | 22 +- oam/install_scripts/master-rep-infinidb.sh | 3 +- oamapps/calpontConsole/calpontConsole.cpp | 188 +------------ oamapps/postConfigure/postConfigure.cpp | 302 ++++----------------- procmgr/processmanager.cpp | 15 +- procmon/processmonitor.cpp | 1 + 10 files changed, 93 insertions(+), 505 deletions(-) diff --git a/oam/cloud/IDBInstanceCmds.sh b/oam/cloud/IDBInstanceCmds.sh index 31de657c4..2567c4695 100644 --- a/oam/cloud/IDBInstanceCmds.sh +++ b/oam/cloud/IDBInstanceCmds.sh @@ -109,9 +109,11 @@ export PATH=$path export EC2_HOME=$ec2 export JAVA_HOME=$java -# get x509 Certification and Private Key and region -x509Cert=`$prefix/Calpont/bin/getConfig Installation AmazonX509Certificate` -x509PriKey=`$prefix/Calpont/bin/getConfig Installation AmazonX509PrivateKey` +# get Keys and region +AmazonAccessKey=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` +AmazonSecretKey=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` +AmazonAccessKey=`cat $AmazonAccessKeyFile` +AmazonSecretKey=`cat $AmazonSecretKeyFile` Region=`$prefix/Calpont/bin/getConfig Installation AmazonRegion` subnet=`$prefix/Calpont/bin/getConfig Installation AmazonSubNetID` @@ -132,7 +134,7 @@ describeInstanceFile="/tmp/describeInstance.txt" touch $describeInstanceFile describeInstance() { - ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region > $describeInstanceFile 2>&1 + ec2-describe-instances -O $AmazonAccessKey -W $xAmazonSecretKey --region $Region > $describeInstanceFile 2>&1 } getInstance() { @@ -145,8 +147,6 @@ getInstance() { localIP=`ifconfig eth0 | grep "inet addr:" | awk '{print substr($2,6,20)}'` #get local Instance ID -# instance=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` - instance=`cat $describeInstanceFile | grep -m 1 $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` if [ "$instance" == "" ]; then describeInstance @@ -167,8 +167,6 @@ getInstancePrivate() { localIP=`ifconfig eth0 | grep "inet addr:" | awk '{print substr($2,6,20)}'` #get local Instance ID -# instance=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` - instance=`cat $describeInstanceFile | grep -m 1 $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` if [ "$instance" == "" ]; then describeInstance @@ -188,8 +186,6 @@ getZone() { getInstancePrivate >/dev/null 2>&1 #get zone if [ "$subnet" == "unassigned" ]; then -# zone=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'` - zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'` if [ "$zone" == "" ]; then describeInstance @@ -197,8 +193,6 @@ getZone() { zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'` else -# zone=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $10}'` - zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $10}'` if [ "$zone" == "" ]; then describeInstance @@ -214,8 +208,6 @@ getZone() { getPrivateIP() { #get instance info -# ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region $instanceName > /tmp/instanceInfo_$instanceName 2>&1 - grep -B1 -A4 -m 1 $instanceName $describeInstanceFile > /tmp/instanceInfo_$instanceName 2>&1 if [ `cat /tmp/instanceInfo_$instanceName | wc -c` -eq 0 ]; then describeInstance @@ -265,8 +257,6 @@ getType() { getInstancePrivate >/dev/null 2>&1 #get Type if [ "$subnet" == "unassigned" ]; then -# instanceType=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'` - instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'` if [ "$instanceType" == "" ]; then describeInstance @@ -274,8 +264,6 @@ getType() { instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'` else -# instanceType=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $8}'` - instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $8}'` if [ "$instanceType" == "" ]; then describeInstance @@ -293,8 +281,6 @@ getKey() { getInstancePrivate >/dev/null 2>&1 #get Key if [ "$subnet" == "unassigned" ]; then -# key=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'` - key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'` if [ "$key" == "" ]; then describeInstance @@ -302,8 +288,6 @@ getKey() { key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'` else -# key=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $6}'` - key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $6}'` if [ "$key" == "" ]; then describeInstance @@ -320,8 +304,6 @@ getAMI() { #get local Instance ID getInstancePrivate >/dev/null 2>&1 #get AMI -# ami=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $3}'` - ami=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $3}'` if [ "$ami" == "" ]; then describeInstance @@ -337,8 +319,6 @@ getGroup() { getInstancePrivate >/dev/null 2>&1 #get group if [ "$subnet" == "unassigned" ]; then -# group=`ec2-describe-instances -C $x509Cert -K $x509PriKey $instance --region $Region | grep -m 1 RESERVATION | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $4}'` - group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 RESERVATION | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $4}'` if [ "$group" == "" ]; then describeInstance @@ -348,8 +328,6 @@ getGroup() { group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $22}'` fi else -# group=`ec2-describe-instances -C $x509Cert -K $x509PriKey $instance --region $Region | grep -m 1 GROUP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` - group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 GROUP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` if [ "$group" == "" ]; then describeInstance @@ -366,8 +344,6 @@ getProfile() { getInstancePrivate >/dev/null 2>&1 #get Type if [ "$subnet" == "unassigned" ]; then -# instanceProfile=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $23}'` - instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $23}'` if [ "$instanceProfile" == "" ]; then describeInstance @@ -375,8 +351,6 @@ getProfile() { instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $23}'` else -# instanceProfile=`ec2-describe-instances -C $x509Cert -K $x509PriKey --region $Region | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $21}'` - instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $21}'` if [ "$instanceProfile" == "" ]; then describeInstance diff --git a/oam/cloud/IDBVolumeCmds.sh b/oam/cloud/IDBVolumeCmds.sh index 1ebd787e9..297c28e35 100644 --- a/oam/cloud/IDBVolumeCmds.sh +++ b/oam/cloud/IDBVolumeCmds.sh @@ -102,9 +102,12 @@ export PATH=$path export EC2_HOME=$ec2 export JAVA_HOME=$java -# get x509 Certification and Private Key -x509Cert=`$prefix/Calpont/bin/getConfig Installation AmazonX509Certificate` -x509PriKey=`$prefix/Calpont/bin/getConfig Installation AmazonX509PrivateKey` +# get Keys +AmazonAccessKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` +AmazonSecretKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` +AmazonAccessKey=`cat $AmazonAccessKeyFile` +AmazonSecretKey=`cat $AmazonSecretKeyFile` + Region=`$prefix/Calpont/bin/getConfig Installation AmazonRegion` if test ! -f $x509Cert ; then @@ -171,7 +174,7 @@ createvolume() { # get zone zone=`$prefix/Calpont/bin/IDBInstanceCmds.sh getZone` #create volume - volume=`ec2-create-volume -C $x509Cert -K $x509PriKey --region $Region -z $zone -s $volumeSize | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` + 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}'` @@ -181,7 +184,7 @@ createvolume() { describevolume() { #describe volume - ec2-describe-volumes -C $x509Cert -K $x509PriKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1 + ec2-describe-volumes -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1 checkInfostatus echo $STATUS @@ -190,7 +193,7 @@ describevolume() { detachvolume() { #detach volume - ec2-detach-volume -C $x509Cert -K $x509PriKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1 + ec2-detach-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1 checkInfostatus if [ $STATUS == "detaching" ]; then @@ -227,7 +230,7 @@ detachvolume() { attachvolume() { #detach volume - ec2-attach-volume -C $x509Cert -K $x509PriKey --region $Region $volumeName -i $instanceName -d $deviceName > /tmp/volumeInfo_$volumeName 2>&1 + 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 @@ -261,13 +264,13 @@ attachvolume() { deletevolume() { #delete volume - ec2-delete-volume -C $x509Cert -K $x509PriKey --region $Region $volumeName > /tmp/deletevolume_$volumeName 2>&1 + ec2-delete-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/deletevolume_$volumeName 2>&1 return } createTag() { #create tag - ec2-create-tags -C $x509Cert -K $x509PriKey --region $Region $resourceName --tag $tagName=$tagValue > /tmp/createTag_$volumeName 2>&1 + ec2-create-tags -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $resourceName --tag $tagName=$tagValue > /tmp/createTag_$volumeName 2>&1 return } diff --git a/oam/etc/Calpont.xml b/oam/etc/Calpont.xml index 15e4935ab..a94df4262 100755 --- a/oam/etc/Calpont.xml +++ b/oam/etc/Calpont.xml @@ -443,8 +443,8 @@ unassigned unassigned unassigned - unassigned - unassigned + unassigned + unassigned us-east-1 unassigned unassigned diff --git a/oam/etc/Calpont.xml.singleserver b/oam/etc/Calpont.xml.singleserver index 89bab523f..d716e6143 100644 --- a/oam/etc/Calpont.xml.singleserver +++ b/oam/etc/Calpont.xml.singleserver @@ -439,8 +439,8 @@ unassigned rpm y - unassigned - unassigned + unassigned + unassigned us-east-1 unassigned unassigned diff --git a/oam/etc/ConsoleCmds.xml b/oam/etc/ConsoleCmds.xml index 3e6829f86..f1d1d5bc6 100644 --- a/oam/etc/ConsoleCmds.xml +++ b/oam/etc/ConsoleCmds.xml @@ -256,30 +256,16 @@ Optional: Module-name and Parameter-name will display the Module Name Configuration parameter - addExternalDevice - Add External Device to Configuration file - External Devices will be monitored and alarms reported on failures - Required: External Device name - Required: External Device IP Address + AVAILABLE - getExternalDeviceConfig - Get External Device Configuration Information - Can display all External Device parameters or a single External Device - No Argument or 'all' will display all External Devices Configuration parameters - Optional: External Device name will display the Switch Name Configuration parameters + AVAILABLE - setExternalDeviceConfig - Set a External Device Configuration parameter - Required: External-device-name is the parameter to be updated - Required: Parameter-name is the parameter to be updated - Required: Parameter-value is the parameter value + AVAILABLE - removeExternalDevice - Remove External Device to Configuration file - Required: External Device name + AVAILABLE assignElasticIPAddress diff --git a/oam/install_scripts/master-rep-infinidb.sh b/oam/install_scripts/master-rep-infinidb.sh index f13466613..5c32b4e3d 100644 --- a/oam/install_scripts/master-rep-infinidb.sh +++ b/oam/install_scripts/master-rep-infinidb.sh @@ -49,7 +49,6 @@ echo "Create Replication User $repUser for node $hostipaddr" >>/tmp/master-rep-s cat >/tmp/idb_master-rep.sql <>/tmp/master-rep-status-$hostipaddr.log @@ -66,7 +65,7 @@ checkForError echo "Grant table access for $repUser for node $hostipaddr" >>/tmp/master-rep-status-$hostipaddr.log cat >/tmp/idb_master-rep.sql <getConfig(InstallSection, "AmazonX509Certificate"); - x509PriKey = sysConfig->getConfig(InstallSection, "AmazonX509PrivateKey"); + AmazonAccessKey = sysConfig->getConfig(InstallSection, "AmazonAccessKey"); + AmazonSecretKey = sysConfig->getConfig(InstallSection, "AmazonSecretKey"); } catch(...) {} @@ -1016,13 +1016,13 @@ int main(int argc, char *argv[]) while(true) { - prompt = "Enter Name and directory of the X.509 Certificate (" + x509Cert + ") > "; + prompt = "Enter file name containing the Access Key (" + AmazonAccessKey + ") > "; pcommand = callReadline(prompt.c_str()); if (pcommand) { - if (strlen(pcommand) > 0) x509Cert = pcommand; + if (strlen(pcommand) > 0) AmazonAccessKey = pcommand; callFree(pcommand); } - ifstream File (x509Cert.c_str()); + ifstream File (AmazonAccessKey.c_str()); if (!File) { cout << "Error: file not found, please re-enter" << endl; if ( noPrompting ) @@ -1034,13 +1034,13 @@ int main(int argc, char *argv[]) while(true) { - prompt = "Enter Name and directory of the X.509 Private Key (" + x509PriKey + ") > "; + prompt = "Enter file name containing the Secret Key (" + AmazonSecretKey + ") > "; pcommand = callReadline(prompt.c_str()); if (pcommand) { - if (strlen(pcommand) > 0) x509PriKey = pcommand; + if (strlen(pcommand) > 0) AmazonSecretKey = pcommand; callFree(pcommand); } - ifstream File (x509PriKey.c_str()); + ifstream File (AmazonSecretKey.c_str()); if (!File) { cout << "Error: file not found, please re-enter" << endl; @@ -1052,15 +1052,40 @@ int main(int argc, char *argv[]) } try { - sysConfig->setConfig(InstallSection, "AmazonX509Certificate", x509Cert); - sysConfig->setConfig(InstallSection, "AmazonX509PrivateKey", x509PriKey); + sysConfig->setConfig(InstallSection, "AmazonAccessKey", AmazonAccessKey); + sysConfig->setConfig(InstallSection, "AmazonSecretKey", AmazonSecretKey); } catch(...) {} - if( !copyX509files() ) - cout << "copyX509files error" << endl; + if( !copyKeyfiles() ) + cout << "copyKeyfiles error" << endl; + + try { + AmazonRegion = sysConfig->getConfig(InstallSection, "AmazonRegion"); + } + catch(...) + {} + cout << endl; + + while(true) + { + prompt = "Enter Amazon Region you are running in (" + AmazonRegion + ") > "; + pcommand = callReadline(prompt.c_str()); + if (pcommand) { + if (strlen(pcommand) > 0) AmazonRegion = pcommand; + callFree(pcommand); + } + break; + } + + try { + sysConfig->setConfig(InstallSection, "AmazonRegion", AmazonRegion); + } + catch(...) + {} + break; } } @@ -2552,239 +2577,6 @@ int main(int argc, char *argv[]) //check snmp Apps disable option snmpAppCheck(); - // - // Configure External Devices - // - SystemExtDeviceConfig systemextdeviceconfig; - - try{ - oam.getSystemConfig(systemextdeviceconfig); - } - catch(...) - { - cout << "ERROR: Problem reading the InfiniDB System Configuration file" << endl; - exit(1); - } - - cout << endl << "===== Setup the External Device Configuration =====" << endl << endl; - - cout << "External Devices are devices like a storage array or a Ethernet Switch that can" << endl; - cout << "be setup to be monitored by InfiniDB with a ping test. If device fails, InfiniDB" << endl; - cout << "will report a failure alarm." << endl << endl; - - if ( systemextdeviceconfig.Count > 0 ) { - - cout << "Current List of External Devices being monitored" << endl << endl; - - cout << "Device Name IP Address" << endl; - cout << "-------------------------- ----------------" << endl; - - for ( unsigned int i = 0 ; i < systemextdeviceconfig.Count ; i++ ) - { - cout.setf(ios::left); - cout.width(30); - cout << systemextdeviceconfig.extdeviceconfig[i].Name; - cout << systemextdeviceconfig.extdeviceconfig[i].IPAddr << endl; -// cout << "Device Name: " << (*pt1).Name << " IP Address: " << (*pt1).IPAddr << endl; - } - - cout << endl; - - string modify = "n"; - while(true) { - prompt = "Would you like to modify current list? [y,n] (n) > "; - pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) modify = pcommand; - callFree(pcommand); - } - if ( modify == "y" || modify == "n" ) - break; - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; - if ( noPrompting ) - exit(1); - } - - if ( modify == "y" ) { - - for ( unsigned int i = 0 ; i < systemextdeviceconfig.Count ; i++ ) - { - string name = systemextdeviceconfig.extdeviceconfig[i].Name; - modify = "n"; - while(true) { - prompt = "Would you like to modify or delete '" + name + "'? [m,d,n] (n) > "; - pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) modify = pcommand; - callFree(pcommand); - } - if ( modify == "m" || modify == "d" || modify == "n") - break; - cout << "Invalid Entry, please enter 'm' for modify, 'd' for delete or 'n' for no" << endl; - if ( noPrompting ) - exit(1); - } - - if ( modify == "d" ) { - // delete device - ExtDeviceConfig extdeviceconfig; - - extdeviceconfig.Name = oam::UnassignedName; - extdeviceconfig.IPAddr = oam::UnassignedIpAddr; - extdeviceconfig.DisableState = oam::ENABLEDSTATE; - - try{ - oam.setSystemConfig(name, extdeviceconfig); - } - catch(...) - { - cout << "ERROR: Problem updating the InfiniDB System Configuration file" << endl; - exit(1); - } - cout << "External Device '" + name + "' deleted" << endl << endl; - } - else - { - if ( modify == "m" ) { - string newName = name; - prompt = "Enter Name (" + newName + ") > "; - pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) newName = pcommand; - callFree(pcommand); - } - - string newIPAddr = systemextdeviceconfig.extdeviceconfig[i].IPAddr; - while (true) - { - prompt = "Enter IP Address of (" + newIPAddr + ") > "; - pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) newIPAddr = pcommand; - callFree(pcommand); - } - - if (oam.isValidIP(newIPAddr)) - break; - else - { - cout << "Invalid IP Address format, xxx.xxx.xxx.xxx, please re-enter" << endl; - if ( noPrompting ) - exit(1); - } - } - - ExtDeviceConfig extdeviceconfig; - - extdeviceconfig.Name = newName; - extdeviceconfig.IPAddr = newIPAddr; - extdeviceconfig.DisableState = oam::ENABLEDSTATE; - - try{ - oam.setSystemConfig(name, extdeviceconfig); - } - catch(...) - { - cout << "ERROR: Problem updating the InfiniDB System Configuration file" << endl; - exit(1); - } - cout << "External Device '" + name + "' modified" << endl << endl; - } - } - } - } - } - - while(true) { - string add = "n"; - while(true) { - prompt = "Would you like to add an External Device? [y,n] (n) > "; - pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) add = pcommand; - callFree(pcommand); - } - if ( add == "y" || add == "n" ) - break; - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; - if ( noPrompting ) - exit(1); - } - - if ( add == "y" ) { - cout << endl; - string newName = oam::UnassignedName; - while(true) { - prompt = "Enter Name (" + newName + ") > "; - pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) newName = pcommand; - callFree(pcommand); - } - - if ( newName == oam::UnassignedName ) { - cout << "Invalid Entry, please enter valid name or 'abort'" << endl; - if ( noPrompting ) - exit(1); - } - else - break; - } - - if ( newName == "abort" ) - continue; - - //get Network IP Address - string newIPAddr = oam::UnassignedIpAddr; - string IPAddress = oam.getIPAddress(newName); - if ( !IPAddress.empty() ) - newIPAddr = IPAddress; - - while (true) - { - prompt = "Enter IP Address of (" + newIPAddr + ") > "; - pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) newIPAddr = pcommand; - callFree(pcommand); - } - - if (oam.isValidIP(newIPAddr)) - break; - else - cout << "Invalid IP Address format, xxx.xxx.xxx.xxx, please re-enter" << endl; - if ( noPrompting ) - exit(1); - newIPAddr = oam::UnassignedIpAddr; - } - - ExtDeviceConfig extdeviceconfig; - - extdeviceconfig.Name = newName; - extdeviceconfig.IPAddr = newIPAddr; - extdeviceconfig.DisableState = oam::ENABLEDSTATE; - - try{ - oam.setSystemConfig(newName, extdeviceconfig); - } - catch(...) - { - cout << "ERROR: Problem updating the InfiniDB System Configuration file" << endl; - exit(1); - } - cout << endl; - } - else - break; - } - //setup local OS Files if( !setOSFiles(parentOAMModuleName, IserverTypeInstall) ) { cout << "setOSFiles error" << endl; @@ -5031,12 +4823,12 @@ bool copyFstab(string moduleName) /* * Copy x.509 file */ -bool copyX509files() +bool copyKeyfiles() { - string cmd = "/bin/cp -f " + x509Cert + " " + installDir + "/local/etc/. > /dev/null 2>&1"; + string cmd = "/bin/cp -f " + AmazonAccessKey + " " + installDir + "/local/etc/. > /dev/null 2>&1"; system(cmd.c_str()); - cmd = "/bin/cp -f " + x509PriKey + " " + installDir + "/local/etc/. > /dev/null 2>&1"; + cmd = "/bin/cp -f " + AmazonSecretKey + " " + installDir + "/local/etc/. > /dev/null 2>&1"; system(cmd.c_str()); return true; diff --git a/procmgr/processmanager.cpp b/procmgr/processmanager.cpp index 01129206b..66bc8d247 100644 --- a/procmgr/processmanager.cpp +++ b/procmgr/processmanager.cpp @@ -10069,7 +10069,20 @@ int ProcessManager::setMySQLReplication(oam::DeviceNetworkList devicenetworklist if ( moduleType == "pm" && PMwithUM == "n" ) continue; } - + + //check status, skip if module is offline + int opState = oam::ACTIVE; + bool degraded; + try { + oam.getModuleStatus(remoteModuleName, opState, degraded); + } + catch(...) + { + } + + if (opState != oam::ACTIVE) + continue; + ByteStream msg1; ByteStream::byte requestID = oam::SLAVEREP; if ( !enable ) { diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index 2553030f4..7e86bf03e 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -843,6 +843,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO //stop the mysql daemon try { oam.actionMysqlCalpont(MYSQL_STOP); + log.writeLog(__LINE__, "Stop MySQL Process", LOG_TYPE_DEBUG); } catch(...) {} From f38cfc6480fe8ba7fa6c399654e4ad3c7f114871 Mon Sep 17 00:00:00 2001 From: david hill Date: Tue, 1 Mar 2016 14:41:47 -0600 Subject: [PATCH 2/6] fix use of the amazon keys --- oamapps/postConfigure/postConfigure.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index 0e87e2f21..1380c1b12 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -147,6 +147,7 @@ string reuseConfig ="n"; string oldFileName; string AmazonAccessKey; string AmazonSecretKey; +string AmazonRegion; string glusterCopies; string glusterInstalled = "n"; string hadoopInstalled = "n"; From 92bf40fcbbdfabc35529e00bbdf5edae2e2627bf Mon Sep 17 00:00:00 2001 From: david hill Date: Wed, 2 Mar 2016 14:27:29 -0600 Subject: [PATCH 3/6] change amazon failover logic, make work like normal system --- oam/cloud/IDBInstanceCmds.sh | 2 +- oam/cloud/IDBVolumeCmds.sh | 10 ++--- oamapps/postConfigure/postConfigure.cpp | 56 ++----------------------- procmgr/main.cpp | 23 +++++----- procmgr/processmanager.cpp | 13 +++--- tools/configMgt/autoConfigure.cpp | 26 ++++++++++-- 6 files changed, 47 insertions(+), 83 deletions(-) diff --git a/oam/cloud/IDBInstanceCmds.sh b/oam/cloud/IDBInstanceCmds.sh index 2567c4695..6fc5ef168 100644 --- a/oam/cloud/IDBInstanceCmds.sh +++ b/oam/cloud/IDBInstanceCmds.sh @@ -134,7 +134,7 @@ describeInstanceFile="/tmp/describeInstance.txt" touch $describeInstanceFile describeInstance() { - ec2-describe-instances -O $AmazonAccessKey -W $xAmazonSecretKey --region $Region > $describeInstanceFile 2>&1 + ec2-describe-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region > $describeInstanceFile 2>&1 } getInstance() { diff --git a/oam/cloud/IDBVolumeCmds.sh b/oam/cloud/IDBVolumeCmds.sh index 297c28e35..cb06cf917 100644 --- a/oam/cloud/IDBVolumeCmds.sh +++ b/oam/cloud/IDBVolumeCmds.sh @@ -110,13 +110,13 @@ AmazonSecretKey=`cat $AmazonSecretKeyFile` Region=`$prefix/Calpont/bin/getConfig Installation AmazonRegion` -if test ! -f $x509Cert ; then - echo "FAILED: missing x509Cert : $x509Cert" +if test ! -f $AmazonAccessKeyFile ; then + echo "FAILED: missing AmazonAccessKeyFile : $AmazonAccessKeyFile" exit 1 fi -if test ! -f $x509PriKey ; then - echo "FAILED: missing x509PriKey : $x509PriKey" +if test ! -f $xAmazonSecretKeyFile ; then + echo "FAILED: missing AmazonSecretKeyFile : $xAmazonSecretKeyFile" exit 1 fi @@ -200,7 +200,7 @@ detachvolume() { retries=1 while [ $retries -ne 60 ]; do #retry until it's attached - ec2-detach-volume -C $x509Cert -K $x509PriKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1 + ec2-detach-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1 checkInfostatus if [ $STATUS == "available" ]; then diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index 1380c1b12..f0912ca9a 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -2132,7 +2132,7 @@ int main(int argc, char *argv[]) catch(...) {} - prompt = "Enter Volume Name assigned to module '" + newModuleName + "' (" + volumeName + ") > "; + prompt = "Enter Volume ID assigned to module '" + newModuleName + "' (" + volumeName + ") > "; pcommand = callReadline(prompt.c_str()); if (pcommand) { @@ -2140,7 +2140,7 @@ int main(int argc, char *argv[]) callFree(pcommand); } - prompt = "Enter Device Name assigned to module '" + newModuleName + "' (" + deviceName + ") > "; + prompt = "Enter Device Name (/dev/sdxx) '" + newModuleName + "' (" + deviceName + ") > "; pcommand = callReadline(prompt.c_str()); if (pcommand) { @@ -2409,7 +2409,7 @@ int main(int argc, char *argv[]) catch(...) {} - prompt = "Enter Volume Name assigned to '" + DBrootID + "' (" + volumeName + ") > "; + prompt = "Enter Volume ID for '" + DBrootID + "' (" + volumeName + ") > "; pcommand = callReadline(prompt.c_str()); if (pcommand) { @@ -2425,7 +2425,7 @@ int main(int argc, char *argv[]) catch(...) {} - prompt = "Enter Device Name for volume '" + volumeName + "' (" + deviceName + ") > "; + prompt = "Enter Device Name (/dev/sdxx) for volume '" + volumeName + "' (" + deviceName + ") > "; pcommand = callReadline(prompt.c_str()); if (pcommand) { @@ -4582,54 +4582,6 @@ bool storageSetup(string cloud) } } - - if( DBRootStorageType == "external" && cloud == "amazon" ) - { //set AmazonPMFailover - - string AmazonPMFailover = "y"; - - try { - AmazonPMFailover = sysConfig->getConfig(InstallSection, "AmazonPMFailover"); - } - catch(...) - {} - - cout << endl; - while(true) - { - pcommand = callReadline("Do you want to enable Instance failover support? [y,n] (" + AmazonPMFailover + ") > "); - if (pcommand) - { - if (strlen(pcommand) > 0) AmazonPMFailover = pcommand; - callFree(pcommand); - } - - if ( AmazonPMFailover == "y" || AmazonPMFailover == "n" ) { - cout << endl; - break; - } - else - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; - if ( noPrompting ) - exit(1); - } - - try { - sysConfig->setConfig(InstallSection, "AmazonPMFailover", AmazonPMFailover); - } - catch(...) - {} - } - - if( DBRootStorageType == "internal" && cloud == "amazon" ) - { //set AmazonPMFailover - try { - sysConfig->setConfig(InstallSection, "AmazonPMFailover", "n"); - } - catch(...) - {} - } - if ( !writeConfig(sysConfig) ) { cout << "ERROR: Failed trying to update InfiniDB System Configuration file" << endl; return false; diff --git a/procmgr/main.cpp b/procmgr/main.cpp index c588c4df2..630f97a73 100644 --- a/procmgr/main.cpp +++ b/procmgr/main.cpp @@ -49,7 +49,6 @@ string cloud; bool amazon = false; string PMInstanceType; string UMInstanceType; -string AmazonPMFailover = "y"; string GlusterConfig = "n"; bool rootUser = true; string USER = "root"; @@ -144,7 +143,6 @@ int main(int argc, char **argv) { oam.getSystemConfig("PMInstanceType", PMInstanceType); oam.getSystemConfig("UMInstanceType", UMInstanceType); - oam.getSystemConfig("AmazonPMFailover", AmazonPMFailover); amazon = true; } @@ -1281,9 +1279,8 @@ void pingDeviceThread() int status; // if pm, move dbroots back to pm - if ( ( moduleName.find("pm") == 0 && !amazon ) || - ( moduleName.find("pm") == 0 && amazon && downActiveOAMModule ) || - ( moduleName.find("pm") == 0 && amazon && AmazonPMFailover == "y") ) { + if ( ( moduleName.find("pm") == 0 ) || + ( moduleName.find("pm") == 0 && downActiveOAMModule ) ) { //restart to get the versionbuffer files closed so it can be unmounted processManager.restartProcessType("WriteEngineServer", moduleName); @@ -1559,8 +1556,8 @@ void pingDeviceThread() aManager.sendAlarmReport(moduleName.c_str(), MODULE_DOWN_AUTO, SET); // if pm, move dbroots back to pm - if ( ( moduleName.find("pm") == 0 && !amazon ) || - ( moduleName.find("pm") == 0 && amazon && downActiveOAMModule ) ) { + if ( ( moduleName.find("pm") == 0 ) || + ( moduleName.find("pm") == 0 && downActiveOAMModule ) ) { //move dbroots to other modules try { log.writeLog(__LINE__, "Call autoMovePmDbroot", LOG_TYPE_DEBUG); @@ -1593,9 +1590,9 @@ void pingDeviceThread() log.writeLog(__LINE__, "Module failed to auto start: " + moduleName, LOG_TYPE_CRITICAL); - if ( amazon ) - processManager.setSystemState(oam::FAILED); - else +// if ( amazon ) +// processManager.setSystemState(oam::FAILED); +// else processManager.setSystemState(oam::ACTIVE); //set query system state ready @@ -1663,8 +1660,8 @@ void pingDeviceThread() log.writeLog(__LINE__, "'dbrmctl reload' done", LOG_TYPE_DEBUG); // if pm, move dbroots to other pms - if ( !amazon || - ( amazon && AmazonPMFailover == "y") ) { +// if ( !amazon || +// ( amazon ) ) { if( moduleName.find("pm") == 0 ) { try { log.writeLog(__LINE__, "Call autoMovePmDbroot", LOG_TYPE_DEBUG); @@ -1683,7 +1680,7 @@ void pingDeviceThread() log.writeLog(__LINE__, "EXCEPTION ERROR on autoMovePmDbroot: Caught unknown exception!", LOG_TYPE_ERROR); } } - } +// } // if Cloud Instance // state = running, then instance is rebooting, monitor for recovery diff --git a/procmgr/processmanager.cpp b/procmgr/processmanager.cpp index 66bc8d247..e77b651ea 100644 --- a/procmgr/processmanager.cpp +++ b/procmgr/processmanager.cpp @@ -53,7 +53,6 @@ extern string USER; extern bool HDFS; extern string localHostName; extern string PMwithUM; -extern string AmazonPMFailover; typedef map moduleList; extern moduleList moduleInfoList; @@ -8626,7 +8625,7 @@ int ProcessManager::OAMParentModuleChange() noAckCount = 0; //if Amazon Parent PM is restarting, monitor when back active and take needed actions - if (amazonParentRestart) +/* if (amazonParentRestart) { log.writeLog(__LINE__, "Amazon Parent pinging, waiting until it's active", LOG_TYPE_DEBUG); sleep(60); @@ -8659,7 +8658,7 @@ int ProcessManager::OAMParentModuleChange() sleep(5); } } - +*/ sleep(1); break; } @@ -8837,7 +8836,7 @@ int ProcessManager::OAMParentModuleChange() {} //do amazon failover - if (amazon && AmazonPMFailover == "n") +/* if (amazon && AmazonPMFailover == "n") { log.writeLog(__LINE__, " ", LOG_TYPE_DEBUG); log.writeLog(__LINE__, "*** OAMParentModule outage, AmazonPMFailover not set, wating for instance to restart ***", LOG_TYPE_DEBUG); @@ -8912,7 +8911,7 @@ int ProcessManager::OAMParentModuleChange() //clear and go monitor again failover = false; - } + }*/ } } @@ -9187,9 +9186,7 @@ int ProcessManager::OAMParentModuleChange() } //restart DDLProc/DMLProc to perform any rollbacks, if needed - //dont rollback in amazon, wait until down pm recovers - if ( ( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM ) - && !amazon ) { + if ( ( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM ) ) { processManager.restartProcessType("DDLProc", config.moduleName()); sleep(1); processManager.restartProcessType("DMLProc", config.moduleName()); diff --git a/tools/configMgt/autoConfigure.cpp b/tools/configMgt/autoConfigure.cpp index 5afe2d68a..dd3981a00 100644 --- a/tools/configMgt/autoConfigure.cpp +++ b/tools/configMgt/autoConfigure.cpp @@ -1806,16 +1806,34 @@ int main(int argc, char *argv[]) {} try { - string AmazonPMFailover = sysConfigOld->getConfig("Installation", "AmazonPMFailover"); + string AmazonAccessKey = sysConfigOld->getConfig("Installation", "AmazonAccessKey"); - if ( !AmazonPMFailover.empty() ) + if ( !AmazonAccessKey.empty() ) { try { - sysConfigNew->setConfig("Installation", "AmazonPMFailover", AmazonPMFailover); + sysConfigNew->setConfig("Installation", "AmazonAccessKey", AmazonAccessKey); } catch(...) { - cout << "ERROR: Problem setting AmazonPMFailover in the Calpont System Configuration file" << endl; + cout << "ERROR: Problem setting AmazonAccessKey in the Calpont System Configuration file" << endl; + exit(-1); + } + } + } + catch(...) + {} + + try { + string AmazonSecretKey = sysConfigOld->getConfig("Installation", "AmazonSecretKey"); + + if ( !AmazonAccessKey.empty() ) + { + try { + sysConfigNew->setConfig("Installation", "AmazonSecretKey", AmazonSecretKey); + } + catch(...) + { + cout << "ERROR: Problem setting AmazonSecretKey in the Calpont System Configuration file" << endl; exit(-1); } } From 50429d6e850c42e8607124d067bcdf519ab8fa92 Mon Sep 17 00:00:00 2001 From: david hill Date: Wed, 2 Mar 2016 14:30:44 -0600 Subject: [PATCH 4/6] change amazon failover logic, make work like normal system --- tools/configMgt/autoConfigure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/configMgt/autoConfigure.cpp b/tools/configMgt/autoConfigure.cpp index dd3981a00..640d6c928 100644 --- a/tools/configMgt/autoConfigure.cpp +++ b/tools/configMgt/autoConfigure.cpp @@ -1826,7 +1826,7 @@ int main(int argc, char *argv[]) try { string AmazonSecretKey = sysConfigOld->getConfig("Installation", "AmazonSecretKey"); - if ( !AmazonAccessKey.empty() ) + if ( !AmazonSecretKey.empty() ) { try { sysConfigNew->setConfig("Installation", "AmazonSecretKey", AmazonSecretKey); From e44fdcb104fd4cb0e5b5dbf53b8a401fecff1c89 Mon Sep 17 00:00:00 2001 From: david hill Date: Wed, 2 Mar 2016 17:23:07 -0600 Subject: [PATCH 5/6] fix key parms --- oam/cloud/IDBInstanceCmds.sh | 42 ++++++++++++++++++------------------ oam/cloud/IDBVolumeCmds.sh | 15 ++++++------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/oam/cloud/IDBInstanceCmds.sh b/oam/cloud/IDBInstanceCmds.sh index 6fc5ef168..24bd5ec8d 100644 --- a/oam/cloud/IDBInstanceCmds.sh +++ b/oam/cloud/IDBInstanceCmds.sh @@ -110,20 +110,20 @@ export EC2_HOME=$ec2 export JAVA_HOME=$java # get Keys and region -AmazonAccessKey=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` -AmazonSecretKey=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` +AmazonAccessKeyfile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` +AmazonSecretKeyfile=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` AmazonAccessKey=`cat $AmazonAccessKeyFile` AmazonSecretKey=`cat $AmazonSecretKeyFile` Region=`$prefix/Calpont/bin/getConfig Installation AmazonRegion` subnet=`$prefix/Calpont/bin/getConfig Installation AmazonSubNetID` -if test ! -f $x509Cert ; then - echo "FAILED: missing x509Cert : $x509Cert" +if test ! -f $AmazonAccessKeyfile ; then + echo "FAILED: missing AmazonAccessKeyfile : $AmazonAccessKeyfile" exit 1 fi -if test ! -f $x509PriKey ; then - echo "FAILED: missing x509PriKey : $x509PriKey" +if test ! -f $AmazonSecretKeyfile ; then + echo "FAILED: missing AmazonSecretKeyfile : $AmazonSecretKeyfile" exit 1 fi @@ -384,37 +384,37 @@ launchInstance() { if [ "$subnet" == "unassigned" ]; then #NOT VPC if [ "$instanceProfile" = "" ] || [ "$instanceProfile" = "default" ]; then - newInstance=`ec2-run-instances -C $x509Cert -K $x509PriKey -k $key -g $group -t $instanceType -z $zone --region $Region $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` + 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 -C $x509Cert -K $x509PriKey -k $key -g $group -t $instanceType -z $zone -p $instanceProfile --region $Region $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` + 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 -C $x509Cert -K $x509PriKey -k $key -g $group -t $instanceType -z $zone --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` + 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 -C $x509Cert -K $x509PriKey -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}'` + 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 -C $x509Cert -K $x509PriKey -k $key -t $instanceType -z $zone --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` + 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 -C $x509Cert -K $x509PriKey -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}'` + 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 -C $x509Cert -K $x509PriKey -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}'` + 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 -C $x509Cert -K $x509PriKey -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}'` + 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 -C $x509Cert -K $x509PriKey -k $key -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'` + 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 -C $x509Cert -K $x509PriKey -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}'` + 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 @@ -425,19 +425,19 @@ launchInstance() { terminateInstance() { #terminate Instance - ec2-terminate-instances -C $x509Cert -K $x509PriKey --region $Region $instanceName > /tmp/termInstanceInfo_$instanceName 2>&1 + ec2-terminate-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $instanceName > /tmp/termInstanceInfo_$instanceName 2>&1 return } stopInstance() { #terminate Instance - ec2-stop-instances -C $x509Cert -K $x509PriKey --region $Region $instanceName > /tmp/stopInstanceInfo_$instanceName 2>&1 + ec2-stop-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $instanceName > /tmp/stopInstanceInfo_$instanceName 2>&1 return } startInstance() { #terminate Instance - ec2-start-instances -C $x509Cert -K $x509PriKey --region $Region $instanceName > /tmp/startInstanceInfo_$instanceName 2>&1 + 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 @@ -450,7 +450,7 @@ startInstance() { assignElasticIP() { #terminate Instance - ec2-associate-address -C $x509Cert -K $x509PriKey -i $instanceName $IPAddress > /tmp/assignElasticIPInfo_$IPAddress 2>&1 + ec2-associate-address -O $AmazonAccessKey -W $AmazonSecretKey -i $instanceName $IPAddress > /tmp/assignElasticIPInfo_$IPAddress 2>&1 cat /tmp/assignElasticIPInfo_$IPAddress | grep ADDRESS > /tmp/assignElasticIPStatus_$IPAddress if [ `cat /tmp/assignElasticIPStatus_$IPAddress | wc -c` -eq 0 ]; then @@ -464,7 +464,7 @@ assignElasticIP() { deassignElasticIP() { #terminate Instance - ec2-disassociate-address -C $x509Cert -K $x509PriKey $IPAddress > /tmp/deassignElasticIPInfo_$IPAddress 2>&1 + 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 diff --git a/oam/cloud/IDBVolumeCmds.sh b/oam/cloud/IDBVolumeCmds.sh index cb06cf917..ec3a153b8 100644 --- a/oam/cloud/IDBVolumeCmds.sh +++ b/oam/cloud/IDBVolumeCmds.sh @@ -102,21 +102,20 @@ export PATH=$path export EC2_HOME=$ec2 export JAVA_HOME=$java -# get Keys -AmazonAccessKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` -AmazonSecretKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` +# get Keys and region +AmazonAccessKeyfile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` +AmazonSecretKeyfile=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` AmazonAccessKey=`cat $AmazonAccessKeyFile` AmazonSecretKey=`cat $AmazonSecretKeyFile` - Region=`$prefix/Calpont/bin/getConfig Installation AmazonRegion` -if test ! -f $AmazonAccessKeyFile ; then - echo "FAILED: missing AmazonAccessKeyFile : $AmazonAccessKeyFile" +if test ! -f $AmazonAccessKeyfile ; then + echo "FAILED: missing AmazonAccessKeyfile : $AmazonAccessKeyfile" exit 1 fi -if test ! -f $xAmazonSecretKeyFile ; then - echo "FAILED: missing AmazonSecretKeyFile : $xAmazonSecretKeyFile" +if test ! -f $AmazonSecretKeyfile ; then + echo "FAILED: missing AmazonSecretKeyfile : $AmazonSecretKeyfile" exit 1 fi From 5fda1c1c5fe2bcd13d9f3d2eded846fc2823ab99 Mon Sep 17 00:00:00 2001 From: david hill Date: Thu, 3 Mar 2016 09:58:03 -0600 Subject: [PATCH 6/6] update cloud scripts --- oam/cloud/IDBInstanceCmds.sh | 4 ++-- oam/cloud/IDBVolumeCmds.sh | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/oam/cloud/IDBInstanceCmds.sh b/oam/cloud/IDBInstanceCmds.sh index 24bd5ec8d..2b3995de3 100644 --- a/oam/cloud/IDBInstanceCmds.sh +++ b/oam/cloud/IDBInstanceCmds.sh @@ -110,8 +110,8 @@ export EC2_HOME=$ec2 export JAVA_HOME=$java # get Keys and region -AmazonAccessKeyfile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` -AmazonSecretKeyfile=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` +AmazonAccessKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` +AmazonSecretKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` AmazonAccessKey=`cat $AmazonAccessKeyFile` AmazonSecretKey=`cat $AmazonSecretKeyFile` Region=`$prefix/Calpont/bin/getConfig Installation AmazonRegion` diff --git a/oam/cloud/IDBVolumeCmds.sh b/oam/cloud/IDBVolumeCmds.sh index ec3a153b8..ecb5721db 100644 --- a/oam/cloud/IDBVolumeCmds.sh +++ b/oam/cloud/IDBVolumeCmds.sh @@ -103,10 +103,11 @@ export EC2_HOME=$ec2 export JAVA_HOME=$java # get Keys and region -AmazonAccessKeyfile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` -AmazonSecretKeyfile=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` +AmazonAccessKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonAccessKey` +AmazonSecretKeyFile=`$prefix/Calpont/bin/getConfig Installation AmazonSecretKey` AmazonAccessKey=`cat $AmazonAccessKeyFile` AmazonSecretKey=`cat $AmazonSecretKeyFile` + Region=`$prefix/Calpont/bin/getConfig Installation AmazonRegion` if test ! -f $AmazonAccessKeyfile ; then