vantage6 4.0.2__py3-none-any.whl → 4.1.0b0__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 vantage6 might be problematic. Click here for more details.
- tests_cli/test_node_cli.py +60 -55
- tests_cli/test_server_cli.py +30 -30
- vantage6/cli/_version.py +1 -1
- vantage6/cli/cli.py +102 -0
- vantage6/cli/{dev.py → dev/create.py} +18 -151
- vantage6/cli/dev/remove.py +63 -0
- vantage6/cli/dev/start.py +52 -0
- vantage6/cli/dev/stop.py +30 -0
- vantage6/cli/node/attach.py +58 -0
- vantage6/cli/node/clean.py +40 -0
- vantage6/cli/node/common/__init__.py +124 -0
- vantage6/cli/node/create_private_key.py +139 -0
- vantage6/cli/node/files.py +34 -0
- vantage6/cli/node/list.py +62 -0
- vantage6/cli/node/new.py +46 -0
- vantage6/cli/node/remove.py +103 -0
- vantage6/cli/node/set_api_key.py +45 -0
- vantage6/cli/node/start.py +311 -0
- vantage6/cli/node/stop.py +73 -0
- vantage6/cli/node/version.py +47 -0
- vantage6/cli/server/attach.py +54 -0
- vantage6/cli/server/common/__init__.py +146 -0
- vantage6/cli/server/files.py +16 -0
- vantage6/cli/server/import_.py +144 -0
- vantage6/cli/server/list.py +60 -0
- vantage6/cli/server/new.py +50 -0
- vantage6/cli/server/shell.py +42 -0
- vantage6/cli/server/start.py +302 -0
- vantage6/cli/server/stop.py +158 -0
- vantage6/cli/server/version.py +46 -0
- {vantage6-4.0.2.dist-info → vantage6-4.1.0b0.dist-info}/METADATA +7 -6
- vantage6-4.1.0b0.dist-info/RECORD +52 -0
- vantage6-4.1.0b0.dist-info/entry_points.txt +5 -0
- vantage6/cli/node.py +0 -1092
- vantage6/cli/server.py +0 -1033
- vantage6-4.0.2.dist-info/RECORD +0 -28
- vantage6-4.0.2.dist-info/entry_points.txt +0 -4
- {vantage6-4.0.2.dist-info → vantage6-4.1.0b0.dist-info}/WHEEL +0 -0
- {vantage6-4.0.2.dist-info → vantage6-4.1.0b0.dist-info}/top_level.txt +0 -0
tests_cli/test_node_cli.py
CHANGED
|
@@ -11,17 +11,16 @@ from docker.errors import APIError
|
|
|
11
11
|
|
|
12
12
|
from vantage6.cli.globals import APPNAME
|
|
13
13
|
from vantage6.common import STRING_ENCODING
|
|
14
|
-
from vantage6.cli.node import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_create_client_and_authenticate,
|
|
14
|
+
from vantage6.cli.node.list import cli_node_list
|
|
15
|
+
from vantage6.cli.node.new import cli_node_new_configuration
|
|
16
|
+
from vantage6.cli.node.files import cli_node_files
|
|
17
|
+
from vantage6.cli.node.start import cli_node_start
|
|
18
|
+
from vantage6.cli.node.stop import cli_node_stop
|
|
19
|
+
from vantage6.cli.node.attach import cli_node_attach
|
|
20
|
+
from vantage6.cli.node.create_private_key import cli_node_create_private_key
|
|
21
|
+
from vantage6.cli.node.clean import cli_node_clean
|
|
22
|
+
from vantage6.cli.node.common import (
|
|
23
|
+
create_client_and_authenticate, print_log_worker
|
|
25
24
|
)
|
|
26
25
|
|
|
27
26
|
|
|
@@ -86,9 +85,9 @@ class NodeCLITest(unittest.TestCase):
|
|
|
86
85
|
"-----------------------------------------------------\n"
|
|
87
86
|
)
|
|
88
87
|
|
|
89
|
-
@patch("vantage6.cli.node.configuration_wizard")
|
|
90
|
-
@patch("vantage6.cli.node.check_config_writeable")
|
|
91
|
-
@patch("vantage6.cli.node.NodeContext")
|
|
88
|
+
@patch("vantage6.cli.node.new.configuration_wizard")
|
|
89
|
+
@patch("vantage6.cli.node.new.check_config_writeable")
|
|
90
|
+
@patch("vantage6.cli.node.common.NodeContext")
|
|
92
91
|
def test_new_config(self, context, permissions, wizard):
|
|
93
92
|
"""No error produced when creating new configuration."""
|
|
94
93
|
context.config_exists.return_value = False
|
|
@@ -106,7 +105,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
106
105
|
# check OK exit code
|
|
107
106
|
self.assertEqual(result.exit_code, 0)
|
|
108
107
|
|
|
109
|
-
@patch("vantage6.cli.node.configuration_wizard")
|
|
108
|
+
@patch("vantage6.cli.node.new.configuration_wizard")
|
|
110
109
|
def test_new_config_replace_whitespace_in_name(self, _):
|
|
111
110
|
"""Whitespaces are replaced in the name."""
|
|
112
111
|
|
|
@@ -120,7 +119,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
120
119
|
"[info ] - Replaced spaces from configuration name: some-name"
|
|
121
120
|
)
|
|
122
121
|
|
|
123
|
-
@patch("vantage6.cli.node.NodeContext")
|
|
122
|
+
@patch("vantage6.cli.node.new.NodeContext")
|
|
124
123
|
def test_new_config_already_exists(self, context):
|
|
125
124
|
"""No duplicate configurations are allowed."""
|
|
126
125
|
|
|
@@ -137,8 +136,8 @@ class NodeCLITest(unittest.TestCase):
|
|
|
137
136
|
# check non-zero exit code
|
|
138
137
|
self.assertEqual(result.exit_code, 1)
|
|
139
138
|
|
|
140
|
-
@patch("vantage6.cli.node.check_config_writeable")
|
|
141
|
-
@patch("vantage6.cli.node.NodeContext")
|
|
139
|
+
@patch("vantage6.cli.node.new.check_config_writeable")
|
|
140
|
+
@patch("vantage6.cli.node.common.NodeContext")
|
|
142
141
|
def test_new_write_permissions(self, context, permissions):
|
|
143
142
|
"""User needs write permissions."""
|
|
144
143
|
|
|
@@ -156,12 +155,13 @@ class NodeCLITest(unittest.TestCase):
|
|
|
156
155
|
# check non-zero exit code
|
|
157
156
|
self.assertEqual(result.exit_code, 1)
|
|
158
157
|
|
|
159
|
-
@patch("vantage6.cli.node.NodeContext")
|
|
160
|
-
@patch("vantage6.cli.node.
|
|
161
|
-
|
|
158
|
+
@patch("vantage6.cli.node.common.NodeContext")
|
|
159
|
+
@patch("vantage6.cli.node.files.NodeContext")
|
|
160
|
+
@patch("vantage6.cli.node.common.select_configuration_questionaire")
|
|
161
|
+
def test_files(self, select_config, context, common_context):
|
|
162
162
|
"""No errors produced when retrieving filepaths."""
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
common_context.config_exists.return_value = True
|
|
165
165
|
context.return_value = MagicMock(
|
|
166
166
|
config_file="/file.yaml",
|
|
167
167
|
log_file="/log.log",
|
|
@@ -180,7 +180,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
180
180
|
# check status code is OK
|
|
181
181
|
self.assertEqual(result.exit_code, 0)
|
|
182
182
|
|
|
183
|
-
@patch("vantage6.cli.node.NodeContext")
|
|
183
|
+
@patch("vantage6.cli.node.common.NodeContext")
|
|
184
184
|
def test_files_non_existing_config(self, context):
|
|
185
185
|
"""An error is produced when a non existing config is used."""
|
|
186
186
|
|
|
@@ -196,10 +196,10 @@ class NodeCLITest(unittest.TestCase):
|
|
|
196
196
|
self.assertNotEqual(result.exit_code, 0)
|
|
197
197
|
|
|
198
198
|
@patch("docker.DockerClient.volumes")
|
|
199
|
-
@patch("vantage6.cli.node.pull_if_newer")
|
|
200
|
-
@patch("vantage6.cli.node.NodeContext")
|
|
199
|
+
@patch("vantage6.cli.node.start.pull_if_newer")
|
|
200
|
+
@patch("vantage6.cli.node.start.NodeContext")
|
|
201
201
|
@patch("docker.DockerClient.containers")
|
|
202
|
-
@patch("vantage6.cli.node.check_docker_running", return_value=True)
|
|
202
|
+
@patch("vantage6.cli.node.start.check_docker_running", return_value=True)
|
|
203
203
|
def test_start(self, check_docker, client, context, pull, volumes):
|
|
204
204
|
|
|
205
205
|
# client.containers = MagicMock(name="docker.DockerClient.containers")
|
|
@@ -231,7 +231,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
231
231
|
self.assertEqual(result.exit_code, 0)
|
|
232
232
|
|
|
233
233
|
@patch("docker.DockerClient.containers")
|
|
234
|
-
@patch("vantage6.cli.node.check_docker_running",
|
|
234
|
+
@patch("vantage6.cli.node.stop.check_docker_running",
|
|
235
235
|
return_value=True)
|
|
236
236
|
def test_stop(self, check_docker, containers):
|
|
237
237
|
|
|
@@ -250,10 +250,10 @@ class NodeCLITest(unittest.TestCase):
|
|
|
250
250
|
|
|
251
251
|
self.assertEqual(result.exit_code, 0)
|
|
252
252
|
|
|
253
|
-
@patch("vantage6.cli.node.time")
|
|
254
|
-
@patch("vantage6.cli.node.
|
|
253
|
+
@patch("vantage6.cli.node.attach.time")
|
|
254
|
+
@patch("vantage6.cli.node.attach.print_log_worker")
|
|
255
255
|
@patch("docker.DockerClient.containers")
|
|
256
|
-
@patch("vantage6.cli.node.check_docker_running", return_value=True)
|
|
256
|
+
@patch("vantage6.cli.node.attach.check_docker_running", return_value=True)
|
|
257
257
|
def test_attach(self, check_docker, containers, log_worker, time_):
|
|
258
258
|
"""Attach docker logs without errors."""
|
|
259
259
|
container1 = MagicMock()
|
|
@@ -270,13 +270,13 @@ class NodeCLITest(unittest.TestCase):
|
|
|
270
270
|
result.output,
|
|
271
271
|
"[info ] - Closing log file. Keyboard Interrupt.\n"
|
|
272
272
|
"[info ] - Note that your node is still running! Shut it down "
|
|
273
|
-
"with '
|
|
273
|
+
"with 'v6 node stop'\n"
|
|
274
274
|
)
|
|
275
275
|
self.assertEqual(result.exit_code, 0)
|
|
276
276
|
|
|
277
|
-
@patch("vantage6.cli.node.q")
|
|
277
|
+
@patch("vantage6.cli.node.clean.q")
|
|
278
278
|
@patch("docker.DockerClient.volumes")
|
|
279
|
-
@patch("vantage6.cli.node.check_docker_running", return_value=True)
|
|
279
|
+
@patch("vantage6.cli.node.clean.check_docker_running", return_value=True)
|
|
280
280
|
def test_clean(self, check_docker, volumes, q):
|
|
281
281
|
"""Clean Docker volumes without errors."""
|
|
282
282
|
volume1 = MagicMock()
|
|
@@ -293,10 +293,12 @@ class NodeCLITest(unittest.TestCase):
|
|
|
293
293
|
# check exit code
|
|
294
294
|
self.assertEqual(result.exit_code, 0)
|
|
295
295
|
|
|
296
|
-
@patch(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
296
|
+
@patch(
|
|
297
|
+
"vantage6.cli.node.create_private_key.create_client_and_authenticate")
|
|
298
|
+
@patch("vantage6.cli.node.common.NodeContext")
|
|
299
|
+
@patch("vantage6.cli.node.create_private_key.NodeContext")
|
|
300
|
+
def test_create_private_key(self, context, common_context, client):
|
|
301
|
+
common_context.config_exists.return_value = True
|
|
300
302
|
context.return_value.type_data_folder.return_value = Path(".")
|
|
301
303
|
client.return_value = MagicMock(
|
|
302
304
|
whoami=MagicMock(organization_name="Test")
|
|
@@ -307,16 +309,19 @@ class NodeCLITest(unittest.TestCase):
|
|
|
307
309
|
result = runner.invoke(cli_node_create_private_key,
|
|
308
310
|
["--name", "application"])
|
|
309
311
|
|
|
312
|
+
self.assertEqual(result.exit_code, 0)
|
|
313
|
+
|
|
310
314
|
# remove the private key file again
|
|
311
315
|
os.remove("privkey_Test.pem")
|
|
312
316
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
@patch("vantage6.cli.node.
|
|
317
|
-
@patch("vantage6.cli.node.NodeContext")
|
|
318
|
-
def test_create_private_key_overwite(self, context, client,
|
|
319
|
-
|
|
317
|
+
@patch("vantage6.cli.node.create_private_key.RSACryptor")
|
|
318
|
+
@patch(
|
|
319
|
+
"vantage6.cli.node.create_private_key.create_client_and_authenticate")
|
|
320
|
+
@patch("vantage6.cli.node.common.NodeContext")
|
|
321
|
+
@patch("vantage6.cli.node.create_private_key.NodeContext")
|
|
322
|
+
def test_create_private_key_overwite(self, context, common_context, client,
|
|
323
|
+
cryptor):
|
|
324
|
+
common_context.config_exists.return_value = True
|
|
320
325
|
context.return_value.type_data_folder.return_value = Path(".")
|
|
321
326
|
client.return_value = MagicMock(
|
|
322
327
|
whoami=MagicMock(organization_name="Test")
|
|
@@ -356,7 +361,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
356
361
|
|
|
357
362
|
self.assertEqual(result.exit_code, 0)
|
|
358
363
|
|
|
359
|
-
@patch("vantage6.cli.node.NodeContext")
|
|
364
|
+
@patch("vantage6.cli.node.common.NodeContext")
|
|
360
365
|
def test_create_private_key_config_not_found(self, context):
|
|
361
366
|
context.config_exists.return_value = False
|
|
362
367
|
|
|
@@ -366,7 +371,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
366
371
|
|
|
367
372
|
self.assertEqual(result.exit_code, 1)
|
|
368
373
|
|
|
369
|
-
@patch("vantage6.cli.node.q")
|
|
374
|
+
@patch("vantage6.cli.node.clean.q")
|
|
370
375
|
@patch("docker.DockerClient.volumes")
|
|
371
376
|
@patch("vantage6.common.docker.addons.check_docker_running")
|
|
372
377
|
def test_clean_docker_error(self, check_docker, volumes, q):
|
|
@@ -385,19 +390,19 @@ class NodeCLITest(unittest.TestCase):
|
|
|
385
390
|
# check exit code
|
|
386
391
|
self.assertEqual(result.exit_code, 1)
|
|
387
392
|
|
|
388
|
-
def
|
|
393
|
+
def test_print_log_worker(self):
|
|
389
394
|
stream = BytesIO("Hello!".encode(STRING_ENCODING))
|
|
390
395
|
temp_stdout = StringIO()
|
|
391
396
|
with contextlib.redirect_stdout(temp_stdout):
|
|
392
|
-
|
|
397
|
+
print_log_worker(stream)
|
|
393
398
|
output = temp_stdout.getvalue().strip()
|
|
394
399
|
self.assertEqual(output, "Hello!")
|
|
395
400
|
|
|
396
|
-
@patch("vantage6.cli.node.info")
|
|
397
|
-
@patch("vantage6.cli.node.debug")
|
|
398
|
-
@patch("vantage6.cli.node.error")
|
|
399
|
-
@patch("vantage6.cli.node.UserClient")
|
|
400
|
-
@patch("vantage6.cli.node.q")
|
|
401
|
+
@patch("vantage6.cli.node.common.info")
|
|
402
|
+
@patch("vantage6.cli.node.common.debug")
|
|
403
|
+
@patch("vantage6.cli.node.common.error")
|
|
404
|
+
@patch("vantage6.cli.node.common.UserClient")
|
|
405
|
+
@patch("vantage6.cli.node.common.q")
|
|
401
406
|
def test_client(self, q, client, error, debug, info):
|
|
402
407
|
|
|
403
408
|
ctx = MagicMock(
|
|
@@ -410,14 +415,14 @@ class NodeCLITest(unittest.TestCase):
|
|
|
410
415
|
|
|
411
416
|
# should not trigger an exception
|
|
412
417
|
try:
|
|
413
|
-
|
|
418
|
+
create_client_and_authenticate(ctx)
|
|
414
419
|
except Exception:
|
|
415
420
|
self.fail("Raised an exception!")
|
|
416
421
|
|
|
417
422
|
# client raises exception
|
|
418
423
|
client.side_effect = Exception("Boom!")
|
|
419
424
|
with self.assertRaises(Exception):
|
|
420
|
-
|
|
425
|
+
create_client_and_authenticate(ctx)
|
|
421
426
|
|
|
422
427
|
# TODO this function has been moved to the common package. A test should
|
|
423
428
|
# be added there instead of here
|
tests_cli/test_server_cli.py
CHANGED
|
@@ -5,26 +5,24 @@ from pathlib import Path
|
|
|
5
5
|
from click.testing import CliRunner
|
|
6
6
|
|
|
7
7
|
from vantage6.cli.globals import APPNAME
|
|
8
|
-
from vantage6.cli.server import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
cli_server_attach
|
|
16
|
-
)
|
|
8
|
+
from vantage6.cli.server.start import cli_server_start
|
|
9
|
+
from vantage6.cli.server.list import cli_server_configuration_list
|
|
10
|
+
from vantage6.cli.server.files import cli_server_files
|
|
11
|
+
from vantage6.cli.server.import_ import cli_server_import
|
|
12
|
+
from vantage6.cli.server.new import cli_server_new
|
|
13
|
+
from vantage6.cli.server.stop import cli_server_stop
|
|
14
|
+
from vantage6.cli.server.attach import cli_server_attach
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
class ServerCLITest(unittest.TestCase):
|
|
20
18
|
|
|
21
|
-
@patch("vantage6.cli.server.NetworkManager")
|
|
22
|
-
@patch("vantage6.cli.server.docker.types.Mount")
|
|
19
|
+
@patch("vantage6.cli.server.start.NetworkManager")
|
|
20
|
+
@patch("vantage6.cli.server.start.docker.types.Mount")
|
|
23
21
|
@patch("os.makedirs")
|
|
24
|
-
@patch("vantage6.cli.server.pull_if_newer")
|
|
25
|
-
@patch("vantage6.cli.server.ServerContext")
|
|
26
|
-
@patch("vantage6.cli.server.docker.from_env")
|
|
27
|
-
@patch("vantage6.cli.server.check_docker_running", return_value=True)
|
|
22
|
+
@patch("vantage6.cli.server.start.pull_if_newer")
|
|
23
|
+
@patch("vantage6.cli.server.common.ServerContext")
|
|
24
|
+
@patch("vantage6.cli.server.start.docker.from_env")
|
|
25
|
+
@patch("vantage6.cli.server.start.check_docker_running", return_value=True)
|
|
28
26
|
def test_start(self, docker_check, containers, context,
|
|
29
27
|
pull, os_makedirs, mount, network_manager):
|
|
30
28
|
"""Start server without errors"""
|
|
@@ -52,9 +50,9 @@ class ServerCLITest(unittest.TestCase):
|
|
|
52
50
|
|
|
53
51
|
self.assertEqual(result.exit_code, 0)
|
|
54
52
|
|
|
55
|
-
@patch("vantage6.cli.server.ServerContext")
|
|
53
|
+
@patch("vantage6.cli.server.common.ServerContext")
|
|
56
54
|
@patch("docker.DockerClient.containers")
|
|
57
|
-
@patch("vantage6.cli.server.check_docker_running", return_value=True)
|
|
55
|
+
@patch("vantage6.cli.server.list.check_docker_running", return_value=True)
|
|
58
56
|
def test_configuration_list(self, docker_check, containers, context):
|
|
59
57
|
"""Configuration list without errors."""
|
|
60
58
|
container1 = MagicMock()
|
|
@@ -71,7 +69,7 @@ class ServerCLITest(unittest.TestCase):
|
|
|
71
69
|
self.assertEqual(result.exit_code, 0)
|
|
72
70
|
self.assertIsNone(result.exception)
|
|
73
71
|
|
|
74
|
-
@patch("vantage6.cli.server.ServerContext")
|
|
72
|
+
@patch("vantage6.cli.server.common.ServerContext")
|
|
75
73
|
def test_files(self, context):
|
|
76
74
|
"""Configuration files without errors."""
|
|
77
75
|
|
|
@@ -88,10 +86,11 @@ class ServerCLITest(unittest.TestCase):
|
|
|
88
86
|
self.assertEqual(result.exit_code, 0)
|
|
89
87
|
|
|
90
88
|
@patch("docker.DockerClient.containers")
|
|
91
|
-
@patch("vantage6.cli.server.
|
|
92
|
-
@patch("vantage6.cli.server.click.Path")
|
|
93
|
-
@patch("vantage6.cli.server.check_docker_running",
|
|
94
|
-
|
|
89
|
+
@patch("vantage6.cli.server.import_.print_log_worker")
|
|
90
|
+
@patch("vantage6.cli.server.import_.click.Path")
|
|
91
|
+
@patch("vantage6.cli.server.import_.check_docker_running",
|
|
92
|
+
return_value=True)
|
|
93
|
+
@patch("vantage6.cli.server.common.ServerContext")
|
|
95
94
|
def test_import(self, context, docker_check, click_path, log, containers):
|
|
96
95
|
"""Import entities without errors."""
|
|
97
96
|
click_path.return_value = MagicMock()
|
|
@@ -111,9 +110,9 @@ class ServerCLITest(unittest.TestCase):
|
|
|
111
110
|
self.assertIsNone(result.exception)
|
|
112
111
|
self.assertEqual(result.exit_code, 0)
|
|
113
112
|
|
|
114
|
-
@patch("vantage6.cli.server.configuration_wizard")
|
|
115
|
-
@patch("vantage6.cli.server.check_config_writeable")
|
|
116
|
-
@patch("vantage6.cli.server.ServerContext")
|
|
113
|
+
@patch("vantage6.cli.server.new.configuration_wizard")
|
|
114
|
+
@patch("vantage6.cli.server.new.check_config_writeable")
|
|
115
|
+
@patch("vantage6.cli.server.new.ServerContext")
|
|
117
116
|
def test_new(self, context, permissions, wizard):
|
|
118
117
|
"""New configuration without errors."""
|
|
119
118
|
|
|
@@ -127,9 +126,9 @@ class ServerCLITest(unittest.TestCase):
|
|
|
127
126
|
self.assertIsNone(result.exception)
|
|
128
127
|
self.assertEqual(result.exit_code, 0)
|
|
129
128
|
|
|
130
|
-
@patch("vantage6.cli.server.ServerContext")
|
|
131
|
-
@patch("vantage6.cli.server.docker.from_env")
|
|
132
|
-
@patch("vantage6.cli.server.check_docker_running", return_value=True)
|
|
129
|
+
@patch("vantage6.cli.server.stop.ServerContext")
|
|
130
|
+
@patch("vantage6.cli.server.stop.docker.from_env")
|
|
131
|
+
@patch("vantage6.cli.server.stop.check_docker_running", return_value=True)
|
|
133
132
|
def test_stop(self, docker_check, containers, context):
|
|
134
133
|
"""Stop server without errors."""
|
|
135
134
|
|
|
@@ -150,9 +149,10 @@ class ServerCLITest(unittest.TestCase):
|
|
|
150
149
|
self.assertIsNone(result.exception)
|
|
151
150
|
self.assertEqual(result.exit_code, 0)
|
|
152
151
|
|
|
153
|
-
@patch("vantage6.cli.server.time.sleep")
|
|
152
|
+
@patch("vantage6.cli.server.attach.time.sleep")
|
|
154
153
|
@patch("docker.DockerClient.containers")
|
|
155
|
-
@patch("vantage6.cli.server.check_docker_running",
|
|
154
|
+
@patch("vantage6.cli.server.attach.check_docker_running",
|
|
155
|
+
return_value=True)
|
|
156
156
|
def test_attach(self, docker_check, containers, sleep):
|
|
157
157
|
"""Attach log to the console without errors."""
|
|
158
158
|
container1 = MagicMock()
|
vantage6/cli/_version.py
CHANGED
|
@@ -7,7 +7,7 @@ with open(os.path.join(here, '__build__')) as fp:
|
|
|
7
7
|
__build__ = json.load(fp)
|
|
8
8
|
|
|
9
9
|
# Module version
|
|
10
|
-
version_info = (4,
|
|
10
|
+
version_info = (4, 1, 0, 'beta', __build__, 0)
|
|
11
11
|
|
|
12
12
|
# Module version stage suffix map
|
|
13
13
|
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
|
vantage6/cli/cli.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.cli.server.attach import cli_server_attach
|
|
4
|
+
from vantage6.cli.server.files import cli_server_files
|
|
5
|
+
from vantage6.cli.server.import_ import cli_server_import
|
|
6
|
+
from vantage6.cli.server.list import cli_server_configuration_list
|
|
7
|
+
from vantage6.cli.server.new import cli_server_new
|
|
8
|
+
from vantage6.cli.server.shell import cli_server_shell
|
|
9
|
+
from vantage6.cli.server.start import cli_server_start
|
|
10
|
+
from vantage6.cli.server.stop import cli_server_stop
|
|
11
|
+
from vantage6.cli.server.version import cli_server_version
|
|
12
|
+
from vantage6.cli.node.attach import cli_node_attach
|
|
13
|
+
from vantage6.cli.node.clean import cli_node_clean
|
|
14
|
+
from vantage6.cli.node.create_private_key import cli_node_create_private_key
|
|
15
|
+
from vantage6.cli.node.files import cli_node_files
|
|
16
|
+
from vantage6.cli.node.list import cli_node_list
|
|
17
|
+
from vantage6.cli.node.new import cli_node_new_configuration
|
|
18
|
+
from vantage6.cli.node.remove import cli_node_remove
|
|
19
|
+
from vantage6.cli.node.set_api_key import cli_node_set_api_key
|
|
20
|
+
from vantage6.cli.node.start import cli_node_start
|
|
21
|
+
from vantage6.cli.node.stop import cli_node_stop
|
|
22
|
+
from vantage6.cli.node.version import cli_node_version
|
|
23
|
+
from vantage6.cli.dev.create import create_demo_network
|
|
24
|
+
from vantage6.cli.dev.remove import remove_demo_network
|
|
25
|
+
from vantage6.cli.dev.start import start_demo_network
|
|
26
|
+
from vantage6.cli.dev.stop import stop_demo_network
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Define the server group
|
|
30
|
+
@click.group(name='server')
|
|
31
|
+
def cli_server() -> None:
|
|
32
|
+
"""
|
|
33
|
+
Manage your vantage6 server instances.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# Define the commands for the server group
|
|
38
|
+
cli_server.add_command(cli_server_attach, name='attach')
|
|
39
|
+
cli_server.add_command(cli_server_files, name='files')
|
|
40
|
+
cli_server.add_command(cli_server_import, name='import')
|
|
41
|
+
cli_server.add_command(cli_server_configuration_list, name='list')
|
|
42
|
+
cli_server.add_command(cli_server_new, name='new')
|
|
43
|
+
cli_server.add_command(cli_server_shell, name='shell')
|
|
44
|
+
cli_server.add_command(cli_server_start, name='start')
|
|
45
|
+
cli_server.add_command(cli_server_stop, name='stop')
|
|
46
|
+
cli_server.add_command(cli_server_version, name='version')
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Define the node group
|
|
50
|
+
@click.group(name="node")
|
|
51
|
+
def cli_node() -> None:
|
|
52
|
+
"""
|
|
53
|
+
Manage your vantage6 node instances.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Define the commands for the node group
|
|
58
|
+
cli_node.add_command(cli_node_attach, name="attach")
|
|
59
|
+
cli_node.add_command(cli_node_clean, name="clean")
|
|
60
|
+
cli_node.add_command(cli_node_create_private_key, name="create-private-key")
|
|
61
|
+
cli_node.add_command(cli_node_files, name="files")
|
|
62
|
+
cli_node.add_command(cli_node_list, name="list")
|
|
63
|
+
cli_node.add_command(cli_node_new_configuration, name="new")
|
|
64
|
+
cli_node.add_command(cli_node_remove, name="remove")
|
|
65
|
+
cli_node.add_command(cli_node_set_api_key, name="set-api-key")
|
|
66
|
+
cli_node.add_command(cli_node_start, name="start")
|
|
67
|
+
cli_node.add_command(cli_node_stop, name="stop")
|
|
68
|
+
cli_node.add_command(cli_node_version, name="version")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Define the dev group
|
|
72
|
+
@click.group(name="dev")
|
|
73
|
+
def cli_dev() -> None:
|
|
74
|
+
"""
|
|
75
|
+
Quickly manage a test network with a server and several nodes.
|
|
76
|
+
|
|
77
|
+
These commands are helpful for local testing of your vantage6 environment.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# Define the commands for the dev group
|
|
82
|
+
cli_dev.add_command(create_demo_network, name="create-demo-network")
|
|
83
|
+
cli_dev.add_command(remove_demo_network, name="remove-demo-network")
|
|
84
|
+
cli_dev.add_command(start_demo_network, name="start-demo-network")
|
|
85
|
+
cli_dev.add_command(stop_demo_network, name="stop-demo-network")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# Define the overall group
|
|
89
|
+
@click.group(name='cli')
|
|
90
|
+
def cli_complete() -> None:
|
|
91
|
+
"""
|
|
92
|
+
The `v6` command line interface allows you to manage your vantage6
|
|
93
|
+
infrastructure.
|
|
94
|
+
|
|
95
|
+
It provides a number of subcommands to help you with this task.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# Add the subcommands to the overall group
|
|
100
|
+
cli_complete.add_command(cli_node)
|
|
101
|
+
cli_complete.add_command(cli_server)
|
|
102
|
+
cli_complete.add_command(cli_dev)
|