What are presence classes?

According to RFC 6020, YANG supports two styles of containers. One is for organizing hierarchy. Another type (called ‘presence container’) is for representing configuration data. For instance the existence of presence container ssh indicates the capability to log in to the device using ssh. Let us consider a presence node match-community-set in openconfig-bgp-policy.yang. This node is generated as a YDK class shown below:

 1class BgpConditions(Entity):
 2    """
 3    ...
 4
 5    .. attribute:: match_community_set
 6
 7    Match a referenced community\-set according to the logic defined in the match\-set\-options leaf
 8    **type**\:   :py:class:`MatchCommunitySet <ydk.models.openconfig.openconfig_routing_policy.RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements.Statement.Conditions.BgpConditions.MatchCommunitySet>`
 9
10    **presence node**\: True
11
12    ...
13
14    """
15
16    ...
17
18    def __init__(self):
19        super(RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements.Statement.Conditions.BgpConditions, self).__init__()
20
21        self.yang_name = "bgp-conditions"
22        self.yang_parent_name = "conditions"
23
24        ...
25
26        self.match_community_set = None
27
28        ...

Since the existence of container match_community_set itself represents configuration data, YDK does not instantiate an instance of class MatchCommunitySet and assign it to the match_community_set leaf. The user needs to manually instantiate and assign this object.