提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
checkIntfIntVlanMemberConfigRule = """
(defrule checkSubIntfIntVlanMemberConfigRule
(checkIntf (intf ?intf) )
(SwitchIntfConfig (intf ?intf) (switchportMode "routed") (nativeVlan ?intVlan))
(or (not (VlanStatus (vlan ?intVlan) (intf ?intf)) )
?f <- (VlanStatus (vlan ?intVlan) (intf ?intf)) )
=>
(if (isbound ?f) then (printout t "PASS: vlanStatus exists for " ?intf " " ?intVlan crlf) (return 0) )
(printout t "vlanStatus does not exist for " ?intf " " ?intVlan crlf)
)"""
在上述片段规则中,(isbound?f)的等效片段内置函数是什么? 通常,是否有任何内置函数可以在RHS中检查变量是否在LHS中绑定?
没有确定变量是否已绑定的功能。 通过为or包含的每个条件元素创建规则来实现or条件元素,因此您现有的规则将转换为以下内容:
(defrule checkSubIntfIntVlanMemberConfigRule-1
(checkIntf (intf ?intf) )
(SwitchIntfConfig (intf ?intf) (switchportMode "routed") (nativeVlan ?intVlan))
(not (VlanStatus (vlan ?intVlan) (intf ?intf))
=>
(if (isbound ?f) then (printout t "PASS: vlanStatus exists for " ?intf " " ?intVlan crlf) (return 0) )
(printout t "vlanStatus does not exist for " ?intf " " ?intVlan crlf)
)
(defrule checkSubIntfIntVlanMemberConfigRule-2
(checkIntf (intf ?intf) )
(SwitchIntfConfig (intf ?intf) (switchportMode "routed") (nativeVlan ?intVlan))
?f <- (VlanStatus (vlan ?intVlan) (intf ?intf))
=>
(if (isbound ?f) then (printout t "PASS: vlanStatus exists for " ?intf " " ?intVlan crlf) (return 0) )
(printout t "vlanStatus does not exist for " ?intf " " ?intVlan crlf)
)
您需要将其实现为两个单独的规则,以便每个规则的RHS可以不同:
(defrule checkSubIntfIntVlanMemberConfigRule-1
(checkIntf (intf ?intf) )
(SwitchIntfConfig (intf ?intf) (switchportMode "routed") (nativeVlan ?intVlan))
(not (VlanStatus (vlan ?intVlan) (intf ?intf)))
=>
(printout t "vlanStatus does not exist for " ?intf " " ?intVlan crlf)
)
(defrule checkSubIntfIntVlanMemberConfigRule-2
(checkIntf (intf ?intf) )
(SwitchIntfConfig (intf ?intf) (switchportMode "routed") (nativeVlan ?intVlan))
?f <- (VlanStatus (vlan ?intVlan) (intf ?intf))
=>
(printout t "PASS: vlanStatus exists for " ?intf " " ?intVlan crlf)
)
或者,您可以使用事实查询功能从规则的RHS中测试事实的存在:
(defrule checkSubIntfIntVlanMemberConfigRule
(checkIntf (intf ?intf) )
(SwitchIntfConfig (intf ?intf) (switchportMode "routed") (nativeVlan ?intVlan))
(VlanStatus (vlan ?intVlan) (intf ?intf))
=>
(if (any-factp ((?f VlanStatus)) (and (eq ?f:vlan ?intVlan) (eq ?f:intf ?intf)))
then
(printout t "PASS: vlanStatus exists for " ?intf " " ?intVlan crlf)
else
(printout t "vlanStatus does not exist for " ?intf " " ?intVlan crlf)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.