From 86a3c7a4159b8e978c5a90c66ded1f30944c1f45 Mon Sep 17 00:00:00 2001 From: Sindhu Devale Date: Wed, 2 Nov 2016 10:11:54 -0500 Subject: [PATCH] SDK refactor: Prepare floating ip commands Prepare the OSC "floating ip" commands for the SDK refactor. Change-Id: I02052185b3ce0b053acdcf76a0f68d49e6f7e608 Partially-Implements: blueprint network-command-sdk-support --- openstackclient/network/v2/floating_ip.py | 16 ++++++++++++---- .../tests/unit/network/v2/test_floating_ip.py | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/openstackclient/network/v2/floating_ip.py b/openstackclient/network/v2/floating_ip.py index bb75540cc6..12a4754d3e 100644 --- a/openstackclient/network/v2/floating_ip.py +++ b/openstackclient/network/v2/floating_ip.py @@ -19,6 +19,14 @@ from osc_lib import utils from openstackclient.i18n import _ from openstackclient.network import common +from openstackclient.network import sdk_utils + + +def _get_network_columns(item): + column_map = { + 'tenant_id': 'project_id', + } + return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map) def _get_columns(item): @@ -110,9 +118,9 @@ class CreateFloatingIP(common.NetworkAndComputeShowOne): def take_action_network(self, client, parsed_args): attrs = _get_attrs(self.app.client_manager, parsed_args) obj = client.create_ip(**attrs) - columns = _get_columns(obj) + display_columns, columns = _get_network_columns(obj) data = utils.get_item_properties(obj, columns) - return (columns, data) + return (display_columns, data) def take_action_compute(self, client, parsed_args): obj = client.floating_ips.create(parsed_args.network) @@ -282,9 +290,9 @@ class ShowFloatingIP(common.NetworkAndComputeShowOne): def take_action_network(self, client, parsed_args): obj = client.find_ip(parsed_args.floating_ip, ignore_missing=False) - columns = _get_columns(obj) + display_columns, columns = _get_network_columns(obj) data = utils.get_item_properties(obj, columns) - return (columns, data) + return (display_columns, data) def take_action_compute(self, client, parsed_args): obj = utils.find_resource( diff --git a/openstackclient/tests/unit/network/v2/test_floating_ip.py b/openstackclient/tests/unit/network/v2/test_floating_ip.py index 1f30f2e923..10aaca34ef 100644 --- a/openstackclient/tests/unit/network/v2/test_floating_ip.py +++ b/openstackclient/tests/unit/network/v2/test_floating_ip.py @@ -296,7 +296,7 @@ class TestShowFloatingIPNetwork(TestFloatingIPNetwork): floating_ip.floating_network_id, floating_ip.id, floating_ip.port_id, - floating_ip.tenant_id, + floating_ip.project_id, floating_ip.router_id, floating_ip.status, )