From 142c5faae38c0619d218e0113644d6fa7bea76a8 Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Mon, 9 Jan 2017 12:31:47 +0200 Subject: [PATCH] Fix Octavia gate breakage caused by _get_columns() The above mentioned function tries to extract keys() from an item which is type class. This patch fixes the issue by converting item to dict by using to_dict(). Change-Id: Ida520ae9fe64171d105f486ba06eda127a24547b Closes-Bug: #1654887 --- openstackclient/network/v2/security_group.py | 6 +++--- .../tests/functional/network/v2/test_security_group.py | 3 --- .../tests/functional/network/v2/test_security_group_rule.py | 2 +- openstackclient/tests/unit/fakes.py | 3 +++ 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openstackclient/network/v2/security_group.py b/openstackclient/network/v2/security_group.py index 5420bc8ba7..df9e320b10 100644 --- a/openstackclient/network/v2/security_group.py +++ b/openstackclient/network/v2/security_group.py @@ -74,7 +74,7 @@ _formatters_compute = { def _get_columns(item): # Build the display columns and a list of the property columns # that need to be mapped (display column name, property name). - columns = list(item.keys()) + columns = list(item.to_dict().keys()) property_column_mappings = [] if 'security_group_rules' in columns: columns.append('rules') @@ -156,7 +156,7 @@ class CreateSecurityGroup(common.NetworkAndComputeShowOne): parsed_args.name, description, ) - display_columns, property_columns = _get_columns(obj._info) + display_columns, property_columns = _get_columns(obj) data = utils.get_dict_properties( obj._info, property_columns, @@ -336,7 +336,7 @@ class ShowSecurityGroup(common.NetworkAndComputeShowOne): client.security_groups, parsed_args.group, ) - display_columns, property_columns = _get_columns(obj._info) + display_columns, property_columns = _get_columns(obj) data = utils.get_dict_properties( obj._info, property_columns, diff --git a/openstackclient/tests/functional/network/v2/test_security_group.py b/openstackclient/tests/functional/network/v2/test_security_group.py index 73f6deb3e9..debd81df6e 100644 --- a/openstackclient/tests/functional/network/v2/test_security_group.py +++ b/openstackclient/tests/functional/network/v2/test_security_group.py @@ -12,8 +12,6 @@ import uuid -import testtools - from openstackclient.tests.functional import base @@ -25,7 +23,6 @@ class SecurityGroupTests(base.TestCase): FIELDS = ['name'] @classmethod - @testtools.skip('broken SDK testing') def setUpClass(cls): opts = cls.get_opts(cls.FIELDS) raw_output = cls.openstack('security group create ' + cls.NAME + opts) diff --git a/openstackclient/tests/functional/network/v2/test_security_group_rule.py b/openstackclient/tests/functional/network/v2/test_security_group_rule.py index 5d2e584369..ec3731eb9a 100644 --- a/openstackclient/tests/functional/network/v2/test_security_group_rule.py +++ b/openstackclient/tests/functional/network/v2/test_security_group_rule.py @@ -26,7 +26,6 @@ class SecurityGroupRuleTests(base.TestCase): ID_HEADER = ['ID'] @classmethod - @testtools.skip('broken SDK testing') def setUpClass(cls): # Create the security group to hold the rule. opts = cls.get_opts(cls.NAME_FIELD) @@ -55,6 +54,7 @@ class SecurityGroupRuleTests(base.TestCase): cls.SECURITY_GROUP_NAME) cls.assertOutput('', raw_output) + @testtools.skip('broken SDK testing') def test_security_group_rule_list(self): opts = self.get_opts(self.ID_HEADER) raw_output = self.openstack('security group rule list ' + diff --git a/openstackclient/tests/unit/fakes.py b/openstackclient/tests/unit/fakes.py index f7cb567644..ca6b1d31f1 100644 --- a/openstackclient/tests/unit/fakes.py +++ b/openstackclient/tests/unit/fakes.py @@ -212,6 +212,9 @@ class FakeResource(object): def keys(self): return self._info.keys() + def to_dict(self): + return self._info + @property def info(self): return self._info