Exemplo n.º 1
0
    def get_acl_dict(self, device):
        """
        Returns a dict of acl mappings for a @device, which is expected to
        be a NetDevice object.

        >>> a.get_acl_dict(dev)
        {'all': set(['115j', 'protectRE', 'protectRE.policer', 'test-bluej',
        'testgreenj', 'testops_blockmj']),
        'explicit': set(['test-bluej', 'testgreenj', 'testops_blockmj']),
        'implicit': set(['115j', 'protectRE', 'protectRE.policer'])}
        """
        acls = {}

        # Explicit (we want to make sure the key exists before we try to assign
        # a value)
        expl_key = 'acls:explicit:%s' % device.nodeName
        if self.redis.exists(expl_key):
            acls['explicit'] = self.redis.smembers(expl_key) or set()
        else:
            acls['explicit'] = set()

        # Implicit (automatically-assigned). We're passing the explicit_acls to
        # autoacl so that we can use them logically for auto assignments.
        acls['implicit'] = autoacl(device, explicit_acls=acls['explicit'])

        # All
        acls['all'] = acls['implicit'] | acls['explicit']

        return acls
Exemplo n.º 2
0
    def get_acl_dict(self, device):
        """
        Returns a dict of acl mappings for a @device, which is expected to
        be a NetDevice object.

        >>> a.get_acl_dict(dev)
        {'all': set(['115j', 'protectRE', 'protectRE.policer', 'test-bluej',
        'testgreenj', 'testops_blockmj']),
        'explicit': set(['test-bluej', 'testgreenj', 'testops_blockmj']),
        'implicit': set(['115j', 'protectRE', 'protectRE.policer'])}
        """
        acls = {}

        # Explicit (we want to make sure the key exists before we try to assign
        # a value)
        expl_key = 'acls:explicit:%s' % device.nodeName
        if self.redis.exists(expl_key):
            acls['explicit'] = self.redis.smembers(expl_key) or set()
        else:
            acls['explicit'] = set()

        # Implicit (automatically-assigned). We're passing the explicit_acls to
        # autoacl so that we can use them logically for auto assignments.
        acls['implicit'] = autoacl(device, explicit_acls=acls['explicit'])

        # All
        acls['all'] = acls['implicit'] | acls['explicit']

        return acls
Exemplo n.º 3
0
def populate_implicit_acls(nd=None):
    """populate acls:implicit (autoacls)"""
    nd = nd or get_netdevices()
    for dev in nd.all():
        [
            r.sadd('acls:implicit:%s' % dev.nodeName, acl)
            for acl in autoacl(dev)
        ]
    r.save()
Exemplo n.º 4
0
def populate_implicit_acls(nd=None):
    """populate acls:implicit (autoacls)"""
    nd = nd or get_netdevices()
    for dev in nd.all():
        [r.sadd('acls:implicit:%s' % dev.nodeName, acl) for acl in autoacl(dev)]
    r.save()