You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/05/15 18:41:41 UTC
cassandra git commit: cqlsh: Add LOGIN command to switch users
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.0 d4755287a -> 0b92967d3
cqlsh: Add LOGIN command to switch users
Patch by Sachin Janani and Carl Yeksigian; reviewed by Tyler Hobbs for
CASSANDRA-7212
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0b92967d
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0b92967d
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0b92967d
Branch: refs/heads/cassandra-2.0
Commit: 0b92967d3046ce7893106fd587fc553badc12280
Parents: d475528
Author: Carl Yeksigian <ca...@apache.org>
Authored: Fri May 15 11:36:06 2015 -0500
Committer: Tyler Hobbs <ty...@gmail.com>
Committed: Fri May 15 11:36:06 2015 -0500
----------------------------------------------------------------------
CHANGES.txt | 1 +
bin/cqlsh | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b92967d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 00cc335..a9d04d6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.0.16:
+ * (cqlsh) Add LOGIN command to switch users (CASSANDRA-7212)
* Clone SliceQueryFilter in AbstractReadCommand implementations (CASSANDRA-8940)
* Push correct protocol notification for DROP INDEX (CASSANDRA-9310)
* token-generator - generated tokens too long (CASSANDRA-9300)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b92967d/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index a165dca..fa0de7f 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -197,6 +197,7 @@ my_commands_ending_with_newline = (
'show',
'source',
'capture',
+ 'login',
'debug',
'tracing',
'expand',
@@ -222,6 +223,7 @@ cqlsh_extra_syntax_rules = r'''
| <sourceCommand>
| <captureCommand>
| <copyCommand>
+ | <loginCommand>
| <debugCommand>
| <helpCommand>
| <tracingCommand>
@@ -290,6 +292,9 @@ cqlsh_extra_syntax_rules = r'''
<expandCommand> ::= "EXPAND" ( switch=( "ON" | "OFF" ) )?
;
+<loginCommand> ::= "LOGIN" username=<username> (password=<stringLiteral>)?
+ ;
+
<exitCommand> ::= "exit" | "quit"
;
@@ -1825,6 +1830,35 @@ class Shell(cmd.Cmd):
self.cursor.consistency_level = level.upper()
print 'Consistency level set to %s.' % (level.upper(),)
+ def do_login(self, parsed):
+ """
+ LOGIN [cqlsh only]
+
+ Changes login information without requiring restart.
+
+ LOGIN <username> (<password>)
+
+ Login using the specified username. If password is specified, it will be used
+ otherwise, you will be prompted to enter.
+ """
+ username = parsed.get_binding('username')
+ password = parsed.get_binding('password')
+ if password is None:
+ password = getpass.getpass()
+ else:
+ password = password[1:-1]
+
+ transport = self.transport_factory(self.hostname, self.port, os.environ, CONFIG_FILE)
+ conn = cql.connect(self.hostname, self.port, keyspace=self.current_keyspace, user=username,
+ password=password, cql_version=self.conn.cql_version,
+ transport=transport)
+
+ self.username = username
+ self.password = password
+ self.conn=conn
+ self.cursor = self.conn.cursor()
+ self.get_connection_versions()
+
def do_exit(self, parsed=None):
"""
EXIT/QUIT [cqlsh only]