Merge "Fix format errors in nova security group rule list"
This commit is contained in:
commit
9ccaacbe27
@ -31,15 +31,23 @@ from openstackclient.common import utils
|
|||||||
def _xform_security_group_rule(sgroup):
|
def _xform_security_group_rule(sgroup):
|
||||||
info = {}
|
info = {}
|
||||||
info.update(sgroup)
|
info.update(sgroup)
|
||||||
info.update(
|
from_port = info.pop('from_port')
|
||||||
{'port_range': "%u:%u" % (
|
to_port = info.pop('to_port')
|
||||||
info.pop('from_port'),
|
if isinstance(from_port, int) and isinstance(to_port, int):
|
||||||
info.pop('to_port'),
|
port_range = {'port_range': "%u:%u" % (from_port, to_port)}
|
||||||
)}
|
elif from_port is None and to_port is None:
|
||||||
)
|
port_range = {'port_range': ""}
|
||||||
info['ip_range'] = info['ip_range']['cidr']
|
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':
|
if info['ip_protocol'] == 'icmp':
|
||||||
info['port_range'] = ''
|
info['port_range'] = ''
|
||||||
|
elif info['ip_protocol'] is None:
|
||||||
|
info['ip_protocol'] = ''
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user