Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions SoftLayer/managers/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,19 @@ def edit_securitygroup_rule(self, group_id, rule_id, remote_ip=None,
"""
successful = False
obj = {}
if remote_ip:
if remote_ip is not None:
obj['remoteIp'] = remote_ip
if remote_group:
if remote_group is not None:
obj['remoteGroupId'] = remote_group
if direction:
if direction is not None:
obj['direction'] = direction
if ethertype:
if ethertype is not None:
obj['ethertype'] = ethertype
if port_max:
if port_max is not None:
obj['portRangeMax'] = port_max
if port_min:
if port_min is not None:
obj['portRangeMin'] = port_min
if protocol:
if protocol is not None:
obj['protocol'] = protocol

if obj:
Expand Down
17 changes: 17 additions & 0 deletions tests/managers/network_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,23 @@ def test_edit_securitygroup_rule(self):
args=([{'id': 500,
'direction': 'ingress'}],))

def test_edit_securitygroup_rule_unset(self):
# Test calling edit rule with falsy values, which are used
# to unset those values in the API
result = self.network.edit_securitygroup_rule(100, 500,
protocol='',
port_min=-1,
port_max=-1,
ethertype='',
remote_ip='')

self.assertTrue(result)
self.assert_called_with('SoftLayer_Network_SecurityGroup',
'editRules', identifier=100,
args=([{'id': 500, 'protocol': '',
'portRangeMin': -1, 'portRangeMax': -1,
'ethertype': '', 'remoteIp': ''}],))

def test_get_rwhois(self):
result = self.network.get_rwhois()

Expand Down