usharesoft / hammr

Command-line tool for building consistent and repeatable machine images for multiple cloud platforms
http://hammr.io
Apache License 2.0
28 stars 24 forks source link

The display of "hammr quota list" collapses when disk usage "Consumed > Limit" #468

Open ghost opened 5 years ago

ghost commented 5 years ago

Hello,

Environment

Steps to reproduce

ghost commented 5 years ago

The bug seems to be in the file hammr/commands/quota/quota.py, on the line 69 when we run the command: ascii_bar_graph.print_graph(values)

We have 2 choices:

  1. On the if...else from 62 to 67, we should add an elsif and if the (nb/limit) * 50 > 50, we should set values = 50 whatever the real value is.
  2. I don't have access to the ascii_bar_graph.print_graph() but maybe add an if..else to check the input value and stop drawing pipe when we reach the limit.
locobastos commented 5 years ago

In the file: hammr/commands/quota/quota.py

  1. On the lines 62 to 67, change
    if quota.limit != -1:
    nb = float(quota.nb)
    limit = float(quota.limit)
    values[text] = (nb/limit) * 50
    else:
    values[text] = -1

    to

    if quota.limit != -1:
    nb = float(quota.nb)
    limit = float(quota.limit)
    value = (nb/limit) * 50
    if value >= 50:
        values[text] = 50
    then:
        values[text] = value
    else:
    values[text] = -1

Here the result:

Getting quotas for [bastien.martin] ...
Generations (2)    --------------------UNLIMITED---------------------
Scan (1)           --------------------UNLIMITED---------------------
Disk usage (4G/3G) ||||||||||||||||||||||||||||||||||||||||||||||||||
Templates (2)      --------------------UNLIMITED---------------------