Add /loadbalancers?status=DELETED to client

Fixes bug #1089889

Change-Id: I8c28ae8cdc2dcad7cb332caa74ea4c5b561ce58d
This commit is contained in:
Andrew Hutchings
2012-12-13 11:54:54 +00:00
parent 4feddebe18
commit 1e4787b61b
4 changed files with 16 additions and 3 deletions

View File

@@ -114,6 +114,10 @@ list
List all load balancers
.. option:: --deleted
Show deleted load balancers
.. program:: libra_client limits
limits

View File

@@ -76,9 +76,13 @@ class ClientOptions(object):
subparsers.add_parser(
'protocols', help='get a list of supported protocols and ports'
)
subparsers.add_parser(
sp = subparsers.add_parser(
'list', help='list load balancers'
)
sp.add_argument(
'--deleted', help='list deleted load balancers',
action='store_true'
)
sp = subparsers.add_parser(
'delete', help='delete a load balancer'
)

View File

@@ -54,7 +54,10 @@ class LibraAPI(object):
self._render_list(column_names, columns, body['algorithms'])
def list_lb(self, args):
resp, body = self._get('/loadbalancers')
if args.deleted:
resp, body = self._get('/loadbalancers?status=DELETED')
else:
resp, body = self._get('/loadbalancers')
column_names = ['Name', 'ID', 'Protocol', 'Port', 'Algorithm',
'Status', 'Created', 'Updated']
columns = ['name', 'id', 'protocol', 'port', 'algorithm', 'status',

View File

@@ -11,6 +11,7 @@ class DummyArgs(object):
""" Fake argparse response """
def __init__(self):
self.id = 2000
self.deleted = False
class DummyCreateArgs(object):
""" Fake argparse response for Create function """
@@ -87,7 +88,8 @@ class TestLBaaSClientLibraAPI(unittest.TestCase):
try:
out = StringIO()
sys.stdout = out
self.api.list_lb(None)
args = DummyArgs()
self.api.list_lb(args)
output = out.getvalue().strip()
self.assertRegexpMatches(output, 'lb-site1')
self.assertRegexpMatches(output, '71')