Skip to content

Commit fac57e9

Browse files
Merge pull request #1649 from caberos/issue1643
update the firewall list
2 parents 337b1a0 + bf31862 commit fac57e9

File tree

5 files changed

+80
-18
lines changed

5 files changed

+80
-18
lines changed

SoftLayer/CLI/firewall/list.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def cli(env):
1818
table = formatting.Table(['firewall id',
1919
'type',
2020
'features',
21-
'server/vlan id'])
21+
'server/vlan id'], title='Single Server Firewalls')
2222
fwvlans = mgr.get_firewalls()
2323
dedicated_firewalls = [firewall for firewall in fwvlans
2424
if firewall['dedicatedFirewallFlag']]
@@ -70,7 +70,27 @@ def cli(env):
7070
'hardwareId')
7171
])
7272

73+
table_gatewalls = formatting.Table(['Id',
74+
'firewall',
75+
'type',
76+
'Hostname',
77+
'Location',
78+
'Public Ip',
79+
'Private Ip',
80+
'Associated vlan',
81+
'status'], title='Multi Vlan Firewall')
82+
fw_gatewwalls = mgr.get_firewalls_gatewalls()
83+
84+
for gatewalls in fw_gatewwalls:
85+
table_gatewalls.add_row([gatewalls['networkFirewall']['id'], gatewalls.get('name'),
86+
gatewalls['networkFirewall']['firewallType'],
87+
gatewalls['members'][0]['hardware']['hostname'],
88+
gatewalls['networkFirewall']['datacenter']['name'],
89+
gatewalls['publicIpAddress']['ipAddress'],
90+
gatewalls['privateIpAddress']['ipAddress'],
91+
len(gatewalls['insideVlans']), gatewalls['status']['keyName']])
7392
env.fout(table)
93+
env.fout(table_gatewalls)
7494

7595

7696
def has_firewall_component(server):

SoftLayer/fixtures/SoftLayer_Account.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,3 +1228,41 @@
12281228
'projectedPublicBandwidthUsage': 9.88,
12291229
'totalBandwidthAllocated': 3361
12301230
}]
1231+
1232+
getNetworkGateways = [{
1233+
'id': 615448,
1234+
'name': 'testFirewall-cgallo',
1235+
'networkSpace': 'BOTH',
1236+
'insideVlans': [],
1237+
'members': [
1238+
{
1239+
'id': 687820,
1240+
'hardware': {
1241+
'hostname': 'dft03.pod03.dal13'
1242+
}
1243+
}
1244+
],
1245+
'networkFirewall': {
1246+
'id': 17438,
1247+
'datacenter': {
1248+
'name': 'dal13'
1249+
},
1250+
'firewallType': 'fortigate-security-appliance-10gb',
1251+
'rules': []
1252+
},
1253+
'privateIpAddress': {
1254+
'ipAddress': '10.37.115.70'
1255+
},
1256+
'publicIpAddress': {
1257+
'ipAddress': '67.228.206.245'
1258+
},
1259+
'publicVlan': {
1260+
'id': 3228726,
1261+
'primaryRouter': {
1262+
'hostname': 'fcr03a.dal13'
1263+
}
1264+
},
1265+
'status': {
1266+
'keyName': 'ACTIVE'
1267+
}
1268+
}]

SoftLayer/managers/firewall.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,19 @@ def get_instance(self, firewall_id, mask=None):
302302
svc = self.client['Network_Vlan_Firewall']
303303

304304
return svc.getObject(id=firewall_id, mask=mask)
305+
306+
def get_firewalls_gatewalls(self):
307+
"""Returns a list of all gateway firewalls (gatewalls) on the account.
308+
309+
returns: A list of gateway firewalls (gatewalls) on the current account.
310+
"""
311+
mask = 'mask[id,networkSpace,name,' \
312+
'networkFirewall[id,firewallType,datacenter[name]],' \
313+
'status[keyName],' \
314+
'insideVlans[id],' \
315+
'privateIpAddress[ipAddress],' \
316+
'publicVlan[id,primaryRouter[hostname]],' \
317+
'publicIpAddress[ipAddress],members[id,hardware[hostname]]]'
318+
_filter = {"networkGateways": {"networkFirewall": {"operation": "not null"}}}
319+
320+
return self.account.getNetworkGateways(mask=mask, filter=_filter)

tests/CLI/modules/firewall_tests.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,7 @@ def test_list_firewalls(self):
1616
result = self.run_command(['firewall', 'list'])
1717

1818
self.assert_no_fail(result)
19-
self.assertEqual(json.loads(result.output),
20-
[{'features': ['HA'],
21-
'firewall id': 'vlan:1234',
22-
'server/vlan id': 1,
23-
'type': 'VLAN - dedicated'},
24-
{'features': ['HA'],
25-
'firewall id': 'vlan:23456',
26-
'server/vlan id': 3,
27-
'type': 'VLAN - dedicated'},
28-
{'features': '-',
29-
'firewall id': 'vs:1234',
30-
'server/vlan id': 1,
31-
'type': 'Virtual Server - standard'},
32-
{'features': '-',
33-
'firewall id': 'server:1234',
34-
'server/vlan id': 1,
35-
'type': 'Server - standard'}])
19+
self.assert_called_with('SoftLayer_Account', 'getNetworkGateways')
3620

3721
@mock.patch('SoftLayer.CLI.formatting.confirm')
3822
def test_add_vs(self, confirm_mock):

tests/managers/firewall_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,7 @@ def test_edit_standard_fwl_rules(self):
322322
self.assert_called_with('SoftLayer_Network_Firewall_Update_Request',
323323
'createObject',
324324
args=args)
325+
326+
def test_get_gateways(self):
327+
self.firewall.get_firewalls_gatewalls()
328+
self.assert_called_with('SoftLayer_Account', 'getNetworkGateways')

0 commit comments

Comments
 (0)