diff options
| author | Terry Howe <terrylhowe@gmail.com> | 2014-02-20 09:29:38 -0700 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-02-20 20:17:53 +0000 |
| commit | ada9d35cbe477d7225d217c6c1926b5fb8aa0a92 (patch) | |
| tree | 8ceff436edc14664d09a82a1dcc27064f42acddf /openstackclient/compute | |
| parent | 295842175540df01ea4a2ab5de08f79398e6e12b (diff) | |
| download | python-openstackclient-ada9d35cbe477d7225d217c6c1926b5fb8aa0a92.tar.gz | |
Fix format errors in nova security group rule list
* port range was throwing exception for None to/from ports
* ip_range didn't always have cidr causing error
* ip_protocol None at times and looked bad
Closes-Bug #1256935
Change-Id: I451a0f038a3e9646bca3f278c5d6f6d7e3097a83
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/v2/security_group.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py index a1dc786d..be64bd3a 100644 --- a/openstackclient/compute/v2/security_group.py +++ b/openstackclient/compute/v2/security_group.py @@ -31,15 +31,23 @@ from openstackclient.common import utils def _xform_security_group_rule(sgroup): info = {} info.update(sgroup) - info.update( - {'port_range': "%u:%u" % ( - info.pop('from_port'), - info.pop('to_port'), - )} - ) - info['ip_range'] = info['ip_range']['cidr'] + from_port = info.pop('from_port') + to_port = info.pop('to_port') + if isinstance(from_port, int) and isinstance(to_port, int): + port_range = {'port_range': "%u:%u" % (from_port, to_port)} + elif from_port is None and to_port is None: + port_range = {'port_range': ""} + else: + port_range = {'port_range': "%s:%s" % (from_port, to_port)} + info.update(port_range) + if 'cidr' in info['ip_range']: + info['ip_range'] = info['ip_range']['cidr'] + else: + info['ip_range'] = '' if info['ip_protocol'] == 'icmp': info['port_range'] = '' + elif info['ip_protocol'] is None: + info['ip_protocol'] = '' return info |
