diff --git a/octaviaclient/osc/v2/amphora.py b/octaviaclient/osc/v2/amphora.py index a0fb7d8..ce239c8 100644 --- a/octaviaclient/osc/v2/amphora.py +++ b/octaviaclient/osc/v2/amphora.py @@ -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) diff --git a/octaviaclient/osc/v2/constants.py b/octaviaclient/osc/v2/constants.py index 0b2bd34..cc32649 100644 --- a/octaviaclient/osc/v2/constants.py +++ b/octaviaclient/osc/v2/constants.py @@ -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', diff --git a/octaviaclient/tests/unit/osc/v2/constants.py b/octaviaclient/tests/unit/osc/v2/constants.py index e822662..c0bc6a2 100644 --- a/octaviaclient/tests/unit/osc/v2/constants.py +++ b/octaviaclient/tests/unit/osc/v2/constants.py @@ -30,6 +30,7 @@ AMPHORA_ATTRS = { "vrrp_id": 1, "vrrp_priority": 200, "cached_zone": "zone2", + "image_id": uuidutils.generate_uuid(dashed=True), } HM_ATTRS = { diff --git a/octaviaclient/tests/unit/osc/v2/test_amphora.py b/octaviaclient/tests/unit/osc/v2/test_amphora.py index ffdb933..dcc4863 100644 --- a/octaviaclient/tests/unit/osc/v2/test_amphora.py +++ b/octaviaclient/tests/unit/osc/v2/test_amphora.py @@ -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 = { diff --git a/releasenotes/notes/amphora-list-long-option-55390b5abef5b82e.yaml b/releasenotes/notes/amphora-list-long-option-55390b5abef5b82e.yaml new file mode 100644 index 0000000..183c495 --- /dev/null +++ b/releasenotes/notes/amphora-list-long-option-55390b5abef5b82e.yaml @@ -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). \ No newline at end of file