drove-cli 0.0.5__tar.gz → 0.0.7__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drove-cli
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: Drove Command Line Interface
5
5
  License: Apache-2.0
6
6
  Keywords: container,docker,podman,distributed-systems,container-orchestrator
@@ -74,6 +74,20 @@ EOF
74
74
  chmod +x ~/bin/drove
75
75
  ```
76
76
 
77
+ ## Upgrade
78
+
79
+ ### Using pip
80
+
81
+ ```bash
82
+ pip install -U drove-cli
83
+ ```
84
+
85
+ ### Using Docker
86
+
87
+ ```bash
88
+ docker pull ghcr.io/phonepe/drove-cli:latest
89
+ ```
90
+
77
91
  ## Configuration
78
92
 
79
93
  Create `~/.drove` with your cluster configuration:
@@ -144,7 +158,7 @@ Use `drove -h` or `drove <command> -h` for detailed help.
144
158
 
145
159
  ## Documentation
146
160
 
147
- Full documentation is available at **[github.com/PhonePe/drove-orchestrator](https://github.com/PhonePe/drove-orchestrator)**
161
+ Full documentation is available at **[phonepe.github.io/drove-orchestrator](https://phonepe.github.io/drove-orchestrator/cli/)**
148
162
 
149
163
  ## License
150
164
 
@@ -41,6 +41,20 @@ EOF
41
41
  chmod +x ~/bin/drove
42
42
  ```
43
43
 
44
+ ## Upgrade
45
+
46
+ ### Using pip
47
+
48
+ ```bash
49
+ pip install -U drove-cli
50
+ ```
51
+
52
+ ### Using Docker
53
+
54
+ ```bash
55
+ docker pull ghcr.io/phonepe/drove-cli:latest
56
+ ```
57
+
44
58
  ## Configuration
45
59
 
46
60
  Create `~/.drove` with your cluster configuration:
@@ -111,7 +125,7 @@ Use `drove -h` or `drove <command> -h` for detailed help.
111
125
 
112
126
  ## Documentation
113
127
 
