kaqing 2.0.200__py3-none-any.whl → 2.0.211__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kaqing might be problematic. Click here for more details.
- adam/batch.py +1 -1
- adam/commands/app/utils_app.py +1 -1
- adam/commands/cql/completions_c.py +1 -1
- adam/commands/cql/utils_cql.py +14 -13
- adam/commands/devices/device.py +1 -1
- adam/commands/download_cassandra_log.py +2 -2
- adam/commands/export/export_databases.py +13 -8
- adam/commands/export/export_sessions.py +12 -11
- adam/commands/export/exporter.py +140 -53
- adam/commands/export/import_session.py +0 -4
- adam/commands/export/importer.py +11 -11
- adam/commands/export/importer_athena.py +15 -6
- adam/commands/export/importer_sqlite.py +19 -8
- adam/commands/export/utils_export.py +37 -15
- adam/commands/postgres/postgres_databases.py +1 -1
- adam/commands/postgres/postgres_ls.py +1 -1
- adam/commands/postgres/utils_postgres.py +2 -1
- adam/commands/show/show_cassandra_status.py +3 -10
- adam/commands/show/show_processes.py +1 -1
- adam/commands/show/show_storage.py +2 -1
- adam/embedded_params.py +1 -1
- adam/repl_commands.py +13 -12
- adam/sso/cred_cache.py +2 -5
- adam/utils.py +122 -71
- adam/utils_k8s/app_clusters.py +10 -3
- adam/utils_k8s/app_pods.py +9 -3
- adam/utils_k8s/cassandra_clusters.py +4 -4
- adam/utils_k8s/cassandra_nodes.py +13 -7
- adam/{pod_exec_result.py → utils_k8s/pod_exec_result.py} +8 -2
- adam/utils_k8s/pods.py +34 -29
- adam/utils_local.py +78 -2
- adam/utils_repl/repl_completer.py +6 -2
- adam/utils_sqlite.py +3 -8
- adam/version.py +1 -1
- {kaqing-2.0.200.dist-info → kaqing-2.0.211.dist-info}/METADATA +1 -1
- {kaqing-2.0.200.dist-info → kaqing-2.0.211.dist-info}/RECORD +39 -61
- adam/commands/alter_tables.py +0 -66
- adam/commands/cassandra/download_cassandra_log.py +0 -45
- adam/commands/cassandra/nodetool.py +0 -64
- adam/commands/cassandra/nodetool_commands.py +0 -120
- adam/commands/cassandra/restart_cluster.py +0 -47
- adam/commands/cassandra/restart_node.py +0 -51
- adam/commands/cassandra/restart_nodes.py +0 -47
- adam/commands/cassandra/rollout.py +0 -88
- adam/commands/cat.py +0 -36
- adam/commands/cd.py +0 -41
- adam/commands/download_file.py +0 -47
- adam/commands/find_files.py +0 -51
- adam/commands/find_processes.py +0 -76
- adam/commands/head.py +0 -36
- adam/commands/ls.py +0 -41
- adam/commands/os/cat.py +0 -36
- adam/commands/os/download_file.py +0 -47
- adam/commands/os/find_files.py +0 -51
- adam/commands/os/find_processes.py +0 -76
- adam/commands/os/head.py +0 -36
- adam/commands/os/shell.py +0 -41
- adam/commands/shell.py +0 -41
- {kaqing-2.0.200.dist-info → kaqing-2.0.211.dist-info}/WHEEL +0 -0
- {kaqing-2.0.200.dist-info → kaqing-2.0.211.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.200.dist-info → kaqing-2.0.211.dist-info}/top_level.txt +0 -0
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
NODETOOL_COMMANDS = [
|
|
2
|
-
'assassinate',
|
|
3
|
-
'bootstrap',
|
|
4
|
-
'cleanup',
|
|
5
|
-
'clearsnapshot',
|
|
6
|
-
'clientstats',
|
|
7
|
-
'compact',
|
|
8
|
-
'compactionhistory',
|
|
9
|
-
'compactionstats',
|
|
10
|
-
'decommission',
|
|
11
|
-
'describecluster',
|
|
12
|
-
'describering',
|
|
13
|
-
'disableauditlog',
|
|
14
|
-
'disableautocompaction',
|
|
15
|
-
'disablebackup',
|
|
16
|
-
'disablebinary',
|
|
17
|
-
'disablefullquerylog',
|
|
18
|
-
'disablegossip',
|
|
19
|
-
'disablehandoff',
|
|
20
|
-
'disablehintsfordc',
|
|
21
|
-
'disableoldprotocolversions',
|
|
22
|
-
'drain',
|
|
23
|
-
'enableauditlog',
|
|
24
|
-
'enableautocompaction',
|
|
25
|
-
'enablebackup',
|
|
26
|
-
'enablebinary',
|
|
27
|
-
'enablefullquerylog',
|
|
28
|
-
'enablegossip',
|
|
29
|
-
'enablehandoff',
|
|
30
|
-
'enablehintsfordc',
|
|
31
|
-
'enableoldprotocolversions',
|
|
32
|
-
'failuredetector',
|
|
33
|
-
'flush',
|
|
34
|
-
'garbagecollect',
|
|
35
|
-
'gcstats',
|
|
36
|
-
'getbatchlogreplaythrottle',
|
|
37
|
-
'getcompactionthreshold',
|
|
38
|
-
'getcompactionthroughput',
|
|
39
|
-
'getconcurrency',
|
|
40
|
-
'getconcurrentcompactors',
|
|
41
|
-
'getconcurrentviewbuilders',
|
|
42
|
-
'getendpoints',
|
|
43
|
-
'getfullquerylog',
|
|
44
|
-
'getinterdcstreamthroughput',
|
|
45
|
-
'getlogginglevels',
|
|
46
|
-
'getmaxhintwindow',
|
|
47
|
-
'getseeds',
|
|
48
|
-
'getsnapshotthrottle',
|
|
49
|
-
'getsstables',
|
|
50
|
-
'getstreamthroughput',
|
|
51
|
-
'gettimeout',
|
|
52
|
-
'gettraceprobability',
|
|
53
|
-
'gossipinfo',
|
|
54
|
-
'help',
|
|
55
|
-
'import',
|
|
56
|
-
'info',
|
|
57
|
-
'invalidatecountercache',
|
|
58
|
-
'invalidatekeycache',
|
|
59
|
-
'invalidaterowcache',
|
|
60
|
-
'join',
|
|
61
|
-
'listsnapshots',
|
|
62
|
-
'move',
|
|
63
|
-
'netstats',
|
|
64
|
-
'pausehandoff',
|
|
65
|
-
'profileload',
|
|
66
|
-
'proxyhistograms',
|
|
67
|
-
'rangekeysample',
|
|
68
|
-
'rebuild',
|
|
69
|
-
'rebuild_index',
|
|
70
|
-
'refresh',
|
|
71
|
-
'refreshsizeestimates',
|
|
72
|
-
'reloadlocalschema',
|
|
73
|
-
'reloadseeds',
|
|
74
|
-
'reloadssl',
|
|
75
|
-
'reloadtriggers',
|
|
76
|
-
'relocatesstables',
|
|
77
|
-
'removenode',
|
|
78
|
-
'repair',
|
|
79
|
-
'repair_admin',
|
|
80
|
-
'replaybatchlog',
|
|
81
|
-
'resetfullquerylog',
|
|
82
|
-
'resetlocalschema',
|
|
83
|
-
'resumehandoff',
|
|
84
|
-
'ring',
|
|
85
|
-
'scrub',
|
|
86
|
-
'setbatchlogreplaythrottle',
|
|
87
|
-
'setcachecapacity',
|
|
88
|
-
'setcachekeystosave',
|
|
89
|
-
'setcompactionthreshold',
|
|
90
|
-
'setcompactionthroughput',
|
|
91
|
-
'setconcurrency',
|
|
92
|
-
'setconcurrentcompactors',
|
|
93
|
-
'setconcurrentviewbuilders',
|
|
94
|
-
'sethintedhandoffthrottlekb',
|
|
95
|
-
'setinterdcstreamthroughput',
|
|
96
|
-
'setlogginglevel',
|
|
97
|
-
'setmaxhintwindow',
|
|
98
|
-
'setsnapshotthrottle',
|
|
99
|
-
'setstreamthroughput',
|
|
100
|
-
'settimeout',
|
|
101
|
-
'settraceprobability',
|
|
102
|
-
'sjk',
|
|
103
|
-
'snapshot',
|
|
104
|
-
'status',
|
|
105
|
-
'statusautocompaction',
|
|
106
|
-
'statusbackup',
|
|
107
|
-
'statusbinary',
|
|
108
|
-
'statusgossip',
|
|
109
|
-
'statushandoff',
|
|
110
|
-
'stop',
|
|
111
|
-
'stopdaemon',
|
|
112
|
-
'tablehistograms',
|
|
113
|
-
'tablestats',
|
|
114
|
-
'toppartitions',
|
|
115
|
-
'tpstats',
|
|
116
|
-
'truncatehints',
|
|
117
|
-
'upgradesstables',
|
|
118
|
-
'verify',
|
|
119
|
-
'version',
|
|
120
|
-
'viewbuildstatus']
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from adam.commands import extract_options
|
|
2
|
-
from adam.commands.command import Command
|
|
3
|
-
from adam.utils_k8s.pods import Pods
|
|
4
|
-
from adam.utils_k8s.statefulsets import StatefulSets
|
|
5
|
-
from adam.repl_state import ReplState, RequiredState
|
|
6
|
-
from adam.utils import log2
|
|
7
|
-
|
|
8
|
-
class RestartCluster(Command):
|
|
9
|
-
COMMAND = 'restart cluster'
|
|
10
|
-
|
|
11
|
-
# the singleton pattern
|
|
12
|
-
def __new__(cls, *args, **kwargs):
|
|
13
|
-
if not hasattr(cls, 'instance'): cls.instance = super(RestartCluster, cls).__new__(cls)
|
|
14
|
-
|
|
15
|
-
return cls.instance
|
|
16
|
-
|
|
17
|
-
def __init__(self, successor: Command=None):
|
|
18
|
-
super().__init__(successor)
|
|
19
|
-
|
|
20
|
-
def command(self):
|
|
21
|
-
return RestartCluster.COMMAND
|
|
22
|
-
|
|
23
|
-
def required(self):
|
|
24
|
-
return RequiredState.CLUSTER
|
|
25
|
-
|
|
26
|
-
def run(self, cmd: str, state: ReplState):
|
|
27
|
-
if not(args := self.args(cmd)):
|
|
28
|
-
return super().run(cmd, state)
|
|
29
|
-
|
|
30
|
-
with self.validate(args, state) as (args, state):
|
|
31
|
-
with extract_options(args, '--force') as (args, forced):
|
|
32
|
-
if not forced:
|
|
33
|
-
log2('Please add --force for restarting all nodes in a cluster.')
|
|
34
|
-
|
|
35
|
-
return 'force-needed'
|
|
36
|
-
|
|
37
|
-
log2(f'Restarting all pods from {state.sts}...')
|
|
38
|
-
for pod_name in StatefulSets.pod_names(state.sts, state.namespace):
|
|
39
|
-
Pods.delete(pod_name, state.namespace)
|
|
40
|
-
|
|
41
|
-
return state
|
|
42
|
-
|
|
43
|
-
def completion(self, state: ReplState):
|
|
44
|
-
return super().completion(state, {'--force': None})
|
|
45
|
-
|
|
46
|
-
def help(self, _: ReplState):
|
|
47
|
-
return f"{RestartCluster.COMMAND} --force\t restart all the nodes in the cluster"
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
from adam.commands import extract_options
|
|
2
|
-
from adam.commands.command import Command
|
|
3
|
-
from adam.commands.devices.devices import Devices
|
|
4
|
-
from adam.utils_k8s.pods import Pods
|
|
5
|
-
from adam.repl_state import ReplState, RequiredState
|
|
6
|
-
from adam.utils import log2
|
|
7
|
-
|
|
8
|
-
class RestartNode(Command):
|
|
9
|
-
COMMAND = 'restart node'
|
|
10
|
-
|
|
11
|
-
# the singleton pattern
|
|
12
|
-
def __new__(cls, *args, **kwargs):
|
|
13
|
-
if not hasattr(cls, 'instance'): cls.instance = super(RestartNode, cls).__new__(cls)
|
|
14
|
-
|
|
15
|
-
return cls.instance
|
|
16
|
-
|
|
17
|
-
def __init__(self, successor: Command=None):
|
|
18
|
-
super().__init__(successor)
|
|
19
|
-
|
|
20
|
-
def command(self):
|
|
21
|
-
return RestartNode.COMMAND
|
|
22
|
-
|
|
23
|
-
def required(self):
|
|
24
|
-
return RequiredState.POD
|
|
25
|
-
|
|
26
|
-
def run(self, cmd: str, state: ReplState):
|
|
27
|
-
if not(args := self.args(cmd)):
|
|
28
|
-
return super().run(cmd, state)
|
|
29
|
-
|
|
30
|
-
with self.validate(args, state) as (args, state):
|
|
31
|
-
if not state.pod:
|
|
32
|
-
log2("'pod' is required")
|
|
33
|
-
|
|
34
|
-
return 'pod-needed'
|
|
35
|
-
|
|
36
|
-
with extract_options(args, '--force') as (args, forced):
|
|
37
|
-
if not forced:
|
|
38
|
-
log2('Please add --force for restarting pod.')
|
|
39
|
-
|
|
40
|
-
return 'force-needed'
|
|
41
|
-
|
|
42
|
-
log2(f'Restarting {state.pod}...')
|
|
43
|
-
Pods.delete(state.pod, state.namespace)
|
|
44
|
-
|
|
45
|
-
return state
|
|
46
|
-
|
|
47
|
-
def completion(self, state: ReplState):
|
|
48
|
-
return super().completion(state, {'--force': None}, pods=Devices.of(state).pods(state, '-'))
|
|
49
|
-
|
|
50
|
-
def help(self, _: ReplState):
|
|
51
|
-
return f"{RestartNode.COMMAND} --force\t restart the node"
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from adam.commands import extract_options, validate_args
|
|
2
|
-
from adam.commands.command import Command
|
|
3
|
-
from adam.utils_k8s.pods import Pods
|
|
4
|
-
from adam.utils_k8s.statefulsets import StatefulSets
|
|
5
|
-
from adam.repl_state import ReplState, RequiredState
|
|
6
|
-
from adam.utils import log2
|
|
7
|
-
|
|
8
|
-
class RestartNodes(Command):
|
|
9
|
-
COMMAND = 'restart nodes'
|
|
10
|
-
|
|
11
|
-
# the singleton pattern
|
|
12
|
-
def __new__(cls, *args, **kwargs):
|
|
13
|
-
if not hasattr(cls, 'instance'): cls.instance = super(RestartNodes, cls).__new__(cls)
|
|
14
|
-
|
|
15
|
-
return cls.instance
|
|
16
|
-
|
|
17
|
-
def __init__(self, successor: Command=None):
|
|
18
|
-
super().__init__(successor)
|
|
19
|
-
|
|
20
|
-
def command(self):
|
|
21
|
-
return RestartNodes.COMMAND
|
|
22
|
-
|
|
23
|
-
def required(self):
|
|
24
|
-
return RequiredState.CLUSTER
|
|
25
|
-
|
|
26
|
-
def run(self, cmd: str, state: ReplState):
|
|
27
|
-
if not(args := self.args(cmd)):
|
|
28
|
-
return super().run(cmd, state)
|
|
29
|
-
|
|
30
|
-
with self.validate(args, state, apply=False) as (args, state):
|
|
31
|
-
with extract_options(args, '--force') as (args, forced):
|
|
32
|
-
with validate_args(args, state, name='pod name'):
|
|
33
|
-
if not forced:
|
|
34
|
-
log2('Please add --force for restarting nodes.')
|
|
35
|
-
|
|
36
|
-
return 'force-needed'
|
|
37
|
-
|
|
38
|
-
for arg in args:
|
|
39
|
-
Pods.delete(arg, state.namespace)
|
|
40
|
-
|
|
41
|
-
return state
|
|
42
|
-
|
|
43
|
-
def completion(self, state: ReplState):
|
|
44
|
-
return super().completion(state, lambda: {p: {'--force': None} for p in StatefulSets.pod_names(state.sts, state.namespace)})
|
|
45
|
-
|
|
46
|
-
def help(self, _: ReplState):
|
|
47
|
-
return f"{RestartNodes.COMMAND} <pod-name>... --force\t restart Cassandra nodes"
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
from kubernetes import client
|
|
3
|
-
from kubernetes.client.rest import ApiException
|
|
4
|
-
|
|
5
|
-
from adam.commands import extract_options
|
|
6
|
-
from adam.commands.command import Command
|
|
7
|
-
from adam.commands.watch import Watch
|
|
8
|
-
from adam.utils_k8s.statefulsets import StatefulSets
|
|
9
|
-
from adam.config import Config
|
|
10
|
-
from adam.repl_state import ReplState, RequiredState
|
|
11
|
-
from adam.utils import duration, log2
|
|
12
|
-
|
|
13
|
-
class RollOut(Command):
|
|
14
|
-
COMMAND = 'rollout'
|
|
15
|
-
|
|
16
|
-
# the singleton pattern
|
|
17
|
-
def __new__(cls, *args, **kwargs):
|
|
18
|
-
if not hasattr(cls, 'instance'): cls.instance = super(RollOut, cls).__new__(cls)
|
|
19
|
-
|
|
20
|
-
return cls.instance
|
|
21
|
-
|
|
22
|
-
def __init__(self, successor: Command=None):
|
|
23
|
-
super().__init__(successor)
|
|
24
|
-
|
|
25
|
-
def command(self):
|
|
26
|
-
return RollOut.COMMAND
|
|
27
|
-
|
|
28
|
-
def required(self):
|
|
29
|
-
return RequiredState.CLUSTER
|
|
30
|
-
|
|
31
|
-
def run(self, cmd: str, state: ReplState):
|
|
32
|
-
if not(args := self.args(cmd)):
|
|
33
|
-
return super().run(cmd, state)
|
|
34
|
-
|
|
35
|
-
with self.validate(args, state) as (args, state):
|
|
36
|
-
with extract_options(args, '--force') as (args, forced):
|
|
37
|
-
restarted, rollingout = StatefulSets.restarted_at(state.sts, state.namespace)
|
|
38
|
-
if rollingout and not forced:
|
|
39
|
-
log2(f"* Cluster is being rolled out for {duration(restarted)}. Please wait until it's done or use --force.")
|
|
40
|
-
|
|
41
|
-
return state
|
|
42
|
-
|
|
43
|
-
self.rolling_restart(state.sts, state.namespace)
|
|
44
|
-
|
|
45
|
-
auto_watch = False
|
|
46
|
-
if (auto_watch_cmds := Config().get('watch.auto', 'rollout')):
|
|
47
|
-
cmds = [c.strip(' ') for c in auto_watch_cmds.split(',')]
|
|
48
|
-
if self.command() in cmds:
|
|
49
|
-
auto_watch = True
|
|
50
|
-
log2('Rolling out cluster with auto watch...')
|
|
51
|
-
Watch().run('watch', state)
|
|
52
|
-
|
|
53
|
-
if not auto_watch:
|
|
54
|
-
log2('Rolling out cluster...')
|
|
55
|
-
|
|
56
|
-
return state
|
|
57
|
-
|
|
58
|
-
def rolling_restart(self, statefulset, namespace):
|
|
59
|
-
# kubectl rollout restart statefulset <statefulset-name>
|
|
60
|
-
v1_apps = client.AppsV1Api()
|
|
61
|
-
|
|
62
|
-
now = datetime.datetime.now(datetime.timezone.utc)
|
|
63
|
-
now = str(now.isoformat("T") + "Z")
|
|
64
|
-
body = {
|
|
65
|
-
'spec': {
|
|
66
|
-
'template':{
|
|
67
|
-
'metadata': {
|
|
68
|
-
'annotations': {
|
|
69
|
-
'kubectl.kubernetes.io/restartedAt': now
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
try:
|
|
77
|
-
v1_apps.patch_namespaced_stateful_set(statefulset, namespace, body, pretty='true')
|
|
78
|
-
except ApiException as e:
|
|
79
|
-
log2("Exception when calling AppsV1Api->read_namespaced_statefulset_status: %s\n" % e)
|
|
80
|
-
|
|
81
|
-
def completion(self, state: ReplState):
|
|
82
|
-
if super().completion(state):
|
|
83
|
-
return {RollOut.COMMAND: None}
|
|
84
|
-
|
|
85
|
-
return {}
|
|
86
|
-
|
|
87
|
-
def help(self, _: ReplState):
|
|
88
|
-
return f'{RollOut.COMMAND} [--force]\t rollout all nodes'
|
adam/commands/cat.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
from adam.commands import validate_args
|
|
2
|
-
from adam.commands.command import Command
|
|
3
|
-
from adam.commands.devices.devices import Devices
|
|
4
|
-
from adam.repl_state import ReplState, RequiredState
|
|
5
|
-
|
|
6
|
-
class Cat(Command):
|
|
7
|
-
COMMAND = 'cat'
|
|
8
|
-
|
|
9
|
-
# the singleton pattern
|
|
10
|
-
def __new__(cls, *args, **kwargs):
|
|
11
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Cat, cls).__new__(cls)
|
|
12
|
-
|
|
13
|
-
return cls.instance
|
|
14
|
-
|
|
15
|
-
def __init__(self, successor: Command=None):
|
|
16
|
-
super().__init__(successor)
|
|
17
|
-
|
|
18
|
-
def command(self):
|
|
19
|
-
return Cat.COMMAND
|
|
20
|
-
|
|
21
|
-
def required(self):
|
|
22
|
-
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
23
|
-
|
|
24
|
-
def run(self, cmd: str, state: ReplState):
|
|
25
|
-
if not(args := self.args(cmd)):
|
|
26
|
-
return super().run(cmd, state)
|
|
27
|
-
|
|
28
|
-
with self.validate(args, state) as (args, state):
|
|
29
|
-
with validate_args(args, state, name='file'):
|
|
30
|
-
return Devices.of(state).bash(state, state, cmd.split(' '))
|
|
31
|
-
|
|
32
|
-
def completion(self, state: ReplState):
|
|
33
|
-
return super().completion(state, lambda: {f: None for f in Devices.of(state).files(state)}, pods=Devices.of(state).pods(state, '-'), auto='jit')
|
|
34
|
-
|
|
35
|
-
def help(self, _: ReplState):
|
|
36
|
-
return f'{Cat.COMMAND} file [&]\t run cat command on the pod'
|
adam/commands/cd.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
from adam.commands import validate_args
|
|
2
|
-
from adam.commands.command import Command
|
|
3
|
-
from adam.commands.devices.device import Device
|
|
4
|
-
from adam.commands.devices.devices import Devices
|
|
5
|
-
from adam.repl_state import ReplState
|
|
6
|
-
|
|
7
|
-
class Cd(Command):
|
|
8
|
-
COMMAND = 'cd'
|
|
9
|
-
|
|
10
|
-
# the singleton pattern
|
|
11
|
-
def __new__(cls, *args, **kwargs):
|
|
12
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Cd, cls).__new__(cls)
|
|
13
|
-
|
|
14
|
-
return cls.instance
|
|
15
|
-
|
|
16
|
-
def __init__(self, successor: Command=None):
|
|
17
|
-
super().__init__(successor)
|
|
18
|
-
|
|
19
|
-
def command(self):
|
|
20
|
-
return Cd.COMMAND
|
|
21
|
-
|
|
22
|
-
def required(self):
|
|
23
|
-
return ReplState.NON_L
|
|
24
|
-
|
|
25
|
-
def run(self, cmd: str, state: ReplState):
|
|
26
|
-
if not(args := self.args(cmd)):
|
|
27
|
-
return super().run(cmd, state)
|
|
28
|
-
|
|
29
|
-
with self.validate(args, state, apply=False) as (args, state):
|
|
30
|
-
with validate_args(args, state, name='directory') as arg_str:
|
|
31
|
-
device: Device = Devices.of(state)
|
|
32
|
-
for dir in arg_str.split('/'):
|
|
33
|
-
device.cd(dir, state)
|
|
34
|
-
|
|
35
|
-
return state
|
|
36
|
-
|
|
37
|
-
def completion(self, state: ReplState):
|
|
38
|
-
return Devices.of(state).cd_completion(Cd.COMMAND, state, default = {})
|
|
39
|
-
|
|
40
|
-
def help(self, _: ReplState):
|
|
41
|
-
return f'{Cd.COMMAND} <path> | .. \t move around on the operational device hierarchy'
|
adam/commands/download_file.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from adam.commands import validate_args
|
|
2
|
-
from adam.commands.command import Command
|
|
3
|
-
from adam.commands.devices.devices import Devices
|
|
4
|
-
from adam.config import Config
|
|
5
|
-
from adam.pod_exec_result import PodExecResult
|
|
6
|
-
from adam.repl_state import ReplState, RequiredState
|
|
7
|
-
from adam.utils import log2
|
|
8
|
-
from adam.utils_k8s.pods import Pods
|
|
9
|
-
|
|
10
|
-
class DownloadFile(Command):
|
|
11
|
-
COMMAND = 'download file'
|
|
12
|
-
|
|
13
|
-
# the singleton pattern
|
|
14
|
-
def __new__(cls, *args, **kwargs):
|
|
15
|
-
if not hasattr(cls, 'instance'): cls.instance = super(DownloadFile, cls).__new__(cls)
|
|
16
|
-
|
|
17
|
-
return cls.instance
|
|
18
|
-
|
|
19
|
-
def __init__(self, successor: Command=None):
|
|
20
|
-
super().__init__(successor)
|
|
21
|
-
|
|
22
|
-
def command(self):
|
|
23
|
-
return DownloadFile.COMMAND
|
|
24
|
-
|
|
25
|
-
def required(self):
|
|
26
|
-
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
27
|
-
|
|
28
|
-
def run(self, cmd: str, state: ReplState):
|
|
29
|
-
if not(args := self.args(cmd)):
|
|
30
|
-
return super().run(cmd, state)
|
|
31
|
-
|
|
32
|
-
with self.validate(args, state) as (args, state):
|
|
33
|
-
with validate_args(args, state, name='file'):
|
|
34
|
-
to_file = Pods.download_file(Devices.of(state).pod(state),
|
|
35
|
-
Devices.of(state).default_container(state),
|
|
36
|
-
state.namespace,
|
|
37
|
-
args[0],
|
|
38
|
-
args[1] if len(args) > 1 else None)
|
|
39
|
-
log2(f'Downloaded to {to_file}.')
|
|
40
|
-
|
|
41
|
-
return state
|
|
42
|
-
|
|
43
|
-
def completion(self, state: ReplState):
|
|
44
|
-
return super().completion(state, lambda: {f: None for f in Devices.of(state).files(state)}, pods=Devices.of(state).pods(state, '-'), auto='jit')
|
|
45
|
-
|
|
46
|
-
def help(self, _: ReplState):
|
|
47
|
-
return f'{DownloadFile.COMMAND} from-file [to-file]\t download file from pod'
|
adam/commands/find_files.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
from adam.commands.command import Command
|
|
4
|
-
from adam.repl_state import ReplState
|
|
5
|
-
from adam.utils import log2
|
|
6
|
-
from adam.utils_local import local_tmp_dir
|
|
7
|
-
|
|
8
|
-
class FindLocalFiles(Command):
|
|
9
|
-
COMMAND = 'find local'
|
|
10
|
-
|
|
11
|
-
# the singleton pattern
|
|
12
|
-
def __new__(cls, *args, **kwargs):
|
|
13
|
-
if not hasattr(cls, 'instance'): cls.instance = super(FindLocalFiles, cls).__new__(cls)
|
|
14
|
-
|
|
15
|
-
return cls.instance
|
|
16
|
-
|
|
17
|
-
def __init__(self, successor: Command=None):
|
|
18
|
-
super().__init__(successor)
|
|
19
|
-
|
|
20
|
-
def command(self):
|
|
21
|
-
return FindLocalFiles.COMMAND
|
|
22
|
-
|
|
23
|
-
def run(self, cmd: str, state: ReplState):
|
|
24
|
-
if not(args := self.args(cmd)):
|
|
25
|
-
return super().run(cmd, state)
|
|
26
|
-
|
|
27
|
-
with self.validate(args, state) as (args, state):
|
|
28
|
-
cmd = 'find'
|
|
29
|
-
|
|
30
|
-
if not args:
|
|
31
|
-
cmd = f'find {local_tmp_dir()}'
|
|
32
|
-
elif len(args) == 1:
|
|
33
|
-
cmd = f"find {local_tmp_dir()} -name '{args[0]}'"
|
|
34
|
-
else:
|
|
35
|
-
new_args = [f"'{arg}'" if '*' in arg else arg for arg in args]
|
|
36
|
-
cmd = 'find ' + ' '.join(new_args)
|
|
37
|
-
|
|
38
|
-
log2(cmd)
|
|
39
|
-
os.system(cmd)
|
|
40
|
-
|
|
41
|
-
return state
|
|
42
|
-
|
|
43
|
-
def completion(self, state: ReplState):
|
|
44
|
-
return super().completion(state, {
|
|
45
|
-
'*.csv': None,
|
|
46
|
-
'*.db': None,
|
|
47
|
-
'*': None
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
def help(self, _: ReplState):
|
|
51
|
-
return f'{FindLocalFiles.COMMAND} [linux-find-arguments]\t find files from local machine'
|
adam/commands/find_processes.py
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
from adam.commands import extract_options, validate_args
|
|
2
|
-
from adam.commands.command import Command
|
|
3
|
-
from adam.commands.devices.devices import Devices
|
|
4
|
-
from adam.commands.export.utils_export import state_with_pod
|
|
5
|
-
from adam.repl_state import ReplState, RequiredState
|
|
6
|
-
from adam.utils import log2, tabulize
|
|
7
|
-
|
|
8
|
-
class FindProcesses(Command):
|
|
9
|
-
COMMAND = 'find processes'
|
|
10
|
-
|
|
11
|
-
# the singleton pattern
|
|
12
|
-
def __new__(cls, *args, **kwargs):
|
|
13
|
-
if not hasattr(cls, 'instance'): cls.instance = super(FindProcesses, cls).__new__(cls)
|
|
14
|
-
|
|
15
|
-
return cls.instance
|
|
16
|
-
|
|
17
|
-
def __init__(self, successor: Command=None):
|
|
18
|
-
super().__init__(successor)
|
|
19
|
-
|
|
20
|
-
def command(self):
|
|
21
|
-
return FindProcesses.COMMAND
|
|
22
|
-
|
|
23
|
-
def required(self):
|
|
24
|
-
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
25
|
-
|
|
26
|
-
def run(self, cmd: str, state: ReplState):
|
|
27
|
-
if not(args := self.args(cmd)):
|
|
28
|
-
return super().run(cmd, state)
|
|
29
|
-
|
|
30
|
-
with self.validate(args, state) as (args, state):
|
|
31
|
-
with extract_options(args, '-kill') as (args, kill):
|
|
32
|
-
with validate_args(args, state, name='words to look for'):
|
|
33
|
-
arg = ' | '.join([f'grep {a}' for a in args])
|
|
34
|
-
awk = "awk '{ print $1, $2, $8, $NF }'"
|
|
35
|
-
rs = Devices.of(state).bash(state, state, f"ps -ef | grep -v grep | {arg} | {awk}".split(' '))
|
|
36
|
-
|
|
37
|
-
lines: list[list[str]] = []
|
|
38
|
-
for r in rs:
|
|
39
|
-
for l in r.stdout.split('\n'):
|
|
40
|
-
l = l.strip(' \t\r\n')
|
|
41
|
-
if not l:
|
|
42
|
-
continue
|
|
43
|
-
|
|
44
|
-
tokens = [r.pod] + l.split(' ')
|
|
45
|
-
lines.append(tokens)
|
|
46
|
-
|
|
47
|
-
pids = []
|
|
48
|
-
for l in lines:
|
|
49
|
-
pids.append(f'{l[2]}@{l[0]}')
|
|
50
|
-
|
|
51
|
-
tabulize(lines, lambda l: '\t'.join(l), header = 'POD\tUSER\tPID\tCMD\tLAST_ARG', separator='\t')
|
|
52
|
-
log2()
|
|
53
|
-
log2(f'PIDS with {",".join(args)}: {",".join(pids)}')
|
|
54
|
-
|
|
55
|
-
if kill:
|
|
56
|
-
log2()
|
|
57
|
-
for pidp in pids:
|
|
58
|
-
pid_n_pod = pidp.split('@')
|
|
59
|
-
pid = pid_n_pod[0]
|
|
60
|
-
if len(pid_n_pod) < 2:
|
|
61
|
-
continue
|
|
62
|
-
|
|
63
|
-
pod = pid_n_pod[1]
|
|
64
|
-
|
|
65
|
-
log2(f'@{pod} bash kill -9 {pid}')
|
|
66
|
-
|
|
67
|
-
with state_with_pod(state, pod) as state1:
|
|
68
|
-
Devices.of(state).bash(state, state1, ['kill', '-9', pid])
|
|
69
|
-
|
|
70
|
-
return rs
|
|
71
|
-
|
|
72
|
-
def completion(self, state: ReplState):
|
|
73
|
-
return super().completion(state)
|
|
74
|
-
|
|
75
|
-
def help(self, _: ReplState):
|
|
76
|
-
return f'{FindProcesses.COMMAND} word... [-kill]\t find processes with words'
|
adam/commands/head.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
from adam.commands import validate_args
|
|
2
|
-
from adam.commands.command import Command
|
|
3
|
-
from adam.commands.devices.devices import Devices
|
|
4
|
-
from adam.repl_state import ReplState, RequiredState
|
|
5
|
-
|
|
6
|
-
class Head(Command):
|
|
7
|
-
COMMAND = 'head'
|
|
8
|
-
|
|
9
|
-
# the singleton pattern
|
|
10
|
-
def __new__(cls, *args, **kwargs):
|
|
11
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Head, cls).__new__(cls)
|
|
12
|
-
|
|
13
|
-
return cls.instance
|
|
14
|
-
|
|
15
|
-
def __init__(self, successor: Command=None):
|
|
16
|
-
super().__init__(successor)
|
|
17
|
-
|
|
18
|
-
def command(self):
|
|
19
|
-
return Head.COMMAND
|
|
20
|
-
|
|
21
|
-
def required(self):
|
|
22
|
-
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
23
|
-
|
|
24
|
-
def run(self, cmd: str, state: ReplState):
|
|
25
|
-
if not(args := self.args(cmd)):
|
|
26
|
-
return super().run(cmd, state)
|
|
27
|
-
|
|
28
|
-
with self.validate(args, state) as (args, state):
|
|
29
|
-
with validate_args(args, state, name='file'):
|
|
30
|
-
return Devices.of(state).bash(state, state, cmd.split(' '))
|
|
31
|
-
|
|
32
|
-
def completion(self, state: ReplState):
|
|
33
|
-
return super().completion(state, lambda: {f: None for f in Devices.of(state).files(state)}, pods=Devices.of(state).pods(state, '-'), auto='jit')
|
|
34
|
-
|
|
35
|
-
def help(self, _: ReplState):
|
|
36
|
-
return f'{Head.COMMAND} file [&]\t run head command on the pod'
|
adam/commands/ls.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import copy
|
|
2
|
-
|
|
3
|
-
from adam.commands.command import Command
|
|
4
|
-
from adam.commands.devices.devices import Devices
|
|
5
|
-
from adam.repl_state import ReplState
|
|
6
|
-
|
|
7
|
-
class Ls(Command):
|
|
8
|
-
COMMAND = 'ls'
|
|
9
|
-
|
|
10
|
-
# the singleton pattern
|
|
11
|
-
def __new__(cls, *args, **kwargs):
|
|
12
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Ls, cls).__new__(cls)
|
|
13
|
-
|
|
14
|
-
return cls.instance
|
|
15
|
-
|
|
16
|
-
def __init__(self, successor: Command=None):
|
|
17
|
-
super().__init__(successor)
|
|
18
|
-
|
|
19
|
-
def command(self):
|
|
20
|
-
return Ls.COMMAND
|
|
21
|
-
|
|
22
|
-
def run(self, cmd: str, state: ReplState):
|
|
23
|
-
if not(args := self.args(cmd)):
|
|
24
|
-
return super().run(cmd, state)
|
|
25
|
-
|
|
26
|
-
with self.validate(args, state) as (args, state):
|
|
27
|
-
if len(args) > 0:
|
|
28
|
-
arg = args[0]
|
|
29
|
-
if arg in ['p:', 'c:'] and arg != f'{state.device}:':
|
|
30
|
-
state = copy.copy(state)
|
|
31
|
-
state.device = arg.replace(':', '')
|
|
32
|
-
|
|
33
|
-
Devices.of(state).ls(cmd, state)
|
|
34
|
-
|
|
35
|
-
return state
|
|
36
|
-
|
|
37
|
-
def completion(self, state: ReplState):
|
|
38
|
-
return super().completion(state, {'&': None}, pods=Devices.of(state).pods(state, '-'))
|
|
39
|
-
|
|
40
|
-
def help(self, _: ReplState):
|
|
41
|
-
return f'{Ls.COMMAND} [device:]\t list apps, envs, clusters, nodes, pg hosts/databases or export databases'
|