示例#1
0
        cfg = result.get_data()
        data = json.loads(cfg)
        print json.dumps(data, indent=4)
    elif (status.eq(STATUS.DATA_NOT_FOUND) == True):
        print("No firewalls configuration found")
    else:
        print("\n")
        print("!!!Demo terminated, reason: %s" % status.brief().lower())
        ctrl.delete_netconf_node(vrouter)
        exit(0)

    print "\n"
    fwName1 = "ACCEPT-SRC-IPADDR"
    print(">>> Create new firewall instance '%s' on '%s' " %
          (fwName1, nodeName))
    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)
    print firewall1.to_json()
    time.sleep(rundelay)
    result = vrouter.create_firewall_instance(firewall1)
    status = result.get_status()
    if (status.eq(STATUS.OK) == True):
        print("Firewall instance '%s' was successfully created" % fwName1)
    else:
        print("\n")
示例#2
0
 if (status.eq(STATUS.OK) == True):
     print ("'%s' firewall config:" % nodeName)
     cfg = result.get_data()
     data = json.loads(cfg)
     print json.dumps(data, indent=4)
 elif (status.eq(STATUS.DATA_NOT_FOUND)):
     print ("No firewalls configuration found")
 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.get_status()
 if(status.eq(STATUS.OK) == True):
     print ("Firewall instance '%s' was successfully created" % firewallgroup)
 else:
     print ("\n")
示例#3
0
     cfg = result.get_data()
     data = json.loads(cfg)
     print json.dumps(data, indent=4)
 elif (status.eq(STATUS.DATA_NOT_FOUND) == True):
     print ("No firewalls configuration found")
 else:
     print ("\n")
     print ("!!!Demo terminated, reason: %s" % status.brief().lower())
     ctrl.delete_netconf_node(vrouter)
     exit(0)
 
 
 print "\n"
 fwName1 = "ACCEPT-SRC-IPADDR"
 print (">>> Create new firewall instance '%s' on '%s' " % (fwName1, nodeName))
 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)
 print firewall1.to_json()
 time.sleep(rundelay)
 result = vrouter.create_firewall_instance(firewall1)
 status = result.get_status()
 if(status.eq(STATUS.OK) == True):
     print ("Firewall instance '%s' was successfully created" % fwName1)
 else:
     print ("\n")
示例#4
0
    status = result.get_status()
    if (status.eq(STATUS.OK)):
        print ("'%s' firewall config:" % nodeName)
        cfg = result.get_data()
        data = json.loads(cfg)
        print json.dumps(data, indent=4)
    elif (status.eq(STATUS.DATA_NOT_FOUND)):
        print ("No firewalls configuration found")
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief().lower())
        exit(0)

    print "\n"
    fw_name = "FW-ACCEPT-SRC-172_22_17_108"
    firewall = Firewall(fw_name)
    # add a rule to the firewall instance
    rulenum = 33
    rule = Rule(rulenum)
    rule.add_action("accept")
    rule.add_source_address("172.22.17.108")
    firewall.add_rule(rule)
    print ("<<< Create new firewall instance '%s' on '%s'" %
           (fw_name, nodeName))
    print firewall.get_payload()
    time.sleep(rundelay)
    result = vrouter.add_modify_firewall_instance(firewall)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print ("Firewall instance '%s' was successfully created" % fw_name)
    else: