Browse Source

Merge "Add --long to amphora-list to show more columns"

tags/2.0.1^0
Zuul 3 months ago
committed by Gerrit Code Review
parent
commit
17836502fa
5 changed files with 42 additions and 1 deletions
  1. +9
    -0
      octaviaclient/osc/v2/amphora.py
  2. +12
    -0
      octaviaclient/osc/v2/constants.py
  3. +1
    -0
      octaviaclient/tests/unit/osc/v2/constants.py
  4. +15
    -1
      octaviaclient/tests/unit/osc/v2/test_amphora.py
  5. +5
    -0
      releasenotes/notes/amphora-list-long-option-55390b5abef5b82e.yaml

+ 9
- 0
octaviaclient/osc/v2/amphora.py View File

@@ -62,10 +62,19 @@ class ListAmphora(lister.Lister):
help="Filter by amphora provisioning status."
)

parser.add_argument(
'--long',
action='store_true',
help='Show additional fields.',
)

return parser

def take_action(self, parsed_args):
columns = const.AMPHORA_COLUMNS
if parsed_args.long:
columns = const.AMPHORA_COLUMNS_LONG

attrs = v2_utils.get_amphora_attrs(self.app.client_manager,
parsed_args)



+ 12
- 0
octaviaclient/osc/v2/constants.py View File

@@ -279,6 +279,18 @@ AMPHORA_COLUMNS = (
'ha_ip',
)

AMPHORA_COLUMNS_LONG = (
'id',
'loadbalancer_id',
'status',
'role',
'lb_network_ip',
'ha_ip',
'compute_id',
'cached_zone',
'image_id',
)

PROVIDER_COLUMNS = (
'name',
'description',


+ 1
- 0
octaviaclient/tests/unit/osc/v2/constants.py View File

@@ -30,6 +30,7 @@ AMPHORA_ATTRS = {
"vrrp_id": 1,
"vrrp_priority": 200,
"cached_zone": "zone2",
"image_id": uuidutils.generate_uuid(dashed=True),
}

HM_ATTRS = {


+ 15
- 1
octaviaclient/tests/unit/osc/v2/test_amphora.py View File

@@ -30,11 +30,12 @@ class TestAmphora(fakes.TestOctaviaClient):
self._amp = fakes.createFakeResource('amphora')
self.amp_info = copy.deepcopy(attr_consts.AMPHORA_ATTRS)
self.columns = copy.deepcopy(constants.AMPHORA_COLUMNS)
self.columns_long = copy.deepcopy(constants.AMPHORA_COLUMNS_LONG)
self.rows = copy.deepcopy(constants.AMPHORA_ROWS)

info_list = {'amphorae': [
{k: v for k, v in attr_consts.AMPHORA_ATTRS.items() if (
k in self.columns)},
k in self.columns_long)},
]}
self.api_mock = mock.Mock()
self.api_mock.amphora_list.return_value = info_list
@@ -50,6 +51,8 @@ class TestAmphoraList(TestAmphora):
super(TestAmphoraList, self).setUp()
self.data_list = (tuple(
attr_consts.AMPHORA_ATTRS[k] for k in self.columns),)
self.data_list_long = (tuple(
attr_consts.AMPHORA_ATTRS[k] for k in self.columns_long),)
self.cmd = amphora.ListAmphora(self.app, None)

def test_amphora_list_no_options(self):
@@ -63,6 +66,17 @@ class TestAmphoraList(TestAmphora):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data_list, tuple(data))

def test_amphora_list_long(self):
arglist = ['--long']
verify_list = []

parsed_args = self.check_parser(self.cmd, arglist, verify_list)
columns, data = self.cmd.take_action(parsed_args)

self.api_mock.amphora_list.assert_called_with()
self.assertEqual(self.columns_long, columns)
self.assertEqual(self.data_list_long, tuple(data))

@mock.patch('octaviaclient.osc.v2.utils.get_amphora_attrs')
def test_amphora_list_with_loadbalancer(self, mock_client):
mock_client.return_value = {


+ 5
- 0
releasenotes/notes/amphora-list-long-option-55390b5abef5b82e.yaml View File

@@ -0,0 +1,5 @@
---
features:
- |
Amphora list now supports a ``--long`` option, which will include a few
additional columns (compute_id, cached_zone, image_id).

Loading…
Cancel
Save