def grant_permission(username, resource=None, resource_type='keyspace', permission=None, contact_points=None, port=None, cql_user=None, cql_pass=None):
 permission_cql = ('grant {0}'.format(permission) if permission else 'grant all permissions')
 resource_cql = ('on {0} {1}'.format(resource_type, resource) if resource else 'on all keyspaces')
 query = '{0} {1} to {2}'.format(permission_cql, resource_cql, username)
 log.debug("Attempting to grant permissions with query '{0}'".format(query))
 try:
  cql_query(query, contact_points, port, cql_user, cql_pass)
 except CommandExecutionError:
  log.critical('Could not grant permissions.')
  raise
 except BaseException as e:
  log.critical('Unexpected error while granting permissions: {0}'.format(str(e)))
  raise
 return True

def grant_permission ( username , resource = None , resource_type = 'keyspace' , permission = None , contact_points = None , port = None , cql_user = None , cql_pass = None ) : permission_cql = ( 'grant {0}' . format ( permission ) if permission else 'grant all permissions' ) resource_cql = ( 'on {0} {1}' . format ( resource_type , resource ) if resource else 'on all keyspaces' ) query = '{0} {1} to {2}' . format ( permission_cql , resource_cql , username ) log . debug ( "Attempting to grant permissions with query '{0}'" . format ( query ) ) try : cql_query ( query , contact_points , port , cql_user , cql_pass ) except CommandExecutionError : log . critical ( 'Could not grant permissions.' ) raise except BaseException as e : log . critical ( 'Unexpected error while granting permissions: {0}' . format ( str ( e ) ) ) raise return True
grant permissions to a user .