aboutsummaryrefslogtreecommitdiff
path: root/scenarios/fragments/garage.py
diff options
context:
space:
mode:
Diffstat (limited to 'scenarios/fragments/garage.py')
-rw-r--r--scenarios/fragments/garage.py51
1 files changed, 11 insertions, 40 deletions
diff --git a/scenarios/fragments/garage.py b/scenarios/fragments/garage.py
index d0d5209..c1e09d0 100644
--- a/scenarios/fragments/garage.py
+++ b/scenarios/fragments/garage.py
@@ -2,18 +2,15 @@ import glob, json, time
from os.path import exists
from os import environ as env
from pathlib import Path
-from . import shared
-
-try:
- import garage_admin_sdk
- from garage_admin_sdk.api import nodes_api, layout_api, key_api
- from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo
- from garage_admin_sdk.model.layout_version import LayoutVersion
- from garage_admin_sdk.model.add_key_request import AddKeyRequest
- from garage_admin_sdk.model.update_key_request import UpdateKeyRequest
- from garage_admin_sdk.model.update_key_request_allow import UpdateKeyRequestAllow
-except:
- pass
+from . import shared, flavor
+
+import garage_admin_sdk
+from garage_admin_sdk.api import nodes_api, layout_api, key_api
+from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo
+from garage_admin_sdk.model.layout_version import LayoutVersion
+from garage_admin_sdk.model.add_key_request import AddKeyRequest
+from garage_admin_sdk.model.update_key_request import UpdateKeyRequest
+from garage_admin_sdk.model.update_key_request_allow import UpdateKeyRequestAllow
storage_path = "./i/am/not/defined"
rpc_secret = "3e9abff5f9e480afbadb46a77b7a26fe0e404258f0dc3fd5386b0ba8e0ad2fba"
@@ -21,12 +18,7 @@ metrics = "cacce0b2de4bc2d9f5b5fdff551e01ac1496055aed248202d415398987e35f81"
admin = "ae8cb40ea7368bbdbb6430af11cca7da833d3458a5f52086f4e805a570fb5c2a"
key = None
-version_flavor = {
- "garage-local": { "path": "./garage/target/release/garage" },
- "garage-v0.7": { "version": "v0.7.3", "target": "x86_64-unknown-linux-musl" },
- "garage-v0.8": { "version": "89b8087ba81c508ba382aa6c9cb6bb3afa6a43c8", "target": "x86_64-unknown-linux-musl" },
-}
-version = version_flavor["garage-v0.7"]
+version = flavor.garage["garage-v0.7"]
configuration = garage_admin_sdk.Configuration(
host = "http://localhost:3903/v0",
@@ -66,27 +58,6 @@ def deploy_follow(version=None, target=None):
sync_on_key_up()
shared.log("ready")
-def path(vers=None):
- if vers is None:
- vers = version
-
- if "path" in vers: return vers["path"]
- else:
- binary = f"garage-{vers['target']}-{vers['version']}"
- return Path(shared.binary_path) / binary
-
-def download():
- for flav, version in version_flavor.items():
- if "path" in version: continue
-
- p = path(vers=version)
- if exists(p): continue
-
- shared.exec(f"mkdir -p {shared.binary_path}")
- shared.exec(f"wget https://garagehq.deuxfleurs.fr/_releases/{version['version']}/{version['target']}/garage -O {p}")
- shared.exec(f"chmod +x {p}")
- shared.exec(f"{p} --version")
-
def daemon():
shared.exec(f"mkdir -p {storage_path}")
with open(config, 'w+') as f:
@@ -118,7 +89,7 @@ metrics_token = "{metrics}"
admin_token = "{admin}"
""")
- shared.exec(f"{path()} server 2>> {storage_path}/logs.stderr 1>> {storage_path}/logs.stdout & echo $! > {storage_path}/daemon.pid")
+ shared.exec(f"{version['path']} server 2>> {storage_path}/logs.stderr 1>> {storage_path}/logs.stdout & echo $! > {storage_path}/daemon.pid")
time.sleep(1)
node_info = storage_path / "node_info"