-
-
Save dnel/583bb49ccd75023c2acd10c29a2e1ace to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
script="config firewall addrgrp\n" | |
group_dict={} | |
comment_dict={} | |
with open('groups.csv', 'rb') as csvfile: | |
obj_reader = csv.reader(csvfile, dialect='excel') | |
for row in obj_reader: | |
if group_dict.get(row[0]): | |
group_dict[row[0]] = "%s \"%s\"" % (group_dict.get(row[0]),row[6]) | |
else: | |
group_dict[row[0]] = "\"%s\"" % row[6] | |
if len(row[8]) > 2: | |
comment_dict[row[0]] = "\"%s\"" % row[8] | |
for k in group_dict.keys(): | |
segment = "edit \"%s\"\n set member %s\n" % (k,group_dict.get(k)) | |
if comment_dict.get(k): segment += " set comment %s\n" % comment_dict.get(k) | |
segment += "next\n" | |
script += segment | |
script += "end\n" | |
with open('groups_script.fgt', 'w') as save_file: save_file.write(script) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment