tft-cli 0.0.18__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 +53 -2
- tft/cli/config.py +3 -0
- {tft_cli-0.0.18.dist-info → tft_cli-0.0.20.dist-info}/METADATA +2 -1
- tft_cli-0.0.20.dist-info/RECORD +10 -0
- tft_cli-0.0.18.dist-info/RECORD +0 -10
- {tft_cli-0.0.18.dist-info → tft_cli-0.0.20.dist-info}/LICENSE +0 -0
- {tft_cli-0.0.18.dist-info → tft_cli-0.0.20.dist-info}/WHEEL +0 -0
- {tft_cli-0.0.18.dist-info → tft_cli-0.0.20.dist-info}/entry_points.txt +0 -0
tft/cli/commands.py
CHANGED
|
@@ -6,6 +6,7 @@ import json
|
|
|
6
6
|
import os
|
|
7
7
|
import re
|
|
8
8
|
import shutil
|
|
9
|
+
import stat
|
|
9
10
|
import subprocess
|
|
10
11
|
import textwrap
|
|
11
12
|
import time
|
|
@@ -519,6 +520,7 @@ def request(
|
|
|
519
520
|
fedora_copr_build: List[str] = OPTION_FEDORA_COPR_BUILD,
|
|
520
521
|
repository: List[str] = OPTION_REPOSITORY,
|
|
521
522
|
repository_file: List[str] = OPTION_REPOSITORY_FILE,
|
|
523
|
+
sanity: bool = typer.Option(False, help="Run Testing Farm sanity test.", rich_help_panel=RESERVE_PANEL_GENERAL),
|
|
522
524
|
tags: Optional[List[str]] = typer.Option(
|
|
523
525
|
None,
|
|
524
526
|
"-t",
|
|
@@ -566,6 +568,16 @@ def request(
|
|
|
566
568
|
"Only 'x86_64' architecture supported in this case."
|
|
567
569
|
)
|
|
568
570
|
|
|
571
|
+
if sanity:
|
|
572
|
+
if git_url or tmt_plan_name:
|
|
573
|
+
exit_error(
|
|
574
|
+
"The option [underline]--sanity[/underline] is mutually exclusive with "
|
|
575
|
+
"[underline]--git-url[/underline] and [underline]--plan[/underline]."
|
|
576
|
+
)
|
|
577
|
+
|
|
578
|
+
git_url = str(settings.TESTING_FARM_TESTS_GIT_URL)
|
|
579
|
+
tmt_plan_name = str(settings.TESTING_FARM_SANITY_PLAN)
|
|
580
|
+
|
|
569
581
|
# resolve git repository details from the current repository
|
|
570
582
|
if not git_url:
|
|
571
583
|
if not git_available:
|
|
@@ -1177,6 +1189,28 @@ def reserve(
|
|
|
1177
1189
|
if not print_only_request_id:
|
|
1178
1190
|
console.print(message)
|
|
1179
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
|
+
|
|
1180
1214
|
# check for token
|
|
1181
1215
|
if not settings.API_TOKEN:
|
|
1182
1216
|
exit_error("No API token found, export `TESTING_FARM_API_TOKEN` environment variable.")
|
|
@@ -1404,10 +1438,27 @@ def reserve(
|
|
|
1404
1438
|
|
|
1405
1439
|
time.sleep(1)
|
|
1406
1440
|
|
|
1407
|
-
|
|
1441
|
+
sshproxy_url = urllib.parse.urljoin(str(settings.API_URL), f"v0.1/sshproxy?api_key={settings.API_TOKEN}")
|
|
1442
|
+
response = session.get(sshproxy_url)
|
|
1443
|
+
|
|
1444
|
+
content = response.json()
|
|
1445
|
+
|
|
1446
|
+
ssh_private_key = ""
|
|
1447
|
+
if content.get('ssh_private_key_base_64'):
|
|
1448
|
+
ssh_private_key = base64.b64decode(content['ssh_private_key_base_64']).decode()
|
|
1449
|
+
|
|
1450
|
+
ssh_proxy_option = f" -J {content['ssh_proxy']}" if content.get('ssh_proxy') else ""
|
|
1451
|
+
|
|
1452
|
+
if ssh_private_key:
|
|
1453
|
+
console.print("🔑 [blue]Adding SSH proxy key[/blue]")
|
|
1454
|
+
subprocess.run(["ssh-add", "-"], input=ssh_private_key.encode())
|
|
1455
|
+
|
|
1456
|
+
console.print(f"🌎 ssh{ssh_proxy_option} root@{guest}")
|
|
1408
1457
|
|
|
1409
1458
|
if autoconnect:
|
|
1410
|
-
os.system(
|
|
1459
|
+
os.system(
|
|
1460
|
+
f"ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null{ssh_proxy_option} root@{guest}" # noqa: E501
|
|
1461
|
+
)
|
|
1411
1462
|
|
|
1412
1463
|
|
|
1413
1464
|
def update():
|
tft/cli/config.py
CHANGED
|
@@ -21,4 +21,7 @@ settings = LazySettings(
|
|
|
21
21
|
DEFAULT_RETRY_BACKOFF_FACTOR=1,
|
|
22
22
|
# system CA certificates path, default for RHEL variants
|
|
23
23
|
REQUESTS_CA_BUNDLE="/etc/ssl/certs/ca-bundle.crt",
|
|
24
|
+
# Testing Farm sanity test,
|
|
25
|
+
TESTING_FARM_TESTS_GIT_URL="https://gitlab.com/testing-farm/tests",
|
|
26
|
+
TESTING_FARM_SANITY_PLAN="/testing-farm/sanity",
|
|
24
27
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tft-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.20
|
|
4
4
|
Summary: Testing Farm CLI tool
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: Miroslav Vadkerti
|
|
@@ -16,4 +16,5 @@ Requires-Dist: colorama (>=0.4.4,<0.5.0)
|
|
|
16
16
|
Requires-Dist: dynaconf (>=3.1.7,<4.0.0)
|
|
17
17
|
Requires-Dist: requests (>=2.27.1,<3.0.0)
|
|
18
18
|
Requires-Dist: ruamel-yaml (>=0.18.6,<0.19.0)
|
|
19
|
+
Requires-Dist: setuptools
|
|
19
20
|
Requires-Dist: typer[all] (>=0.7.0,<0.8.0)
|
|
@@ -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,,
|
tft_cli-0.0.18.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
tft/cli/__init__.py,sha256=uEJkNJbqC583PBtNI30kxWdeOr3Wj6zJzIYKf0AD72I,92
|
|
2
|
-
tft/cli/commands.py,sha256=Io1U_zo1ZWtqdfhf4WpXpsLlyBpXRh0XuEEoTop2mIE,54520
|
|
3
|
-
tft/cli/config.py,sha256=rIY8y42pCruDtWAp8eCs08wm7gcWDKxU14Bs4ULkGqg,958
|
|
4
|
-
tft/cli/tool.py,sha256=wFcVxe1NRGW8stputOZlKMasZHjpysas7f0sgpEzipQ,865
|
|
5
|
-
tft/cli/utils.py,sha256=9s7zY_k1MYYPTF4Gr2AMH2DMcySUCIgXbF3LjYa7bzY,7404
|
|
6
|
-
tft_cli-0.0.18.dist-info/LICENSE,sha256=YpVAQfXkIyzQAdm5LZkI6L5UWqLppa6O8_tgDSdoabQ,574
|
|
7
|
-
tft_cli-0.0.18.dist-info/METADATA,sha256=b-bIarMMld3dufVt5pFI114lofPEvQ8ybg7oI5YOTuM,705
|
|
8
|
-
tft_cli-0.0.18.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
|
9
|
-
tft_cli-0.0.18.dist-info/entry_points.txt,sha256=xzdebHkH5Bx-YRf-XPMsIoVpvgfUqqcRQGuo8DFkiao,49
|
|
10
|
-
tft_cli-0.0.18.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|