This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
import json
import uuid
import csv
with open('opnsense_aliases.json') as user_file:
parsed_json = json.load(user_file)
cur_items=parsed_json['aliases']['alias']
with open('/tmp/pfsense_alias.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
#print(row)
item_name = row['name']
item_data = row['data']
item_type = row['type']
item_description = row['description']
if len(row['data'].split(" "))>1:
item_data = "\n".join(row['data'].split(" "))
item_uuid = str(uuid.uuid4())
y = {'enabled': '1',
'name': item_name,
'type': item_type,
'proto': '',
'interface': '',
'counters': '0',
'updatefreq': '',
'content': item_data,
'categories': '',
'description': item_description
}
cur_items[item_uuid] = y
print(json.dumps(parsed_json, indent=2))
$curl -X POST -d '{"address":"192.168.42.42"}' -H "Content-Type: application/json" -k -u $key:$secret https://opnsense/api/firewall/alias_util/add/test
{"status":"failed","status_msg":"nonexistent alias test"}