Skip to content

Commit 58982dd

Browse files
pinheadmzwillcl-ark
authored andcommitted
tank: restore get_architecture() for docker-compose.yml creation
1 parent a40c728 commit 58982dd

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/warnet/tank.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
import shutil
88
from copy import deepcopy
99
from pathlib import Path
10-
from docker.api import service
1110
from docker.models.containers import Container
12-
from services.fluentd import FLUENT_IP
1311
from templates import TEMPLATES
1412
from warnet.utils import (
1513
exponential_backoff,
1614
generate_ipv4_addr,
1715
sanitize_tc_netem_command,
1816
dump_bitcoin_conf,
1917
SUPPORTED_TAGS,
18+
get_architecture,
2019
)
2120

2221
CONTAINER_PREFIX_BITCOIND = "tank"
@@ -223,7 +222,7 @@ def add_services(self, services):
223222
"context": str(TEMPLATES),
224223
"dockerfile": str(TEMPLATES / f"Dockerfile"),
225224
"args": {
226-
"ARCH": "x86_64",
225+
"ARCH": get_architecture(),
227226
"BITCOIN_URL": "https://bitcoincore.org/bin",
228227
"BITCOIN_VERSION": f"{self.version}",
229228
},

src/warnet/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import random
77
import re
8+
import subprocess
89
import sys
910
import time
1011
from io import BytesIO
@@ -63,6 +64,20 @@ def wrapper(*args, **kwargs):
6364
return decorator
6465

6566

67+
def get_architecture():
68+
"""
69+
Get the architecture of the machine.
70+
:return: The architecture of the machine or None if an error occurred
71+
"""
72+
result = subprocess.run(["uname", "-m"], stdout=subprocess.PIPE)
73+
arch = result.stdout.decode("utf-8").strip()
74+
if arch == "arm64":
75+
arch = "aarch64"
76+
if arch is None:
77+
raise Exception("Failed to detect architecture.")
78+
return arch
79+
80+
6681
def generate_ipv4_addr(subnet):
6782
"""
6883
Generate a valid random IPv4 address within the given subnet.

0 commit comments

Comments
 (0)