Ejemplo n.º 1
0
    status = result[0]
    if status.eq(STATUS.OK) == True:
        print ("'%s' firewalls config:" % nodeName)
        cfg = result[1]
        data = json.loads(cfg)
        print json.dumps(data, indent=4)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief().lower())
        exit(0)

    print "\n"
    fwName1 = "ACCEPT-SRC-IPADDR"
    print (">>> Create new firewall instance '%s' on '%s' " % (fwName1, nodeName))
    time.sleep(rundelay)
    firewall1 = Firewall()
    rules = Rules(fwName1)
    rulenum = 30
    rule = Rule(rulenum)
    rule.add_action("accept")
    rule.add_source_address("172.22.17.108")
    rules.add_rule(rule)
    firewall1.add_rules(rules)
    result = vrouter.create_firewall_instance(firewall1)
    status = result[0]
    if status.eq(STATUS.OK) == True:
        print ("Firewall instance '%s' was successfully created" % fwName1)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief().lower())
        exit(0)
Ejemplo n.º 2
0
 result = vrouter.get_firewalls_cfg()
 status = result[0]
 if (status.eq(STATUS.OK) == True):
     print ("'%s' firewalls config:" % nodeName)
     cfg = result[1]
     data = json.loads(cfg)
     print json.dumps(data, indent=4)
 else:
     print ("\n")
     print ("!!!Demo terminated, reason: %s" % status.brief().lower())
     exit(0)
 
 
 print "\n"
 firewallgroup = "FW-ACCEPT-SRC-172_22_17_108"
 firewall = Firewall()    
 rules = Rules(firewallgroup)    
 rulenum = 33
 rule = Rule(rulenum)
 rule.add_action("accept")
 rule.add_source_address("172.22.17.108")    
 rules.add_rule(rule)
 firewall.add_rules(rules)
 print ("<<< Create new firewall instance '%s' on '%s' " % (firewallgroup, nodeName))
 time.sleep(rundelay)    
 result = vrouter.create_firewall_instance(firewall)
 status = result[0]
 if(status.eq(STATUS.OK) == True):
     print ("Firewall instance '%s' was successfully created" % firewallgroup)
 else:
     print ("\n")