tft-cli 0.0.19__py3-none-any.whl → 0.0.20__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.
tft/cli/commands.py CHANGED
@@ -6,8 +6,8 @@ import json
6
6
  import os
7
7
  import re
8
8
  import shutil
9
+ import stat
9
10
  import subprocess
10
- import tempfile
11
11
  import textwrap
12
12
  import time
13
13
  import urllib.parse
@@ -1189,6 +1189,28 @@ def reserve(
1189
1189
  if not print_only_request_id:
1190
1190
  console.print(message)
1191
1191
 
1192
+ # Sanity checks for ssh-agent
1193
+
1194
+ # Check of SSH_AUTH_SOCK is defined
1195
+ ssh_auth_sock = os.getenv("SSH_AUTH_SOCK")
1196
+ if not ssh_auth_sock:
1197
+ exit_error("SSH_AUTH_SOCK is not defined, make sure the ssh-agent is running by executing 'eval `ssh-agent`'.")
1198
+
1199
+ # Check if SSH_AUTH_SOCK exists
1200
+ if not os.path.exists(ssh_auth_sock):
1201
+ exit_error(
1202
+ "SSH_AUTH_SOCK socket does not exist, make sure the ssh-agent is running by executing 'eval `ssh-agent`'."
1203
+ )
1204
+
1205
+ # Check if value of SSH_AUTH_SOCK is socket
1206
+ if not stat.S_ISSOCK(os.stat(ssh_auth_sock).st_mode):
1207
+ exit_error("SSH_AUTH_SOCK is not a socket, make sure the ssh-agent is running by executing 'eval `ssh-agent`'.")
1208
+
1209
+ # Check if ssh-add -L is not empty
1210
+ ssh_add_output = subprocess.run(["ssh-add", "-L"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
1211
+ if ssh_add_output.returncode != 0:
1212
+ exit_error("No SSH identities found in the SSH agent. Please run `ssh-add`.")
1213
+
1192
1214
  # check for token
1193
1215
  if not settings.API_TOKEN:
1194
1216
  exit_error("No API token found, export `TESTING_FARM_API_TOKEN` environment variable.")
@@ -1427,24 +1449,16 @@ def reserve(
1427
1449
 
1428
1450
  ssh_proxy_option = f" -J {content['ssh_proxy']}" if content.get('ssh_proxy') else ""
1429
1451
 
1430
- ssh_private_key_option = ""
1431
1452
  if ssh_private_key:
1432
- tmp = tempfile.NamedTemporaryFile(delete=False)
1433
- tmp.write(ssh_private_key.encode())
1434
- tmp.flush()
1435
- tmp.close()
1436
-
1437
- os.chmod(tmp.name, 0o600)
1438
-
1439
- ssh_private_key_option = f" -i {tmp.name}"
1453
+ console.print("🔑 [blue]Adding SSH proxy key[/blue]")
1454
+ subprocess.run(["ssh-add", "-"], input=ssh_private_key.encode())
1440
1455
 
1441
- console.print(f"🌎 ssh{ssh_proxy_option}{ssh_private_key_option} root@{guest}")
1456
+ console.print(f"🌎 ssh{ssh_proxy_option} root@{guest}")
1442
1457
 
1443
1458
  if autoconnect:
1444
1459
  os.system(
1445
- f"ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null{ssh_proxy_option}{ssh_private_key_option} root@{guest}" # noqa: E501
1460
+ f"ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null{ssh_proxy_option} root@{guest}" # noqa: E501
1446
1461
  )
1447
- os.unlink(tmp.name)
1448
1462
 
1449
1463
 
1450
1464
  def update():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tft-cli
3
- Version: 0.0.19
3
+ Version: 0.0.20
4
4
  Summary: Testing Farm CLI tool
5
5
  License: Apache-2.0
6
6
  Author: Miroslav Vadkerti
@@ -0,0 +1,10 @@
1
+ tft/cli/__init__.py,sha256=uEJkNJbqC583PBtNI30kxWdeOr3Wj6zJzIYKf0AD72I,92
2
+ tft/cli/commands.py,sha256=nGzFCuKTFrwRAJwhm7Fd-uPmTqh5ONEBoa-2ubH9Fpg,56699
3
+ tft/cli/config.py,sha256=lJ9TtsBAdcNDbh4xZd0x1b48V7IsGl3t7kALmNjCqNs,1115
4
+ tft/cli/tool.py,sha256=wFcVxe1NRGW8stputOZlKMasZHjpysas7f0sgpEzipQ,865
5
+ tft/cli/utils.py,sha256=9s7zY_k1MYYPTF4Gr2AMH2DMcySUCIgXbF3LjYa7bzY,7404
6
+ tft_cli-0.0.20.dist-info/LICENSE,sha256=YpVAQfXkIyzQAdm5LZkI6L5UWqLppa6O8_tgDSdoabQ,574
7
+ tft_cli-0.0.20.dist-info/METADATA,sha256=dVw-eLgGMMRxiN055vL_nIX59bDxInpZ_XSRsbtLjOI,731
8
+ tft_cli-0.0.20.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
9
+ tft_cli-0.0.20.dist-info/entry_points.txt,sha256=xzdebHkH5Bx-YRf-XPMsIoVpvgfUqqcRQGuo8DFkiao,49
10
+ tft_cli-0.0.20.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- tft/cli/__init__.py,sha256=uEJkNJbqC583PBtNI30kxWdeOr3Wj6zJzIYKf0AD72I,92
2
- tft/cli/commands.py,sha256=F9Mtg7x6al97Yo7WkTTTZHzNcMUXLa5A2h4J0H7ED0g,55908
3
- tft/cli/config.py,sha256=lJ9TtsBAdcNDbh4xZd0x1b48V7IsGl3t7kALmNjCqNs,1115
4
- tft/cli/tool.py,sha256=wFcVxe1NRGW8stputOZlKMasZHjpysas7f0sgpEzipQ,865
5
- tft/cli/utils.py,sha256=9s7zY_k1MYYPTF4Gr2AMH2DMcySUCIgXbF3LjYa7bzY,7404
6
- tft_cli-0.0.19.dist-info/LICENSE,sha256=YpVAQfXkIyzQAdm5LZkI6L5UWqLppa6O8_tgDSdoabQ,574
7
- tft_cli-0.0.19.dist-info/METADATA,sha256=FfP_InbT9Kd1lXM85xL-1UIijPCoCk5ZagIBK_W2LGg,731
8
- tft_cli-0.0.19.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
9
- tft_cli-0.0.19.dist-info/entry_points.txt,sha256=xzdebHkH5Bx-YRf-XPMsIoVpvgfUqqcRQGuo8DFkiao,49
10
- tft_cli-0.0.19.dist-info/RECORD,,