Пример #1
0
def removeobject(objname, server):
    cmdstring = """configure terminal
object-group network Deny_All_Group
no network-object object %s
no object network %s
write mem""" % (objname, objname)
    return firecall.main(username, password, sshkey, server, port, cmdstring)
Пример #2
0
def alreadyBlocked(blockip, server):
    cmdstring = "sh run object-group id %s" % fwgroup
    output, errmsg = firecall.main(username, password, sshkey, server, port, cmdstring)
    if "AUTOADD_%s_" % blockip in output:
        return True
    else:
        return False
Пример #3
0
def addip(blockip, server):
    objname = "AUTOADD_%s_%s" % (blockip, today)
    desc = "Added by '%s' via script on %s" % (username, today)
    cmdstring = """configure terminal
object network %s
host %s
description %s
object-group network %s
network-object object %s
write mem""" % (objname, blockip, desc, fwgroup, objname)
    return firecall.main(username, password, sshkey, server, port, cmdstring)
Пример #4
0
def get_objname(ip, server):
    cmdstring = "sh run object-group id %s" % fwgroup
    output, errmsg = firecall.main(username, password, sshkey, server, port, cmdstring)
    string = "AUTOADD_%s_" % ip
    if string in output:
        # split output on all whitespace
        for string in output.split():
            if ip in string:
                return str(string)
    else:
        # if the IP is not found in the firewall object list, just return False
        return False