Skip to content

Commit

Permalink
ccmlib: drop cassandra-cli related helpers
Browse files Browse the repository at this point in the history
cassandra-cli was removed in Cassandra 2.2.0. and it was replaced by
cqlsh in newer releases. actually, scylla-tools does not build or
package this command line tool at all. so let's drop the related helpers
for accessing this tool. in a following-up change, we will drop the
thrift related APIs.

Refs scylladb/scylladb#3811
Refs scylladb/scylladb#18416

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
  • Loading branch information
tchaikov committed Apr 29, 2024
1 parent b18f85d commit 60d6c89
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 85 deletions.
7 changes: 0 additions & 7 deletions ccmlib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,6 @@ def stress(self, stress_options):
self.nodelist()[0].stress(stress_options=stress_options + ['-node', ','.join(livenodes)] )
return self

def run_cli(self, cmds=None, show_output=False, cli_options=None):
cli_options = cli_options or []
livenodes = [node for node in list(self.nodes.values()) if node.is_live()]
if len(livenodes) == 0:
raise common.ArgumentError("No live node")
livenodes[0].run_cli(cmds, show_output, cli_options)

def set_configuration_options(self, values=None, batch_commitlog=None):
if values is not None:
for k, v in values.items():
Expand Down
22 changes: 0 additions & 22 deletions ccmlib/cmds/cluster_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,28 +931,6 @@ def run(self):
sys.exit(1)


class ClusterCliCmd(Cmd):

def description(self):
return "Launch cassandra cli connected to some live node (if any)"

def get_parser(self):
usage = "usage: ccm cli [options] [cli_options]"
parser = self._get_default_parser(usage, self.description(), ignore_unknown_options=True)
parser.add_option('-x', '--exec', type="string", dest="cmds", default=None,
help="Execute the specified commands and exit")
parser.add_option('-v', '--verbose', action="store_true", dest="verbose",
help="With --exec, show cli output after completion", default=False)
return parser

def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, load_cluster=True)
self.cli_options = parser.get_ignored() + args[1:]

def run(self):
self.cluster.run_cli(self.options.cmds, self.options.verbose, self.cli_options)


class ClusterBulkloadCmd(Cmd):

def description(self):
Expand Down
22 changes: 0 additions & 22 deletions ccmlib/cmds/node_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,28 +365,6 @@ def run(self):
self.node.dsetool(" ".join(self.args[1:]))


class NodeCliCmd(Cmd):

def description(self):
return "Launch a cassandra cli connected to this node"

def get_parser(self):
usage = "usage: ccm node_name cli [options] [cli_options]"
parser = self._get_default_parser(usage, self.description(), ignore_unknown_options=True)
parser.add_option('-x', '--exec', type="string", dest="cmds", default=None,
help="Execute the specified commands and exit")
parser.add_option('-v', '--verbose', action="store_true", dest="verbose",
help="With --exec, show cli output after completion", default=False)
return parser

def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, node_name=True, load_cluster=True)
self.cli_options = parser.get_ignored() + args[1:]

def run(self):
self.node.run_cli(self.options.cmds, self.options.verbose, self.cli_options)


class NodeCqlshCmd(Cmd):

def description(self):
Expand Down
34 changes: 0 additions & 34 deletions ccmlib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,31 +900,6 @@ def verify(self, options):
env = self.get_env()
os.execve(verify_bin, [common.platform_binary('sstableverify')] + options, env)

def run_cli(self, cmds=None, show_output=False, cli_options=[]):
cli = self.get_tool('cassandra-cli')
env = self.get_env()
host = self.network_interfaces['thrift'][0]
port = self.network_interfaces['thrift'][1]
args = ['-h', host, '-p', str(port), '--jmxport', str(self.jmx_port)] + cli_options
sys.stdout.flush()
if cmds is None:
os.execve(cli, [common.platform_binary('cassandra-cli')] + args, env)
else:
p = subprocess.Popen([cli] + args, env=env, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True)
for cmd in cmds.split(';'):
p.stdin.write(cmd + ';\n')
p.stdin.write("quit;\n")
p.wait()
for err in p.stderr.readlines():
print("(EE) ", err, end='')
if show_output:
i = 0
for log in p.stdout.readlines():
# first four lines are not interesting
if i >= 4:
print(log, end='')
i = i + 1

def run_cqlsh(self, cmds=None, show_output=False, cqlsh_options=None, return_output=False, timeout=600, extra_env=None):
cqlsh_options = cqlsh_options or []
cqlsh = self.get_tool('cqlsh')
Expand Down Expand Up @@ -978,15 +953,6 @@ def run_cqlsh(self, cmds=None, show_output=False, cqlsh_options=None, return_out
if return_output:
return output

def cli(self):
cdir = self.get_install_dir()
cli = common.join_bin(cdir, 'bin', 'cassandra-cli')
env = self.get_env()
host = self.network_interfaces['thrift'][0]
port = self.network_interfaces['thrift'][1]
args = ['-h', host, '-p', str(port), '--jmxport', str(self.jmx_port)]
return CliSession(subprocess.Popen([cli] + args, env=env, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True))

def set_log_level(self, new_level, class_name=None):
known_level = ['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'OFF']
if new_level not in known_level:
Expand Down

0 comments on commit 60d6c89

Please sign in to comment.