mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-2.0' into cassandra-2.1
This commit is contained in:
commit
9f8c45d6d6
|
|
@ -25,6 +25,7 @@
|
|||
* Fix streaming not holding ref when stream error (CASSANDRA-9295)
|
||||
* Fix canonical view returning early opened SSTables (CASSANDRA-9396)
|
||||
Merged from 2.0:
|
||||
* (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)
|
||||
|
|
|
|||
42
bin/cqlsh
42
bin/cqlsh
|
|
@ -222,6 +222,7 @@ my_commands_ending_with_newline = (
|
|||
'show',
|
||||
'source',
|
||||
'capture',
|
||||
'login',
|
||||
'debug',
|
||||
'tracing',
|
||||
'expand',
|
||||
|
|
@ -253,6 +254,7 @@ cqlsh_extra_syntax_rules = r'''
|
|||
| <sourceCommand>
|
||||
| <captureCommand>
|
||||
| <copyCommand>
|
||||
| <loginCommand>
|
||||
| <debugCommand>
|
||||
| <helpCommand>
|
||||
| <tracingCommand>
|
||||
|
|
@ -334,6 +336,9 @@ cqlsh_extra_syntax_rules = r'''
|
|||
<pagingCommand> ::= "PAGING" ( switch=( "ON" | "OFF" ) )?
|
||||
;
|
||||
|
||||
<loginCommand> ::= "LOGIN" username=<username> (password=<stringLiteral>)?
|
||||
;
|
||||
|
||||
<exitCommand> ::= "exit" | "quit"
|
||||
;
|
||||
|
||||
|
|
@ -1973,6 +1978,43 @@ class Shell(cmd.Cmd):
|
|||
self.serial_consistency_level = cassandra.ConsistencyLevel.name_to_value[level.upper()]
|
||||
print 'Serial 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]
|
||||
|
||||
auth_provider = PlainTextAuthProvider(username=username, password=password)
|
||||
|
||||
conn = Cluster(contact_points=(self.hostname,), port=self.port, cql_version=self.conn.cql_version,
|
||||
protocol_version=DEFAULT_PROTOCOL_VERSION,
|
||||
auth_provider=auth_provider,
|
||||
ssl_options=self.conn.ssl_options,
|
||||
load_balancing_policy=WhiteListRoundRobinPolicy([self.hostname]))
|
||||
|
||||
if self.current_keyspace:
|
||||
session = conn.connect(self.current_keyspace)
|
||||
else:
|
||||
session = conn.connect()
|
||||
|
||||
# Update after we've connected in case we fail to authenticate
|
||||
self.conn = conn
|
||||
self.auth_provider = auth_provider
|
||||
self.username = username
|
||||
self.session = session
|
||||
|
||||
def do_exit(self, parsed=None):
|
||||
"""
|
||||
EXIT/QUIT [cqlsh only]
|
||||
|
|
|
|||
Loading…
Reference in New Issue