Merge "fix for awscli in create_config"
This commit is contained in:
commit
c5f4ce8eda
|
@ -37,23 +37,30 @@ fi
|
|||
EC2_URL=`openstack endpoint list --service ec2 --interface public --os-identity-api-version=3 -c URL -f value`
|
||||
S3_URL=`openstack endpoint list --service s3 --interface public --os-identity-api-version=3 -c URL -f value`
|
||||
|
||||
# in some cases these packages can present in the system but don't work
|
||||
# reinstalling can help
|
||||
venv_dir="$(pwd)/.venv_awscli"
|
||||
virtualenv "$venv_dir"
|
||||
if [[ "$?" -ne "0" ]]; then
|
||||
die $LINENO "Can't setup virtual env."
|
||||
fi
|
||||
source "$venv_dir/bin/activate"
|
||||
pip install awscli
|
||||
if [[ "$?" -ne "0" ]]; then
|
||||
die $LINENO "Can't install awscli in virtual env."
|
||||
fi
|
||||
aws --version
|
||||
if [[ "$?" -ne "0" ]]; then
|
||||
sudo pip install awscli --upgrade
|
||||
aws --version
|
||||
if [[ "$?" -ne "0" ]]; then
|
||||
die $LINENO "Looks like awscli is not correctly installed."
|
||||
fi
|
||||
die $LINENO "awscli doesn't work correctly."
|
||||
fi
|
||||
deactivate
|
||||
|
||||
project_id=`openstack project show $OS_PROJECT_NAME -c id -f value`
|
||||
openstack ec2 credentials create 1>&2
|
||||
line=`openstack ec2 credentials list | grep " $project_id "`
|
||||
read ec2_access_key ec2_secret_key <<< `echo $line | awk '{print $2 " " $4 }'`
|
||||
source "$venv_dir/bin/activate"
|
||||
aws configure set aws_access_key_id $ec2_access_key --profile admin
|
||||
aws configure set aws_secret_access_key $ec2_secret_key --profile admin
|
||||
deactivate
|
||||
AWS_PARAMS="--region $REGION_NAME --endpoint-url $EC2_URL"
|
||||
|
||||
neutron_item=$(openstack service list | grep neutron)
|
||||
|
@ -68,7 +75,9 @@ wget -nv -P /tmp $CIRROS_IMAGE_URL &
|
|||
cirros_image_wget_pid=$!
|
||||
|
||||
# find simple image
|
||||
source "$venv_dir/bin/activate"
|
||||
image_id=`aws $AWS_PARAMS --profile admin ec2 describe-images --filters Name=image-type,Values=machine Name=name,Values=cirros* --query 'Images[0].ImageId' --output text`
|
||||
deactivate
|
||||
|
||||
if [[ "$image_id" == 'None' || -z "$image_id" ]]; then
|
||||
wait $cirros_image_wget_pid
|
||||
|
@ -77,7 +86,9 @@ if [[ "$image_id" == 'None' || -z "$image_id" ]]; then
|
|||
if [[ "$?" -ne "0" ]]; then
|
||||
echo "Creation of openstack image failed."
|
||||
fi
|
||||
source "$venv_dir/bin/activate"
|
||||
image_id=`aws $AWS_PARAMS --profile admin ec2 describe-images --filters Name=image-type,Values=machine Name=name,Values=cirros* --query 'Images[0].ImageId' --output text`
|
||||
deactivate
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -95,7 +106,9 @@ if [[ $RUN_LONG_TESTS == "1" ]]; then
|
|||
exit 1
|
||||
fi
|
||||
# find this image
|
||||
source "$venv_dir/bin/activate"
|
||||
image_id_ubuntu=`aws $AWS_PARAMS --profile admin ec2 describe-images --filters Name=image-type,Values=machine Name=name,Values=$REGULAR_IMAGE_NAME --query 'Images[0].ImageId' --output text`
|
||||
deactivate
|
||||
fi
|
||||
|
||||
# create separate user/project
|
||||
|
@ -129,8 +142,10 @@ fi
|
|||
openstack ec2 credentials create --user $user_id --project $project_id 1>&2
|
||||
line=`openstack ec2 credentials list --user $user_id | grep " $project_id "`
|
||||
read ec2_access_key ec2_secret_key <<< `echo $line | awk '{print $2 " " $4 }'`
|
||||
source "$venv_dir/bin/activate"
|
||||
aws configure set aws_access_key_id $ec2_access_key --profile user
|
||||
aws configure set aws_secret_access_key $ec2_secret_key --profile user
|
||||
deactivate
|
||||
|
||||
auth="--os-project-name $project_name --os-username $user_name --os-password password"
|
||||
|
||||
|
@ -189,7 +204,9 @@ if [[ -n "$openstack_image_id" ]]; then
|
|||
if [[ "$?" -ne "0" ]]; then
|
||||
die $LINENO "Image creation from instance fails"
|
||||
fi
|
||||
source "$venv_dir/bin/activate"
|
||||
ebs_image_id=`aws $AWS_PARAMS --profile user ec2 describe-images --filters Name=image-type,Values=machine Name=name,Values=$image_name --query 'Images[0].ImageId' --output text`
|
||||
deactivate
|
||||
nova $auth delete $instance_id
|
||||
fi
|
||||
|
||||
|
@ -245,7 +262,9 @@ if [[ "$?" -eq "0" && "$CA_CERT" && -e "$CA_CERT" ]]; then
|
|||
warn $LINENO "Bundling of image $CIRROS_IMAGE_URL failed."
|
||||
fi
|
||||
# next line is example how to register this image in the cloud
|
||||
#source "$venv_dir/bin/activate"
|
||||
#aws --endpoint-url $EC2_URL --region RegionOne --profile admin ec2 register-image --image-location "$AWS_AMI_BUCKET/$CIRROS_IMAGE_FNAME.manifest.xml" --name "$CIRROS_IMAGE_FNAME" --architecture x86_64
|
||||
#deactivate
|
||||
else
|
||||
warn $LINENO "Downloading of image $CIRROS_IMAGE_URL failed."
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue