Esempio n. 1
0
    def remove_permission(self, permission):
        """Remove a permission from the group"""
        self._get_registered_object('auth').assert_permission(PERMISSIONS.MANAGE_GROUPS)

        ArgumentValidator.validate_permission(permission)
        permission_enum = PERMISSIONS[permission]

        if permission_enum not in self.get_permissions():
            raise GroupDoesNotContainPermissionError(
                'Group \'%s\' does not contain permission \'%s\'' %
                (self.name, permission))

        cluster = self._get_registered_object('cluster')
        self.remove_permission_from_config(permission, nodes=cluster.get_nodes(include_local=True))
Esempio n. 2
0
    def add_permission(self, permission):
        """Add a permission to the group"""
        self._get_registered_object('auth').assert_permission(PERMISSIONS.MANAGE_GROUPS)

        # Check that permission is valid
        ArgumentValidator.validate_permission(permission)

        permission_enum = PERMISSIONS[permission]
        if permission_enum in self.get_permissions():
            raise GroupAlreadyContainsPermissionError(
                'Group \'%s\' already contains permission \'%s\'' %
                (self.name, permission))

        cluster = self._get_registered_object('cluster')
        self.add_permission_to_config(permission, nodes=cluster.get_nodes(include_local=True))