def main(): print "*** START ***\n" #Loading IOS Reference (ALL commands and parameters available in a device, i.e. documentation) iosReference = IOSReference(minidom.parse('../TestFiles/IOSRef_AlgoValidation.xml')) #Loading devices connected to the network # USING Configuration #2 : 5 devices device1 = Device(minidom.parse('../TestFiles/DevicesConf1/Device1.xml'), iosReference) device2 = Device(minidom.parse('../TestFiles/DevicesConf1/Device2.xml'), iosReference) device3 = Device(minidom.parse('../TestFiles/DevicesConf2/Device3.xml'), iosReference) device4 = Device(minidom.parse('../TestFiles/DevicesConf2/Device4.xml'), iosReference) device5 = Device(minidom.parse('../TestFiles/DevicesConf2/Device5.xml'), iosReference) print "\n** Building validation tree for formula #3: Exists d=x : Exists d=x, a=y : Exists d=x, b=z : y=0 ^ z=3 \n" ''' ----------- CENTRAL ---------- | o (node1) EXISTS | | | d=x (node2) EXISTS /\ / \ / \ / \ a=y (node3) b=z (node4) [cond. y=0] [cond. z=3] ''' #Central validation (main class) central = CentralValidation() central.addDevice(device1) central.addDevice(device2) central.addDevice(device3) central.addDevice(device4) central.addDevice(device5) #aliases x, y, z in the nodes aliasX = Alias("x") aliasY = Alias("y") aliasZ = Alias("z") uid_a = 101 uid_b = 102 uid_d = 1 #condition y=0 condition1 = Condition("==") condition1.setTerms(AtomicAliasTerm(aliasY), AtomicConstantTerm(0)) #condition z=3 condition2 = Condition("==") condition2.setTerms(AtomicAliasTerm(aliasZ), AtomicConstantTerm(3)) #nodes node4 = NeutralNode(uid_b, [], [condition2], aliasZ) node3 = NeutralNode(uid_a, [], [condition1], aliasY) node2 = ExistsNode(uid_d, [node3, node4], [], aliasX) node1 = ExistsNode(0, [node2], [], None) #Formula tree logicFormulaTree = LogicFormulaTree([node1]) #just one node at root central.submitFormula(logicFormulaTree) central.valuate() #import values of parameters from the device META-CLI tmp = central.compute() #compute conditions of the validation tree thanks to the imported values. Return true if the logic formula is verified. print "** FINAL RESULT of computing for all devices : "+str(tmp) print "*** END ***"
def main(): print "*** START ***\n" #Loading IOS Reference (ALL commands and parameters available in a device, i.e. documentation) iosReference = IOSReference(minidom.parse('../TestFiles/IOSRef_AlgoValidation.xml')) #Loading devices connected to the network # USING Configuration #3 : 10 devices device1 = Device(minidom.parse('../TestFiles/DevicesConf3/Device1.xml'), iosReference) device2 = Device(minidom.parse('../TestFiles/DevicesConf3/Device2.xml'), iosReference) device3 = Device(minidom.parse('../TestFiles/DevicesConf3/Device3.xml'), iosReference) device4 = Device(minidom.parse('../TestFiles/DevicesConf3/Device4.xml'), iosReference) device5 = Device(minidom.parse('../TestFiles/DevicesConf3/Device5.xml'), iosReference) device6 = Device(minidom.parse('../TestFiles/DevicesConf3/Device6.xml'), iosReference) device7 = Device(minidom.parse('../TestFiles/DevicesConf3/Device7.xml'), iosReference) device8 = Device(minidom.parse('../TestFiles/DevicesConf3/Device8.xml'), iosReference) device9 = Device(minidom.parse('../TestFiles/DevicesConf3/Device9.xml'), iosReference) device10 = Device(minidom.parse('../TestFiles/DevicesConf3/Device10.xml'), iosReference) print "\n** Building validation tree for formula #4: Exists d=x : Exists d=x, a=y : For all e=w : For all e=w, c=z : y=-1 ^ z=3 \n" ''' ----------- CENTRAL ---------- /\ / \ / \ / \ / \ / \ / \ / \ o EXISTS o FORALL | (node1) | (node2) | | | | | | d=x EXISTS e=w FORALL | (node3) | (node4) | | | | | | a=y (node5) c=z (node6) [cond. y=-1] [cond. z=3] ''' #Central validation (main class) central = CentralValidation() central.addDevice(device1) central.addDevice(device2) central.addDevice(device3) central.addDevice(device4) central.addDevice(device5) central.addDevice(device6) central.addDevice(device7) central.addDevice(device8) central.addDevice(device9) central.addDevice(device10) #aliases w, x, y, z in the nodes aliasW = Alias("w") aliasX = Alias("x") aliasY = Alias("y") aliasZ = Alias("z") uid_a = 101 uid_c = 103 uid_d = 1 uid_e = 2 #condition y=-1 condition1 = Condition("==") condition1.setTerms(AtomicAliasTerm(aliasY), AtomicConstantTerm(-1)) #condition z=3 condition2 = Condition("==") condition2.setTerms(AtomicAliasTerm(aliasZ), AtomicConstantTerm(3)) #nodes node6 = NeutralNode(uid_c, [], [condition2], aliasZ) node5 = NeutralNode(uid_a, [], [condition1], aliasY) node4 = ForAllNode(uid_e, [node6], [], aliasW) node3 = ExistsNode(uid_d, [node5], [], aliasX) node2 = ForAllNode(0, [node4], [], None) node1 = ExistsNode(0, [node3], [], None) #Formula tree logicFormulaTree = LogicFormulaTree([node1, node2]) #two nodes at root central.submitFormula(logicFormulaTree) central.valuate() #import values of parameters from the device META-CLI tmp = central.compute() #compute conditions of the validation tree thanks to the imported values. Return true if the logic formula is verified. print "** FINAL RESULT of computing for all devices : "+str(tmp) print "*** END ***"
def main(): print "*** START ***\n" #Loading IOS Reference (ALL commands and parameters available in a device, i.e. documentation) iosReference = IOSReference(minidom.parse('../TestFiles/IOSRef_AlgoValidation.xml')) #Loading devices connected to the network # USING Configuration #1 : 2 devices device1 = Device(minidom.parse('../TestFiles/DevicesConf1/Device1.xml'), iosReference) device2 = Device(minidom.parse('../TestFiles/DevicesConf1/Device2.xml'), iosReference) print "\n** Building validation tree for formula #1: For all d=x : For all d=x, a=y : y<=0 \n" ''' ----------- CENTRAL ---------- | o (node1) FORALL | | | d=x (node2) FORALL | | | a=y (node3) [cond. y<=0] ''' #Central validation (main class) central = CentralValidation() central.addDevice(device1) central.addDevice(device2) #aliases x and y in the nodes aliasX = Alias("x") aliasY = Alias("y") uid_a = 101 uid_d = 1 #condition y<=0 condition1 = Condition("<=") condition1.setTerms(AtomicAliasTerm(aliasY), AtomicConstantTerm(0)) #nodes node3 = NeutralNode(uid_a, [], [condition1], aliasY) #neutral, with condition y<=0 node2 = ForAllNode(uid_d, [node3], [], aliasX) #no conditions node1 = ForAllNode(0, [node2], [], None) #no conditions and no aliases #Formula tree logicFormulaTree = LogicFormulaTree([node1]) #just one node at root central.submitFormula(logicFormulaTree) central.valuate() #import values of parameters from the device META-CLI tmp = central.compute() #compute conditions of the validation tree thanks to the imported values. Return true if the logic formula is verified. print "** FINAL RESULT of computing for all devices : "+str(tmp) print "*** END ***"