1
1
import json
2
2
import shutil
3
- from importlib .resources import files
4
3
from pathlib import Path
5
4
6
5
from rich import print
7
6
8
7
from .bitcoin import _rpc
8
+ from .constants import (
9
+ LOGGING_HELM_COMMANDS ,
10
+ NETWORK_DIR ,
11
+ SCENARIOS_DIR ,
12
+ )
9
13
from .k8s import get_mission
10
14
from .process import stream_command
11
15
12
- WAR_MANIFESTS_FILES = files ("resources.manifests" )
13
- WAR_NETWORK_FILES = files ("resources.networks" )
14
- WAR_SCENARIOS_FILES = files ("resources.scenarios" )
15
-
16
- WAR_NETWORK_DIR = WAR_NETWORK_FILES .name
17
- WAR_SCENARIOS_DIR = WAR_SCENARIOS_FILES .name
18
-
19
- DEFAULT_NETWORK = Path ("6_node_bitcoin" )
20
- NETWORK_FILE = "network.yaml"
21
- DEFAULTS_FILE = "node-defaults.yaml"
22
- HELM_COMMAND = "helm upgrade --install --create-namespace"
23
- BITCOIN_CHART_LOCATION = str (files ("resources.charts" ).joinpath ("bitcoincore" ))
24
- FORK_OBSERVER_CHART = str (files ("resources.charts" ).joinpath ("fork-observer" ))
25
-
26
16
27
17
def setup_logging_helm () -> bool :
28
- helm_commands = [
29
- "helm repo add grafana https://grafana.github.io/helm-charts" ,
30
- "helm repo add prometheus-community https://prometheus-community.github.io/helm-charts" ,
31
- "helm repo update" ,
32
- f"helm upgrade --install --namespace warnet-logging --create-namespace --values { WAR_MANIFESTS_FILES } /loki_values.yaml loki grafana/loki --version 5.47.2" ,
33
- "helm upgrade --install --namespace warnet-logging promtail grafana/promtail" ,
34
- "helm upgrade --install --namespace warnet-logging prometheus prometheus-community/kube-prometheus-stack --namespace warnet-logging --set grafana.enabled=false" ,
35
- f"helm upgrade --install --namespace warnet-logging loki-grafana grafana/grafana --values { WAR_MANIFESTS_FILES } /grafana_values.yaml" ,
36
- ]
37
-
38
- for command in helm_commands :
18
+ for command in LOGGING_HELM_COMMANDS :
39
19
if not stream_command (command ):
40
20
print (f"Failed to run Helm command: { command } " )
41
21
return False
@@ -67,8 +47,8 @@ def copy_network_defaults(directory: Path):
67
47
"""Create the project structure for a warnet project's network"""
68
48
copy_defaults (
69
49
directory ,
70
- WAR_NETWORK_DIR ,
71
- WAR_NETWORK_FILES . joinpath () ,
50
+ NETWORK_DIR . name ,
51
+ NETWORK_DIR ,
72
52
["node-defaults.yaml" , "__pycache__" , "__init__.py" ],
73
53
)
74
54
@@ -77,8 +57,8 @@ def copy_scenario_defaults(directory: Path):
77
57
"""Create the project structure for a warnet project's scenarios"""
78
58
copy_defaults (
79
59
directory ,
80
- WAR_SCENARIOS_DIR ,
81
- WAR_SCENARIOS_FILES . joinpath () ,
60
+ SCENARIOS_DIR . name ,
61
+ SCENARIOS_DIR ,
82
62
["__init__.py" , "__pycache__" , "commander.py" ],
83
63
)
84
64
0 commit comments