114
- Full documentation is available at **[github.com/PhonePe/drove-orchestrator](https://github.com/PhonePe/drove-orchestrator)**
128
+ Full documentation is available at **[phonepe.github.io/drove-orchestrator](https://phonepe.github.io/drove-orchestrator/cli/)**
115
129
 
116
130
  ## License
117
131
 
@@ -36,14 +36,14 @@ def run():
36
36
  except (BrokenPipeError, IOError, KeyboardInterrupt):
37
37
  pass
38
38
  except droveclient.DroveException as e:
39
- debug = True if client != None and client.debug else False
39
+ debug = True if client is not None and client.debug else False
40
40
  droveutils.print_drove_error(e, debug)
41
41
  if debug:
42
42
  traceback.print_exc()
43
43
 
44
44
  except Exception as e:
45
45
  print("Drove CLI error: " + str(e))
46
- debug = True if client != None and client.debug else False
46
+ debug = True if client is not None and client.debug else False
47
47
  if debug:
48
48
  traceback.print_exc()
49
49
  else:
@@ -8,14 +8,14 @@ from types import SimpleNamespace
8
8
  class DroveCli:
9
9
  def __init__(self, parser: argparse.ArgumentParser):
10
10
  self.parser = parser
11
- self.drove_client = droveclient.DroveClient()
12
11
  self.plugins: list = []
13
12
  self.debug = False
14
13
  subparsers = parser.add_subparsers(help="Available plugins")
14
+ drove_client = droveclient.DroveClient()
15
15
  for plugin_class in DrovePlugin.plugins:
16
16
  plugin = plugin_class()
17
17
  # print("Loading plugin: " + str(plugin))
18
- plugin.populate_options(drove_client=self.drove_client, subparser=subparsers)
18
+ plugin.populate_options(drove_client=drove_client, subparser=subparsers)
19
19
  self.plugins.append(plugin)
20
20
  parser.set_defaults(func=self.show_help)
21
21
 
@@ -23,10 +23,6 @@ class DroveCli:
23
23
  def run(self):
24
24
  args = self.parser.parse_args()
25
25
  self.debug = args.debug
26
- drove_client = droveclient.build_drove_client(self.drove_client, args=args)
27
- if drove_client is None:
28
- return None
29
- self.drove_client = drove_client
30
26
 
31
27
  # Load plugins
32
28
 
@@ -17,12 +17,20 @@ class DrovePlugin:
17
17
  def __init__(self) -> None:
18
18
  self.drove_client: droveclient.DroveClient = None
19
19
  self.parser: argparse.ArgumentParser = None
20
-
20
+
21
+ def needs_client(self) -> bool:
22
+ return True
23
+
21
24
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
22
25
  self.drove_client = drove_client
23
- subparser.set_defaults(func=self.process)
26
+ subparser.set_defaults(func=self.run_plugin)
24
27
  self.parser = subparser
25
28
 
29
+ def run_plugin(self, options: SimpleNamespace):
30
+ if self.needs_client():
31
+ droveclient.build_drove_client(self.drove_client, options)
32
+ self.process(options)
33
+
26
34
  def process(self, options: SimpleNamespace):
27
35
  self.parser.print_help()
28
36
  exit(-1)
@@ -20,7 +20,7 @@ class Applications(plugins.DrovePlugin):
20
20
  sub_parser = commands.add_parser("list", help="List all application instances")
21
21
  sub_parser.add_argument("app_id", metavar="app-id", help="Application ID")
22
22
  sub_parser.add_argument("--old", "-o", help="Show old instances", action="store_true")
23
- sub_parser.add_argument("--sort", "-s", help="Sort output by column", type=int, choices=range(0, 6), default = 0)
23
+ sub_parser.add_argument("--sort", "-s", help="Sort output by column", type=int, choices=range(0, 7), default = 0)
24
24
  sub_parser.add_argument("--reverse", "-r", help="Sort in reverse order", action="store_true")
25
25
  sub_parser.set_defaults(func=self.list_instances)
26
26
 
@@ -76,15 +76,20 @@ class Applications(plugins.DrovePlugin):
76
76
  api = "/apis/v1/applications/{app_id}/instances/old"
77
77
  data = self.drove_client.get(api.format(app_id = options.app_id))
78
78
  #headers = ["Instance ID", "Executor", "CPU", "Memory(MB)", "State", "Error Message", "Created", "Last Updated"]
79
- headers = ["Instance ID", "Executor Host", "State", "Error Message", "Created", "Last Updated"]
79
+ headers = ["Instance ID", "Executor Host", "Ports", "State", "Error Message", "Created", "Last Updated"]
80
80
  rows = []
81
81
  for instance in data:
82
82
  instance_row = []
83
83
  instance_row.append(instance["instanceId"])
84
- try:
85
- instance_row.append(instance["localInfo"]["hostname"])
86
- except KeyError:
87
- instance_row.append("")
84
+ local_info = instance.get("localInfo", {})
85
+ instance_row.append(local_info.get("hostname", ""))
86
+ ports = local_info.get("ports", {})
87
+ ports_str = ",".join(
88
+ "{}:{}".format(key, value["hostPort"])
89
+ for key, value in ports.items()
90
+ if "hostPort" in value
91
+ )
92
+ instance_row.append(ports_str)
88
93
  instance_row.append(instance["state"])
89
94
  instance_row.append(instance["errorMessage"])
90
95
  instance_row.append(droveutils.to_date(instance["created"]))
@@ -85,6 +85,9 @@ class Config(plugins.DrovePlugin):
85
85
  def __init__(self) -> None:
86
86
  pass
87
87
 
88
+ def needs_client(self) -> bool:
89
+ return False
90
+
88
91
  def populate_options(self, drove_client, subparser: argparse.ArgumentParser):
89
92
  parser = subparser.add_parser("config", help="Manage drove cluster configurations")
90
93
  commands = parser.add_subparsers(help="Available config commands")
@@ -77,15 +77,20 @@ class LocalServices(plugins.DrovePlugin):
77
77
  api = "/apis/v1/localservices/{service_id}/instances/old"
78
78
  data = self.drove_client.get(api.format(service_id = options.service_id))
79
79
  #headers = ["Instance ID", "Executor", "CPU", "Memory(MB)", "State", "Error Message", "Created", "Last Updated"]
80
- headers = ["Instance ID", "Executor Host", "State", "Error Message", "Created", "Last Updated"]
80
+ headers = ["Instance ID", "Executor Host", "Ports", "State", "Error Message", "Created", "Last Updated"]
81
81
  rows = []
82
82
  for instance in data:
83
83
  instance_row = []
84
84
  instance_row.append(instance["instanceId"])
85
- try:
86
- instance_row.append(instance["localInfo"]["hostname"])
87
- except KeyError:
88
- instance_row.append("")
85
+ local_info = instance.get("localInfo", {})
86
+ instance_row.append(local_info.get("hostname", ""))
87
+ ports = local_info.get("ports", {})
88
+ ports_str = ",".join(
89
+ "{}:{}".format(key, value["hostPort"])
90
+ for key, value in ports.items()
91
+ if "hostPort" in value
92
+ )
93
+ instance_row.append(ports_str)
89
94
  instance_row.append(instance["state"])
90
95
  instance_row.append(instance["errorMessage"])
91
96
  instance_row.append(droveutils.to_date(instance["created"]))
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "drove-cli"
3
- version = "0.0.5"
3
+ version = "0.0.7"
4
4
  description = "Drove Command Line Interface"
5
5
  authors = ["Santanu Sinha <santanu.sinha@gmail.com>"]
6
6
  maintainers = [
File without changes
File without changes
File without changes
File without changes
File without changes