From c66cf1c25bdc815262430993412c9e650a5a6d50 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Thu, 29 Sep 2011 14:45:34 -0400 Subject: [PATCH] * usr/lib/byobu/ec2_cost: LP: #862655 - fix ec2 cost estimator on OpenStack instances by falling back to the approximation calculator --- debian/changelog | 4 +++- usr/lib/byobu/ec2_cost | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 279c4d7a..a0cdbfd6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ byobu (4.37) unreleased; urgency=low - * UNRELEASED + * usr/lib/byobu/ec2_cost: LP: #862655 + - fix ec2 cost estimator on OpenStack instances by falling back to + the approximation calculator -- Dustin Kirkland Tue, 27 Sep 2011 10:59:05 -0400 diff --git a/usr/lib/byobu/ec2_cost b/usr/lib/byobu/ec2_cost index 74cfe6a8..31c9de4d 100755 --- a/usr/lib/byobu/ec2_cost +++ b/usr/lib/byobu/ec2_cost @@ -36,12 +36,16 @@ __ec2_cost() { # Try to use metadata service if metadata_available; then zone=$(wget -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone) + if [ ! -r "$BYOBU_PREFIX/share/$PKG/ec2/rates.${zone%?}" ]; then + zone="us-east-1d" + fi . "$BYOBU_PREFIX/share/$PKG/ec2/rates.${zone%?}" type=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-type | $SED -e "s/\./_/g") eval rate="\$$type" file_to_stat="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/ec2_cost.instance_type" [ -f "$file_to_stat" ] || wget -q -O "$file_to_stat" http://169.254.169.254/latest/meta-data/instance-type - else + fi + if [ -z "$rate" ]; then . "$BYOBU_PREFIX/share/$PKG/ec2/rates."* # Count CPUs, Memory, Architecture, hours cpu=$(grep -c "^processor.*:" /proc/cpuinfo) || cpu=1