* usr/lib/byobu/ec2_cost: LP: #862655

- fix ec2 cost estimator on OpenStack instances by falling back to
    the approximation calculator
This commit is contained in:
Dustin Kirkland 2011-09-29 14:45:34 -04:00
commit c66cf1c25b
2 changed files with 8 additions and 2 deletions

4
debian/changelog vendored
View file

@ -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 <kirkland@ubuntu.com> Tue, 27 Sep 2011 10:59:05 -0400

View file

@ -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