feat: add various infrastructure check and automation scripts
This commit is contained in:
25
scripts/check_compute_fw.py
Normal file
25
scripts/check_compute_fw.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import requests
|
||||
import urllib3
|
||||
import json
|
||||
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
s = requests.Session()
|
||||
s.verify = False
|
||||
|
||||
r = s.post('https://14.44.4.1/api/auth/login', json={'username': 'snarf', 'password': 'Katzir476!!!'})
|
||||
csrf = r.headers.get('x-csrf-token') or r.cookies.get('csrf_token')
|
||||
headers = {'X-CSRF-Token': csrf} if csrf else {}
|
||||
|
||||
res = s.get('https://14.44.4.1/proxy/network/v2/api/site/default/firewall-policies', headers=headers)
|
||||
policies = res.json()
|
||||
compute_net_id = "1748bb1d-f674-4dcd-85d0-f58109a02e77"
|
||||
|
||||
for p in policies:
|
||||
src_nets = p.get('source', {}).get('network_ids', []) or []
|
||||
dst_nets = p.get('destination', {}).get('network_ids', []) or []
|
||||
if compute_net_id in src_nets or compute_net_id in dst_nets:
|
||||
print(f"Policy: {p.get('name')} (Index {p.get('index')}) | Action: {p.get('action')} | Type: {p.get('connection_state_type')}")
|
||||
print(f" Src: {p.get('source')}")
|
||||
print(f" Dst: {p.get('destination')}")
|
||||
|
||||
Reference in New Issue
Block a user