cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [2/2] cassandra git commit: Merge branch 'cassandra-2.1' into trunk
Date Tue, 21 Apr 2015 17:24:57 GMT
Merge branch 'cassandra-2.1' into trunk

Conflicts:
	bin/cqlsh


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/840d9a66
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/840d9a66
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/840d9a66

Branch: refs/heads/trunk
Commit: 840d9a663295fa0bfb78fb9706aa8400004e0b30
Parents: b379e32 49c1dbd
Author: Tyler Hobbs <tylerlhobbs@gmail.com>
Authored: Tue Apr 21 12:24:47 2015 -0500
Committer: Tyler Hobbs <tylerlhobbs@gmail.com>
Committed: Tue Apr 21 12:24:47 2015 -0500

----------------------------------------------------------------------
 bin/cqlsh | 88 +++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 60 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/840d9a66/bin/cqlsh
----------------------------------------------------------------------
diff --cc bin/cqlsh
index 2078107,05f3368..9dffa7f
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@@ -111,8 -112,7 +112,7 @@@ from cassandra.cluster import Cluster, 
  from cassandra.query import SimpleStatement, ordered_dict_factory
  from cassandra.policies import WhiteListRoundRobinPolicy
  from cassandra.protocol import QueryMessage, ResultMessage
- from cassandra.marshal import int16_pack, int32_pack, uint64_pack
 -from cassandra.metadata import protect_name, protect_names, protect_value
 +from cassandra.metadata import protect_name, protect_names, protect_value, KeyspaceMetadata,
TableMetadata, ColumnMetadata
  from cassandra.auth import PlainTextAuthProvider
  
  # cqlsh should run correctly when run out of a Cassandra source tree,
@@@ -436,7 -456,8 +457,8 @@@ def full_cql_version(ver)
      vertuple = tuple(map(int, ver_parts[0].split('.')) + [ver_parts[1]])
      return ver, vertuple
  
+ 
 -def format_value(val, output_encoding, addcolor=False, time_format=None,
 +def format_value(val, output_encoding, addcolor=False, date_time_format=None,
                   float_precision=None, colormap=None, nullval=None):
      if isinstance(val, DecodeError):
          if addcolor:
@@@ -444,9 -465,10 +466,10 @@@
          else:
              return FormattedValue(repr(val.thebytes))
      return format_by_type(type(val), val, output_encoding, colormap=colormap,
 -                          addcolor=addcolor, nullval=nullval, time_format=time_format,
 +                          addcolor=addcolor, nullval=nullval, date_time_format=date_time_format,
                            float_precision=float_precision)
  
+ 
  def show_warning_without_quoting_line(message, category, filename, lineno, file=None, line=None):
      if file is None:
          file = sys.stderr
@@@ -769,32 -782,10 +795,32 @@@ class Shell(cmd.Cmd)
          ksmeta = self.get_keyspace_meta(ksname)
  
          if tablename not in ksmeta.tables:
-             if ksname == 'system_auth' and tablename in ['roles','role_permissions']:
++            if ksname == 'system_auth' and tablename in ['roles', 'role_permissions']:
 +                self.get_fake_auth_table_meta(ksname, tablename)
 +            else:
 +                raise ColumnFamilyNotFound("Column family %r not found" % tablename)
 +        else:
 +            return ksmeta.tables[tablename]
 +
 +    def get_fake_auth_table_meta(self, ksname, tablename):
 +        # may be using external auth implementation so internal tables
 +        # aren't actually defined in schema. In this case, we'll fake
 +        # them up
 +        if tablename == 'roles':
 +            ks_meta = KeyspaceMetadata(ksname, True, None, None)
 +            table_meta = TableMetadata(ks_meta, 'roles')
 +            table_meta.columns['role'] = ColumnMetadata(table_meta, 'role', cassandra.cqltypes.UTF8Type)
 +            table_meta.columns['is_superuser'] = ColumnMetadata(table_meta, 'is_superuser',
cassandra.cqltypes.BooleanType)
 +            table_meta.columns['can_login'] = ColumnMetadata(table_meta, 'can_login', cassandra.cqltypes.BooleanType)
 +        elif tablename == 'role_permissions':
 +            ks_meta = KeyspaceMetadata(ksname, True, None, None)
 +            table_meta = TableMetadata(ks_meta, 'role_permissions')
 +            table_meta.columns['role'] = ColumnMetadata(table_meta, 'role', cassandra.cqltypes.UTF8Type)
 +            table_meta.columns['resource'] = ColumnMetadata(table_meta, 'resource', cassandra.cqltypes.UTF8Type)
 +            table_meta.columns['permission'] = ColumnMetadata(table_meta, 'permission',
cassandra.cqltypes.UTF8Type)
 +        else:
-             raise ColumnFamilyNotFoundException("Column family %r not found" % tablename)
+             raise ColumnFamilyNotFound("Column family %r not found" % tablename)
  
 -        return ksmeta.tables[tablename]
 -
      def get_usertypes_meta(self):
          data = self.session.execute("select * from system.schema_usertypes")
          if not data:
@@@ -1045,10 -1035,10 +1070,10 @@@
  
          if statement.query_string[:6].lower() == 'select':
              self.print_result(rows, self.parse_for_table_meta(statement.query_string))
 -        elif statement.query_string.lower().startswith("list users"):
 -            self.print_result(rows, self.get_table_meta('system_auth', 'users'))
 +        elif statement.query_string.lower().startswith("list users") or statement.query_string.lower().startswith("list
roles"):
-             self.print_result(rows, self.get_table_meta('system_auth','roles'))
++            self.print_result(rows, self.get_table_meta('system_auth', 'roles'))
          elif statement.query_string.lower().startswith("list"):
-             self.print_result(rows, self.get_table_meta('system_auth','role_permissions'))
 -            self.print_result(rows, self.get_table_meta('system_auth', 'permissions'))
++            self.print_result(rows, self.get_table_meta('system_auth', 'role_permissions'))
          elif rows:
              # CAS INSERT/UPDATE
              self.writeresult("")


Mime
View raw message