Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed show-usage to aggregate raw usage records. Created show-all-u…

…sage for previous show-usage behavior.
  • Loading branch information...
commit 9d29529248660503589d5355da446c490cc97678 1 parent 9a27313
@calebgroom authored
Showing with 44 additions and 3 deletions.
  1. +14 −1 README.rst
  2. +30 −2 bin/clb
View
15 README.rst
@@ -122,7 +122,20 @@ List load balancer details::
List load balancer usage::
- $ clb show-usage mylb
+ $ clb show-usage mylb
+ +--------------------------+---------------------+
+ | Field | Value |
+ +--------------------------+---------------------+
+ | VIP Type: | PUBLIC |
+ | Start Time | 2011-11-01 05:02:25 |
+ | End Time | 2012-01-29 15:57:26 |
+ | Incoming Tranfer (bytes) | 7658 |
+ | Outgoing Tranfer (bytes) | 0 |
+ +--------------------------+---------------------+
+
+List all load balancer usage records::
+
+ $ clb show-all-usage mylb
+-----------------------+---------------------+
| Property | Value |
+-----------------------+---------------------+
View
32 bin/clb
@@ -299,13 +299,41 @@ class CloudloadbalancersShell(object):
print_list2(fields, rows, args.batch, args.delimiter)
@arg('loadbalancer', metavar='<loadbalancer>', help='Name or ID of load balancer.')
- def do_show_usage(self, args):
- """Display load balancer usage."""
+ def do_show_all_usage(self, args):
+ """Display all load balancer usage records."""
lb = self.findlb(args.loadbalancer)
for u in lb.get_usage():
print_dict(u)
@arg('loadbalancer', metavar='<loadbalancer>', help='Name or ID of load balancer.')
+ def do_show_usage(self, args):
+ """Display load balancer usage."""
+ lb = self.findlb(args.loadbalancer)
+ usage = lb.get_usage()
+ output = {}
+ for u in usage:
+ v = u['vipType']
+ if v not in output.keys():
+ output[v] = {'startTime': datetime.now(), 'endTime': datetime(1970, 1, 1), 'outgoingTransfer': 0, 'incomingTransfer': 0}
+
+ if u['startTime'] < output[v]['startTime']:
+ output[v]['startTime'] = u['startTime']
+ if u['endTime'] > output[v]['endTime']:
+ output[v]['endTime'] = u['endTime']
+ output[v]['outgoingTransfer'] += u['outgoingTransfer']
+ output[v]['incomingTransfer'] += u['incomingTransfer']
+
+ fields = ['Field', 'Value']
+ rows = []
+ for k in output.keys():
+ rows.append(['VIP Type:', k])
+ rows.append(['Start Time', output[k]['startTime']])
+ rows.append(['End Time', output[k]['endTime']])
+ rows.append(['Incoming Tranfer (bytes)',output[k]['incomingTransfer']])
+ rows.append(['Outgoing Tranfer (bytes)',output[k]['outgoingTransfer']])
+ print_list2(fields, rows, args.batch, args.delimiter)
+
+ @arg('loadbalancer', metavar='<loadbalancer>', help='Name or ID of load balancer.')
@arg('name', metavar='<name>', help="New load balancer name.")
def do_rename(self,args):
"""Rename an existing load balancer."""
Please sign in to comment.
Something went wrong with that request. Please try again.