This module contains RuleCondition implementation.
There is no need to import this module directly. Use the methods of the Ruleset object to create and manipulate RuleConditions.
Add new RuleCondition:
>>> # Get netobjects >>> nobj_gotham = rs.object_find("/NetObjects/Gotham") >>> nobj_springfield = rs.object_find("/NetObjects/Springfield") >>> >>> # Rulecondition: Gotham OR Springfield >>> cond_g_or_s = rs.rulecondition_add(rs.RULECONDITION_OR) >>> cond_g_or_s.set_items( >>> [ >>> (rs.CONDITION_NETOBJECT_LOCAL, nobj_gotham.id), >>> (rs.CONDITION_NETOBJECT_LOCAL, nobj_springfield.id) >>> ] >>> ) >>> >>> # New firewall rule: Pacifica >>> fwrule = rs.fwrule_add("Pacifica", rs.FWRULE_ACTION_ACCEPT, rulecondition=cond_g_or_s.id)
Edit existing RuleCondition:
>>> # Get netobject >>> nobj_restricted = rs.object_find("/NetObjects/Restricted Subscribers") >>> >>> # Get rule and its rulecondition >>> fwrule = rs.fwrule_find("Pacifica") >>> cond_g_or_s = fwrule.rulecondition >>> >>> # Rulecondition: NOT Restricted Subscribers >>> cond_not_rs = rs.rulecondition_add(rs.RULECONDITION_NOT) >>> cond_not_rs.set_items( >>> [ >>> (rs.CONDITION_NETOBJECT_LOCAL, nobj_restricted.id) >>> ] >>> ) >>> >>> # Rulecondition: AND (new toplevel condition) >>> cond_and = rs.rulecondition_add(rs.RULECONDITION_AND) >>> cond_and.set_items( >>> [ >>> (rs.CONDITION_RULECONDITION, cond_g_or_s.id), >>> (rs.CONDITION_RULECONDITION, cond_not_rs.id) >>> ] >>> ) >>> >>> # Update the rule with the new conditions >>> fwrule.update(rulecondition=cond_and.id)
The RuleCondition class is used to define and alter ruleconditions in v16.0+.
Methods: | ||
---|---|---|
Ungrouped | remove(self) Removes this rulecondition from pldb |
|
rename(self, name) Renames rulecondition to given name |
||
set_items(self, items) Set items on rulecondition as list of (conditiontype, object id) |
Properties: | |
---|---|
creation_date | creation date of rulecondition |
creator | creator of rulecondition |
id | id number of this rulecondition |
items | Items |
modification_date | latest modification of rulecondition |
modified_by | latest modifier of rulecondition |
name | name of rulecondition |
operator | Operator |
Removes this rulecondition from pldb
Set items on rulecondition as list of (conditiontype, object id)
>>> rulecondition.set_items([(0,285)] >>> rulecondition.items [{'conditiontype': 0, 'objectid': 285}]
list
) - list
of tuple
creation date of rulecondition
creator of rulecondition
id number of this rulecondition
Items
latest modification of rulecondition
latest modifier of rulecondition
name of rulecondition
Operator