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") print ("!!!Demo terminated, reason: %s" % status.brief().lower()) exit(0)
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") print("!!!Demo terminated, reason: %s" % status.brief().lower()) exit(0)
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") print ("!!!Demo terminated, reason: %s" % status.brief().lower()) exit(0)